Bug: 'mb-conditional-logic' missing 'rwmb' dependency

Support MB Conditional Logic Bug: 'mb-conditional-logic' missing 'rwmb' dependency

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #50106
    Jayron CastroJayron Castro
    Participant

    Hi Meta Box team,

    I am reporting a minor enqueueing bug that is triggering a "_doing_it_wrong" notice in Query Monitor on the backend.

    The Scenario:
    When opening a standard page/post for editing in the backend (e.g., /wp-admin/post.php?post=1022&action=edit), Query Monitor flags a red PHP notice:

    "WP_Scripts::add was called incorrectly. The script with the handle 'mb-conditional-logic' was enqueued with dependencies that are not registered: rwmb."

    Visual Evidence:
    Here are the screenshots from Query Monitor illustrating the exact errors thrown:
    * Error 1 (Message): [https://ibb.co/v66msTsg](https://ibb.co/v66msTsg)
    * Error 2 (Dependencies): [https://ibb.co/dwFfHJBF](https://ibb.co/dwFfHJBF)

    The Technical Cause:
    It seems the Meta Box AIO (Conditional Logic module) is attempting to enqueue the 'mb-conditional-logic' script globally on the edit screen. However, on pages where there are no active meta boxes rendered, the core Meta Box script ('rwmb') is not enqueued/registered.

    Because 'mb-conditional-logic' declares 'rwmb' as a strict dependency, WordPress throws the dependency error. I have pasted the source JS code (conditional-logic.js) here for quick reference: [https://paste.jaded.net/p/trite.glossy.goldfinch.122b17](https://paste.jaded.net/p/trite.glossy.goldfinch.122b17)

    As you can see, the code wraps with '( function( $, rwmb )', which also causes a JS console error if rwmb is undefined.

    Suggested Fix:
    Could you add a conditional check in the PHP enqueue function of the Conditional Logic module to verify if 'rwmb' is actually registered/enqueued before attempting to load the conditional logic script? Something like 'wp_script_is( "rwmb", "registered" )'.

    It doesn't break the frontend, but fixing this will keep our Query Monitor logs clean.

    Best regards,

    Jayron Castro
    CEO, Kstros.com

Viewing 1 post (of 1 total)
  • You must be logged in to reply to this topic.