• Resolved cjhaas

    (@chrisvendiadvertisingcom)


    In the Wow_Plugin class, in the _includes method, there’s three includes:

    if ( ! class_exists( 'Wow_Company' ) ) {
        include_once 'includes/class-wow-company.php';
    }
    include_once 'admin/class-admin.php';
    include_once 'public/class-public.php';

    Unless the include uses path semantics such as ./, .// or / (depending on OS), PHP actually searches the local directory last, which is probably not what you mean.

    We’ve run into an issue with your plugin because our theme happens to have a file at exactly admin/class-admin.php, same as you, and when we run any WP CLI commands while we are cd’d into our theme, your plugin is including our file.

    As noted, this is an edge case but is pretty easy to fix by just adding __DIR__, same as you are already doing at the bottom of the file.

    We made a very minimal theme to repro this which is available here: https://github.com/vendi-advertising/vendi-minimum-theme

    1. Take a brand new WordPress site
    2. Install and activate the modal-window plugin
    3. Install and activate the theme (don’t bother browsing to it in a browser)
    4. cd into the vendi-minimum-theme directory
    5. Try running a WP CLI command such as wp cache flush, and you should see a die message along with a stack trace showing who is requesting for it to be included.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Contributor DmtLo

    (@lobov)

    Hello.

    Thanks for your feedback. I fixed this issue and updated the plugin to version 5.3.8

    Thanks again

    Thread Starter cjhaas

    (@chrisvendiadvertisingcom)

    Thanks for your very quick response and resolution!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Edge-case bug with require/include and WP-CLI’ is closed to new replies.