Support » Plugin: If Menu - Visibility control for Menu Items » PHP Warning – From update or an error on my side?

  • Not sure if this is from a recent update or an error on my side that I’m only noticing now. My cron jobs are showing the following warning:
    PHP Warning: call_user_func_array() expects parameter 1 to be a valid callback, class '\Layered\IfMenu\Admin' not found in /.../wp-includes/class-wp-hook.php on line 286

    The menu I use it with seems to work fine (logged in or out)
    I’m running Version 0.9 on WP 4.9.5

    Cheers.

Viewing 11 replies - 1 through 11 (of 11 total)
  • I also am seeing this in my window since I have debug turned on..

    This just started happening with the latest update to IF MENU.
    Norm

    Plugin Author Andrei

    (@andreiigna)

    Hi

    Thanks for letting me know about this.

    Looks like the admin page WP Admin -> Appearance -> If Menu was not loaded properly. What is the PHP version where this happened? This info will help for faster debugging

    Cheers

    Thread Starter KicknGuitar

    (@kicknguitar)

    My warning was on PHP 5.6.35

    If O knew more I’d help. Have fun debugging. :p

    Started for us yesterday (2018-04-21) afternoon, PHP 5.6. Every five minutes, it has filled up my inbox with warnings. We have a five minute scheduler running, which is generating this warning.

    PHP Warning: call_user_func_array() expects parameter 1 to be a valid callback, class '\Layered\IfMenu\Admin' not found in .../httpdocs/wp-includes/class-wp-hook.php on line 286

    We don’t see it on the from end, because error display and debug are turned off, and WP has literally no error log to send these things to. And the fact that front-end plugins like this are loaded during off-line scheduled events is just another crappy thing about WP, but we put up with it.

    • This reply was modified 3 years, 7 months ago by Jason Judge.
    • This reply was modified 3 years, 7 months ago by Jason Judge.
    Plugin Author Andrei

    (@andreiigna)

    Hi,

    Would you be able to test the latest update before publishing to WordPress.org?
    https://drive.google.com/open?id=15V8fphKjHf-sdixFfojIK1Y-7ykEtbXG

    If it helps, the modified file is if-menu/if-menu.php.

    Was tested on a few sites with PHP 5.6 and looks fine, and a double-check before going live is always helpful

    Cheers

    Thread Starter KicknGuitar

    (@kicknguitar)

    I just swapped the file about an hour ago but I still get the PHP Warnings via my cron jobs. I’m on PHP 5.6.35

    Inserting this line in if-menu.php, line 335 fixes it:

    include 'src/Admin.php';

    Thread Starter KicknGuitar

    (@kicknguitar)

    @andreiigna, Any word on this fix?

    Plugin Author Andrei

    (@andreiigna)

    The issue may be related to this https://stackoverflow.com/questions/14696961/why-doesnt-phps-autoload-feature-work-in-cli-mode

    In the latest versions, the plugin uses Composer to autoload files and some are not included in some PHP / CLI configs. Is the cronjob set to call a URL or the php files directly?

    @andreiigna I was also experiencing this issue.

    It was happening as PHP was never including your plugin’s vendor/autoload file, as it was including the one in my web root instead.

    I use the composer/installers package to manage some of my WP sites.

    Fix: in if-menu.php:
    require plugin_dir_path(__FILE__) . 'vendor/autoload.php';

    I imagine @kicknguitar was having this issue as well – as the replaced line above was originally an include statement, it failed silently on most setups.

    Plugin Author Andrei

    (@andreiigna)

    Hi TwentyZeroTwo,

    Thank you for the info. I’ve tested this and seems to work fine, the plugin is updated to include the more specific path

    Cheers

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘PHP Warning – From update or an error on my side?’ is closed to new replies.