Jump to content

Featured Replies

Posted

Sending unapproved notifications for moderators without the required causes an undefined array key error:

Whoops\Exception\ErrorException thrown with message "Undefined array key "can_view_hidden_MODPERMKEY_MYITEMTITLE""

Stacktrace:
#9 Whoops\Exception\ErrorException in \system\Content\Content.php:2635
#8 Whoops\Run:handleError in \system\Content\Content.php:2635
#7 IPS\_Content:sendUnapprovedNotification in \system\Content\Item.php:526
#6 IPS\Content\_Item:createFromForm in \system\Content\Item.php:150
#5 IPS\Content\_Item:create in \applications\MYAPP\sources\MYITEM\MYITEM.php:728
#4 IPS\MYAPP\_MYITEM:create in \applications\MYAPP\modules\front\MYMODULE\index.php:93
#3 IPS\MYAPP\modules\front\MYMODULE\_index:new in \system\Dispatcher\Controller.php:107
#2 IPS\Dispatcher\_Controller:execute in \applications\MYAPP\modules\front\MYMODULE\index.php:39
#1 IPS\MYAPP\modules\front\MYMODULE\_index:execute in \system\Dispatcher\Dispatcher.php:153
#0 IPS\_Dispatcher:run in \init.php:940

 

The issue is in the \IPS\Content:sendUnapprovedNotification() function when it checks the individual item permissions (lines 2616-2641):

						try
						{
							$container = ( $this instanceof \IPS\Content\Comment ) ? $this->item()->container() : $this->container();
							$containerClass = \get_class( $container );
							$title = static::$title;
							if
							(
								isset( $containerClass::$modPerm )
								and
								(
									$perms[ $containerClass::$modPerm ] === -1
									or
									(
										\is_array( $perms[ $containerClass::$modPerm ] )
										and
										\in_array( $container->_id, $perms[ $containerClass::$modPerm ] )
									)
								)
								and
								$perms["{$modPermKey}{$title}"]
							)
							{
								$$varKey = TRUE;
							}
						}
						catch ( \BadMethodCallException $e ) { }

 

The IF check uses $perms["{$modPermKey}{$title}"] directly without first doing an isset() check (like it does for $containerClass::$modPerm ).

 

This happened after I added the content item class to my development board and old moderators set up before it are checked and don't have the field/value set.

Edited by teraßyte

Solved by teraßyte

Go to solution

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.

 

  • teraßyte changed the title to [BUG 4.7.17] Checking moderator permissions throws an "Undefined array key" error
  • Author

Oh, whoops, I meant to fill in the title with more details yesterday, but it ended up as only "[BUG 4.7.17]".

 

I've updated it. 😋

46 minutes ago, teraßyte said:

Oh, whoops, I meant to fill in the title with more details yesterday, but it ended up as only "[BUG 4.7.17]".

 

I've updated it. 😋

Well, I guess its still accurate 😄

 

  • 2 weeks later...
  • Author
  • Solution

This is fixed in 4.7.18 Beta 2.

Recently Browsing 0

  • No registered users viewing this page.