getgrav / grav-plugin-admin

Grav Admin Plugin
http://getgrav.org
MIT License
355 stars 222 forks source link

grav.CRITICAL: Syntax error with Page Security tab - Page Groups #2409

Open Quitoboss opened 2 months ago

Quitoboss commented 2 months ago

I detected the following bug: There is in Security tab of page configuration. If you configure the "Page Groups" with no value or with a group but don't select any specific CRUD permisión when saving it brokes giving the next message:

Server Error Sorry, something went terribly wrong! 4 - Syntax error For further details please review your logs/ folder, or enable displaying of errors in your system configuration.

Then in grav.log yo will see: grav.CRITICAL: Syntax error - Trace: #0 /var/www/vhosts/[...]/user/plugins/flex-objects/classes/Admin/AdminController.php(1861): json_decode('', true, 512, 4194304) #1

And 30 lines more. 8 about AdminController 4 about EventDispatcher 4 about Themes 10 about RequestHandler etc.

This was found trying to figure out how can I configure a private page for users (With Grav Login Plugin)

Best regards

pmoreno-rodriguez commented 2 months ago

I confirm this error. Some validation may be missing to prevent the responsible function from passing empty or null data.

(user/plugins/flex-objects/classes/Admin/AdminController.php1861) I have not tried it. The following maybe works:

protected function jsonDecode(array $data)
     {
         foreach ($data as &$value) {
             if (!empty($value)) {
                 if (is_array($value)) {
                    $value = $this->jsonDecode($value);
                 } else {
                   $value = json_decode($value, true, 512, JSON_THROW_ON_ERROR);
                 }
             }
         }

         return $data;
     }