TDBF Posted February 23 Share Posted February 23 Found a small bug which only seems to show when I have Whoops enabled. This happened when viewing a member's profile in the ACP and an applications Notification configurationOptions function does NOT explicitly set a return. Such as: public static function configurationOptions( \IPS\Member $member = NULL ) { if ( $member === NULL or $member->modPermission( 'can_view_hidden_content' ) ) { return [ 'my_notification' => [ 'type' => 'standard', 'notificationTypes' => ['my_notifiction'], 'title' => 'notifications__my_notification', 'showTitle' => FALSE, 'description' => 'notifications__my_notification_desc', 'default' => ['inline'], 'disabled' => ['email', 'push'] ] ]; } } teraßyte 1 Link to comment Share on other sites More sharing options...
teraßyte Posted February 23 Share Posted February 23 What application is that code from? It's not from the default IPS code at least. The problem is that the return array() code is inside the IF check, if the check fails nothing is returned. Adding a simple return at the end of the function is enough: public static function configurationOptions( \IPS\Member $member = NULL ) { if ( $member === NULL or $member->modPermission( 'can_view_hidden_content' ) ) { return [ 'my_notification' => [ 'type' => 'standard', 'notificationTypes' => ['my_notifiction'], 'title' => 'notifications__my_notification', 'showTitle' => FALSE, 'description' => 'notifications__my_notification_desc', 'default' => ['inline'], 'disabled' => ['email', 'push'] ] ]; } return array(); } Link to comment Share on other sites More sharing options...
TDBF Posted February 23 Author Share Posted February 23 1 hour ago, teraßyte said: What application is that code from? It's not from the default IPS code at least. The problem is that the return array() code is inside the IF check, if the check fails nothing is returned. Adding a simple return at the end of the function is enough: public static function configurationOptions( \IPS\Member $member = NULL ) { if ( $member === NULL or $member->modPermission( 'can_view_hidden_content' ) ) { return [ 'my_notification' => [ 'type' => 'standard', 'notificationTypes' => ['my_notifiction'], 'title' => 'notifications__my_notification', 'showTitle' => FALSE, 'description' => 'notifications__my_notification_desc', 'default' => ['inline'], 'disabled' => ['email', 'push'] ] ]; } return array(); } It's just an example which will trigger the Warning in Whoops. 🙂 Link to comment Share on other sites More sharing options...
Solution Daniel F Posted February 23 Solution Share Posted February 23 The method should return an array (mentioned by phpdoc) Unfortunately, there were no return types when IPS 4 was created, but they're now, so I guess the best thing to do here is to enforce it Seems much more straightforward than including just another IMO unnecesary check for the methods return value. SeNioR- and TDBF 2 Link to comment Share on other sites More sharing options...
TDBF Posted February 23 Author Share Posted February 23 18 minutes ago, Daniel F said: The method should return an array (mentioned by phpdoc) Unfortunately, there were no return types when IPS 4 was created, but they're now, so I guess the best thing to do here is to enforce it Seems much more straightforward than including just another IMO unnecesary check for the methods return value. Developers don't always do what is in the manual. 🤪 SeNioR- and Daniel F 2 Link to comment Share on other sites More sharing options...
Recommended Posts