• Hi,
    I’ve got a problem on a site I manage: I just updated “Broken Link Checker” to the newest version (1.11.13) and encountered a 500 Error on the Site.
    The error states a undefined method is_user_logged_in in the accesspress-anonymous-post plugin. But since this error only occurs when updating Broken Link Checker – so I digged into it.
    is_user_logged_in is a pluggable function which is not available very early and get’s called in a pre_get_posts hook by the accesspress-anonymous-post plugin. Until now this wasn’t a problem because the resynch method of blcPostTypeOverlord used a custom SQL query to get posts, but now it uses get_posts which uses WP_Query and calls all those hooks – appearently before is_user_logged_in is available.

    I’ve opened an issue with their plugin as well – but maybe you could do a check if function_exists or if it’s even the correct query (media query,…) in the restrict_media_library function. Check if the function exists probably is the safest way because it’s a pluggable function and not ensured to be available (see documentation.

    • This topic was modified 4 years, 5 months ago by Fabian Todt.
    • This topic was modified 4 years, 5 months ago by Fabian Todt. Reason: fixed apostrophes
Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi @gaambo

    Thank you for writing in.

    Could you please provide us your site URL so that we can check on this and provide you a better solution.

    Regards!

    Thread Starter Fabian Todt

    (@gaambo)

    Thanks for your reply.
    I can’t – I only tested the update locally before deploying it to the live site. The error log was just a normal fatal error that the function is_user_logged_in called in restrict_media_library is not defined.

    But I think I explained the problem well:
    This plugin calls is_user_logged_in which is (according to documentation) a pluggable function and isn’t ensured to be loaded when you call it too early. Since this plugin calls it directly in a hook (pre_get_posts) and it’s not completely sure when this hook is called (because it get’s called in every WP Query not only in the main query) it should check if the function exists. Because some plugins (like the mentioned Broken Link Checker) make a WP Query before this pluggable function is included. Wheather that is correct behaviour of these plugins (or any other code which does it) to make a query before init is not important imho, because they do it (and I’ve seen it elsewhere as well).
    Therefore a quick fix to be compatible with any plugin which does it and adhere to the documentation I encourage and ask you to wrap the call in a function_exists conditional – or as an alternative check if the current query is even the right query the plugin is after (as I see it’s only meant for media queries).

    Hi @gaambo

    Thank you for writing back.

    We will inform these issues to our developer team and release the update ASAP.

    Please do contact us if you have any questions.

    Regards!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Undefined Function is_user_logged_in’ is closed to new replies.