• Have a site triggering tens of thousands of fatals for the following:

    PHP Fatal error:  Uncaught Error: Call to undefined function add_filter() in /srv/htdocs/wp-content/plugins/barcode-scanner-lite-pos-to-manage-products-inventory-and-orders/request.php:106
    Stack trace:
    #0 {main}
    thrown in /srv/htdocs/wp-content/plugins/barcode-scanner-lite-pos-to-manage-products-inventory-and-orders/request.php on line 106

    POST requests are being sent to request.php. It appears WordPress is not fully loaded as the following require statement is after add_filter:

    add_filter("option_active_plugins", "usbs_plugin_filter", 1, 1);
    add_filter("site_option_active_plugins", "usbs_plugin_filter", 1, 1);
    add_filter("active_plugins", "usbs_plugin_filter", 1, 1);

    require($root . "/wp-load.php")

    Can you fix the plugin to ensure core functions are available before calling them?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hello,

    Strange as request.php is loading wp and woo before calling any functions, I assume it may be due to some conflict with third-party plugin or theme.

    Please contact me directly here: https://www.ukrsolution.com/ContactUs

    And I will provide you with the latest plugin version which is not published yet.

    Thread Starter Imagemtg169

    (@mtg169)

    Still fatals on latest version. I suspect the user is making POST requests directly to request.php. Moving require($root . "/wp-load.php") before the add_filter calls resolved the issue, however, the site start throwing fatals again with the latest update that includes it after.

    We can’t reproduce this problem on our test servers, that is why I assume that it is related to some conflict or customization.

    As one of the solution, try to disable the “Enable direct DB mode” option in plugin’s settings->Search tab. This way request will be re-routed and it may solve the problem.

    Thread Starter Imagemtg169

    (@mtg169)

    It’s a user’s site on our hosting so I’m unsure how they are using the plugin exactly, but there are no customizations to it.

    I can reproduce on a test site just accessing request.php directly. It returns: /wp-includes/plugin.php is not fond! and the same error is logged because it’s calling add_filter before wp-load.php is included.

    Typically wp-load.php would be included at the beginning of a file before any core functions are called. I’ve temporarily patched it this way previously, but it will obviously break every time the plugin is updated until fixed in the .org repo.

    I can’t explain why it is not working in your case (maybe some hosting configuration).

    The thing is that add_filter() function described in the plugins.php file (which is loaded earlier), not in wp-load.php. However, I agree that it is better to load wp-load.php before add_filter (just in case).

    In a new version 1.10.1 we will fix that, so new update won’t break your plugin again.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Call to undefined function add_filter’ is closed to new replies.