Jump to content

Bug with PHP 8.1 and reporting when restricted moderator with full forum access


Go to solution Solved by TSP,

Recommended Posts

Posted

I see the following error a lot in our system logs after updating from PHP 7.4 to 8.1:

TypeError: in_array(): Argument #2 ($haystack) must be of type array, int given (0)
#0 /*/system/Content/Content.php(1714): in_array(300, -1)
#1 /*/system/Content/Controller.php(3001): IPS\_Content->report('', '2')
#2 /*/system/Content/Controller.php(2271): IPS\Content\_Controller->_report('IPS\\forums\\Topi...', Object(IPS\forums\Topic\Post), Object(IPS\forums\Topic))
#3 /*/applications/forums/modules/front/forums/topic.php(1240): IPS\Content\_Controller->__call('_report', Array)
#4 /*/system/Dispatcher/Controller.php(107): IPS\forums\modules\front\forums\_topic->__call('reportComment', Array)
#5 /*/system/Content/Controller.php(50): IPS\Dispatcher\_Controller->execute()
#6 /*/applications/forums/modules/front/forums/topic.php(39): IPS\Content\_Controller->execute()
#7 /*/system/Dispatcher/Dispatcher.php(153): IPS\forums\modules\front\forums\_topic->execute()
#8 /*/index.php(13): IPS\_Dispatcher->run()
#9 {main} 

This TypeError doesn't prevent the report from being submitted, but it causes a redirect in the browser (because of an ajax call not receiving the expected reply) to the report page for the content, where the user will be told they've already reported it.

Could contain: Page, Text

 

In Content.php at or around line 1714:

<?php
if ( ! in_array( $item->mapped('container'), $perms[ $container::$modPerm ] ) )

As seen in the error pasted above, the first parameter was 300 (referring to the forum id), while the second parameter supplied is -1. 

The value of $container::$modPerm is "forums", and the value of $perms['forums'] is just -1. This is because, while the moderator or moderator groups is restricted, they are unrestricted in which forums they are able to operate, and then you save it as -1 to the forums-key in the json value for the perms-column in ibf_core_moderators. 

Could contain: Page, Text

 

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...