teraßyte Posted January 27, 2023 Posted January 27, 2023 (edited) Starting the process to rebuild achievements from ACP throws an error rebuilding a gallery album as promoted content. The issue specifically happens in the file /applications/core/extensions/core/AchievementAction/ContentPromotion.php inside the function rebuildRow() on lines 249-255: case 'core_social_promote': $promote = \IPS\core\Promote::load( $row['promote_id'] ); $promote->object()->author()->achievementAction( 'core', 'ContentPromotion', [ 'content' => $promote->object(), 'promotype' => 'promote' ] ); break; The problem in the code above is that when it hits a gallery album entry, which is a node, it tries to call \IPS\gallery\Album::author() which exists only in content items. The correct code for an album would be \IPS\gallery\Album::owner() instead. This is the error's backtrace: Error: Call to undefined method IPS\gallery\Album::author() (0) #0 /home/admin/web/domain.com/public_html/forum/applications/core/extensions/core/Queue/RebuildAchievements.php(141): IPS\core\extensions\core\AchievementAction\_ContentPromotion::rebuildRow(Array, Array) #1 /home/admin/web/domain.com/public_html/forum/system/Task/Task.php(47): IPS\core\extensions\core\Queue\_RebuildAchievements->run(Array, 103) #2 /home/admin/web/domain.com/public_html/forum/applications/core/tasks/queue.php(43): IPS\_Task::runQueue() #3 /home/admin/web/domain.com/public_html/forum/system/Task/Task.php(375): IPS\core\tasks\_queue->IPS\core\tasks\{closure}() #4 /home/admin/web/domain.com/public_html/forum/applications/core/tasks/queue.php(55): IPS\_Task->runUntilTimeout(Object(Closure)) #5 /home/admin/web/domain.com/public_html/forum/system/Task/Task.php(274): IPS\core\tasks\_queue->execute() #6 /home/admin/web/domain.com/public_html/forum/applications/core/modules/admin/settings/advanced.php(751): IPS\_Task->run() #7 /home/admin/web/domain.com/public_html/forum/system/Dispatcher/Controller.php(107): IPS\core\modules\admin\settings\_advanced->runTask() #8 /home/admin/web/domain.com/public_html/forum/applications/core/modules/admin/settings/advanced.php(38): IPS\Dispatcher\_Controller->execute() #9 /home/admin/web/domain.com/public_html/forum/system/Dispatcher/Dispatcher.php(153): IPS\core\modules\admin\settings\_advanced->execute() #10 /home/admin/web/domain.com/public_html/forum/admin/index.php(13): IPS\_Dispatcher->run() #11 {main} As a temporary measure, I've replaced the code above with this one: case 'core_social_promote': $promote = \IPS\core\Promote::load( $row['promote_id'] ); if ( $promote->object() instanceof \IPS\Gallery\Album ) { $promote->object()->owner()->achievementAction( 'core', 'ContentPromotion', [ 'content' => $promote->object(), 'promotype' => 'promote' ] ); } else { $promote->object()->author()->achievementAction( 'core', 'ContentPromotion', [ 'content' => $promote->object(), 'promotype' => 'promote' ] ); } break; Not the best fix though, so you'll probably want to implement something different. 😋 === EDIT: Forgot to mention that the bug is still present in 4.7.7 Beta 3. Edited January 27, 2023 by teraßyte Afrodude, Pescao6 and SJ77 3
Marc Posted January 27, 2023 Posted January 27, 2023 Thank you for bringing this issue to our attention! I can confirm this should be further reviewed and I have logged an internal bug report for our development team to investigate and address as necessary, in a future maintenance release. SJ77 1
Daniel F Posted January 27, 2023 Posted January 27, 2023 How was the album promoted? Promoting an album will promote it as \IPS\Gallery\Album\Item and not as \IPS\Gallery\Album SeNioR- 1
Solution teraßyte Posted January 27, 2023 Author Solution Posted January 27, 2023 (edited) 1 hour ago, Daniel F said: How was the album promoted? Promoting an album will promote it as \IPS\Gallery\Album\Item and not as \IPS\Gallery\Album @Daniel F No idea honestly. I'm just helping someone upgrade their site from 4.4. There are 5 such items in the table. And after you mentioned it I looked also for \IPS\gallery\Album\Item and there is 1 such record. Looking at the database there are 5 albums like that, all promoted in the second half of 2017. And based on the upgrade history table, the suite was on version 4.2.3. An old bug maybe? I guess the proper fix here then would be to update any \IPS\gallery\Album in the promote_class column to \IPS\gallery\Album\Item instead. Edited January 27, 2023 by teraßyte Daniel F 1
Daniel F Posted January 27, 2023 Posted January 27, 2023 @Ryan Ashbrookrockstar found it ( there’s a broken link on mobile view sending the album instead of Album\Item) while reviewing my fix. SeNioR- 1
Marc Posted January 28, 2023 Posted January 28, 2023 22 hours ago, Daniel F said: @Ryan Ashbrookrockstar found it He does that 😄 SJ77 1
teraßyte Posted February 12, 2023 Author Posted February 12, 2023 @Daniel F I guess the fix is in 4.7.8? I'm not seeing it in 4.7.7.
Marc Posted March 10, 2023 Posted March 10, 2023 Just a quick update to let you know that this issue was resolved in the recent 4.7.8 release of our platform. Please upgrade your site to resolve this issue. If you are still seeing any issues after upgrading to this version, please let us know.
teraßyte Posted March 12, 2023 Author Posted March 12, 2023 (edited) @Daniel F This is indeed (partially) fixed in 4.7.8, but you only fixed the template passing the wrong class. There's no query included to update broken items already in the database, and the rebuild process will still throw an error on 4.7.8. EDIT: Nevermind. I see you made a code change similar to the one I posted in the first post to handle broken items. I guess that works too. Edited March 12, 2023 by teraßyte
Recommended Posts