Invision Community 4: SEO, prepare for v5 and dormant account notifications By Matt Monday at 02:04 PM
teraßyte Posted July 10, 2021 Posted July 10, 2021 I have an application that uses only $reviewClass and NO $commentClass which throws an error after upgrading to 4.6. This happens because loading the reviews then goes on to call the function _comments() from system\Content\Item::reviews() to load the data. The error is because of this code added in system\Content\Item::_comments() to handle solved contents, statistics, and recognized content (lines 4349-4400): /* Solved count */ $commentClass = static::$commentClass; $showSolvedStats = FALSE; if ( method_exists( $this, 'isQuestion' ) and $this->isQuestion() ) { $showSolvedStats = TRUE; } else if ( \IPS\IPS::classUsesTrait( $this, 'IPS\Content\Solvable' ) and ( $this->containerAllowsMemberSolvable() OR $this->containerAllowsSolvable() ) ) { $showSolvedStats = TRUE; } if ( $showSolvedStats ) { $memberIds = array(); $solvedCounts = array(); $authorField = $commentClass::$databaseColumnMap['author']; foreach( $results as $id => $data ) { $memberIds[ $data->$authorField ] = $data->$authorField; } if ( \count( $memberIds ) ) { foreach( \IPS\Db::i()->select( 'COUNT(*) as count, member_id', 'core_solved_index', array( \IPS\Db::i()->in( 'member_id', $memberIds ) ), NULL, NULL, 'member_id' ) as $member ) { $solvedCounts[ $member['member_id'] ] = $member['count']; } foreach( $results as $id => $data ) { if ( isset( $solvedCounts[ $data->$authorField ] ) ) { $results[ $id ]->author_solved_count = $solvedCounts[ $data->$authorField ]; } } } } /* Recognized content */ if ( \IPS\IPS::classUsesTrait( $commentClass, 'IPS\Content\Recognizable' ) ) { foreach( \IPS\Db::i()->select( '*', 'core_member_recognize', [ [ 'r_content_class=?', $commentClass ], [ \IPS\Db::i()->in('r_content_id', array_keys( $results ) ) ] ] ) as $row ) { if ( isset( $results[ $row['r_content_id'] ] ) ) { $results[ $row['r_content_id'] ]->recognized = \IPS\core\Achievements\Recognize::constructFromData( $row ); } } } To solve the issue I had to wrap the whole thing in an IF check for the class: if ( isset(static::$commentClass) ) { //... { IPCommerceFan and LaCollision 2
teraßyte Posted July 11, 2021 Author Posted July 11, 2021 I forgot to post the error I'm getting, here it is: class_uses(): object or string expected This happens because the function isQuestion() doesn't exist and once the code reaches the else part with the \IPS\IPS::classUsesTrait( $this, 'IPS\Content\Solvable' ) check the static::$commentClass variable doesn't exist and NULL is used instead. LaCollision 1
teraßyte Posted August 20, 2021 Author Posted August 20, 2021 It's been more than a month since I posted. Nothing? At least I see this is still not fixed in 4.6.5.1.
Daniel F Posted August 20, 2021 Posted August 20, 2021 I have posted this to our internal bug tracker for further review. teraßyte 1
Aurora17 Posted August 20, 2021 Posted August 20, 2021 54 minutes ago, teraßyte said: It's been more than a month since I posted. Nothing? At least I see this is still not fixed in 4.6.5.1. It is from 25 November 2020 that I sent you a PM to ask for assistance for one of your plugins that you have no longer updated and made compatible for version 4.5. Can you kindly check and reply? I also wrote to you on your site and I no longer know how to contact you except in this way (I also apologize to the Invisioncommunity Staff but I take this opportunity)
teraßyte Posted August 20, 2021 Author Posted August 20, 2021 18 minutes ago, Aurora17 said: It is from 25 November 2020 that I sent you a PM to ask for assistance for one of your plugins that you have no longer updated and made compatible for version 4.5. Can you kindly check and reply? I also wrote to you on your site and I no longer know how to contact you except in this way (I also apologize to the Invisioncommunity Staff but I take this opportunity) Hmm, I never got the PM notification on here but I do see it listed after checking just now. I'll reply there. Aurora17 1
Solution Daniel F Posted August 20, 2021 Solution Posted August 20, 2021 3 hours ago, teraßyte said: It's been more than a month since I posted. Nothing? At least I see this is still not fixed in 4.6.5.1. Stuart fixed this few days ago🤯, meaning it's going to be included in the next regular release:) IPCommerceFan 1
Recommended Posts