Invision Community 4: SEO, prepare for v5 and dormant account notifications By Matt Monday at 02:04 PM
Gabriel Torres Posted November 13, 2022 Posted November 13, 2022 (edited) @Adriano Faria I've read the other topic from @CodingJungle where you guys were discussing the infamous parent error with PHP8: Quote PHP Fatal error: Cannot use "parent" when current class scope has no parent in /system/Theme/Theme.php(2703) : eval()'d code on line 137 Our install has several custom-made apps and plugins, and the developer @newbie LAC is MIA since the beginning of the Covid pandemic (and I fear for the worst, as I tried, unsuccessfully, contacting him via email a few times). Since we want to preserve all these plugins, I have to fix all of these errors myself before moving to PHP8 in production, which is quite annoying. I will post below the issue I am having with one specific plugin, so maybe you guys can help me out fixing the issue and, hopefuly, once I understand how to fix this, I will be able to replicate the fix to all other plugins that are throwing the same error. As seen in the log above, the error is thrown in line 137, which reads as: $whosOnline = parent::whosOnline($members, $memberCount, $guests, $anonymous, $orientation); I've tried to surround this statement with what you suggested in the other topic, at no avail: if( \is_callable( 'parent::whosOnline' ) ) { $whosOnline = parent::whosOnline($members, $memberCount, $guests, $anonymous, $orientation); return $whosOnline; } If you could help me out it would be super. I am attaching the hook file to this post for your evaluation. Thanks. nbBotsInOnlineListTplWhosOnline.php Edited November 13, 2022 by Gabriel Torres Adriano Faria and SeNioR- 2
Solution teraßyte Posted November 13, 2022 Solution Posted November 13, 2022 Try replacing the parent call (line 134) with this code instead: # Get parent output (PHP 8 fix) $whosOnline = ''; if( \is_callable( 'parent::' . __FUNCTION__ ) ) { $whosOnline = \call_user_func_array( 'parent::' . __FUNCTION__, \func_get_args() ); } Martin A., Gabriel Torres, SeNioR- and 1 other 3 1
Gabriel Torres Posted November 13, 2022 Author Posted November 13, 2022 Thanks, @teraßyte! It worked here. I will try to replicate the same logic to other plugins and will ask for help again if I face issues solving the issue with other plugins.
Recommended Posts