wintercms / wn-builder-plugin

GUI for building plugins in Winter CMS
MIT License
34 stars 12 forks source link

Navigation menu exception when resetting menu item order #7

Closed arvislacis closed 3 years ago

arvislacis commented 3 years ago

2021-07-04_11-36

Steps to reproduce:

  1. In Builder under your plugin go to the "Backend Menu" configuration section;
  2. Add new or edit existing main menu and set the Order to valid value, for example, 100;
  3. Reset/clear value specified in step 2 to empty value;
  4. Reload page and the most of back-end is not accessible anymore (view exception image).

Cause of this is that when clearing Order value in step 3 then in plugin.yaml file it's stored as order: '' which then throws exception because of https://github.com/wintercms/winter/blob/develop/modules/backend/classes/NavigationManager.php#L121 - because there is no type conversation to int value.

Possible solutions:

  1. Builder menu editor should not save order: '' back into plugin.yaml when parameter value is empty...
  2. https://github.com/wintercms/winter/blob/develop/modules/backend/classes/NavigationManager.php#L121 and similar lines should use type conversation to int value, for example, return (int) $a->order - (int) $b->order;.
LukeTowers commented 3 years ago

Fixed by https://github.com/wintercms/winter/commit/763db7eb8097fbd2c8ca19cd92935fcd1f5abe5f