helgatheviking / Nav-Menu-Roles

Display / Hide wp_nav_menu() items by role
66 stars 32 forks source link

Walker_Nav_Menu Class name error #23

Closed robertdevore closed 7 years ago

robertdevore commented 7 years ago

When a client of mine updated the plugin to the newest version, the following error was spit out and caused the website to crash.

Fatal error: Class 'Walker_Nav_Menu_Edit' not found in /wp-content/plugins/nav-menu-roles/inc/class.Walker_Nav_Menu_Edit_Roles_4.7.php on line 12

I found the issue and will be issuing a pull request to fix the issue in a second - it looks like _Edit was added to the Class name when it should only be extends Walker_Nav_Menu

helgatheviking commented 7 years ago

Well _Edit was supposed to be added. I slightly tweaked how the custom hook (for the NMR fields) is added so that I don't have to manage translations for the core Walker in my plugin. I'm not yet sure why she'd be getting this error.

robertdevore commented 7 years ago

OK then somewhere else in the plugin is missing the _Edit because when I removed it from the 4.7 file, the plugin worked on the client website and a local install I tested it on.

On Dec 9, 2016 4:00 PM, "Kathy" notifications@github.com wrote:

Well _Edit was supposed to be added. I slightly tweaked how the custom hook (for the NMR fields) is added so that I don't have to manage translations for the core Walker in my plugin. I'm not yet sure why she'd be getting this error.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/helgatheviking/Nav-Menu-Roles/issues/23#issuecomment-266121952, or mute the thread https://github.com/notifications/unsubscribe-auth/AJdWBb_HqqDya3B8hUrSivJ7XPV2Ox0uks5rGcGGgaJpZM4LJVSW .

helgatheviking commented 7 years ago

The wp-admin/nav-menus.php calls :

// Load all the nav menu interface functions
require_once( ABSPATH . 'wp-admin/includes/nav-menu.php' );

which calls:

/** Walker_Nav_Menu_Edit class */
require_once( ABSPATH . 'wp-admin/includes/class-walker-nav-menu-edit.php' );

which is the file that includes the class Walker_Nav_Menu_Edit class. That class extends the Walker_Nav_Menu class, but is importantly different b/c the start_el() method gets all the menu fields.

That file is loading fine for me, so I'm trying to think of other reasons it would give your client trouble. Can you try disabling other plugins and reverting to a default theme temporarily?

robertdevore commented 7 years ago

You were right, it was a plugin conflict. I removed all plugins and added them back one by one, and the following plugin was the one that caused the conflict.

If Menu

Chalk it up to me only getting one hour of sleep last night?

tired

helgatheviking commented 7 years ago

It's still strange that it is giving you a fatal error. I'd prefer my plugin to fail quietly in the case of conflict, but I don't want to go back to the approach where people had to translate strings for my plugin that were already translated for core. I opened an issue with If Menu encouraging they update the Walker for WP 4.7 though I'm not sure that will resolve the issue.

robertdevore commented 7 years ago

I agree with you about the failing quietly, unfortunately we're not always in control of how other plugins cause conflicts. Hopefully the If Menu updates the Walker for WP 4.7 and it fixes the conflict.