Skip to content

Codestar Framework 1.0.3 fatal under WP-CLI (global $uscore_dir empty) #204

@PTaubman

Description

@PTaubman

Hello,

I want to share a reproducible bug in Codestar Framework 1.0.3 (the legacy cs-framework line). Version 1.0.2 is not affected; the regression appears in 1.0.3.

Symptom

Any WP-CLI command that fully bootstraps WordPress fails with a fatal error:

PHP Fatal error: Uncaught Error: Failed opening required '/functions/deprecated.php'
in .../plugins/codestar-framework/cs-framework.php on line 62

The front end (normal web requests) is unaffected. The failure is specific to the WP-CLI execution context.

Root cause

In cs-framework.php, the plugin path is assigned to $uscore_dir at file scope, then read back inside cs_framework_init() via global $uscore_dir. Under a standard web request, WordPress includes the plugin at true global scope, so the global resolves correctly. WP-CLI, however, loads wp-settings.php from inside a method (WP_CLI\Runner->load_wordpress()), so variables assigned at plugin-file scope are not actually global. Inside cs_framework_init(), $uscore_dir comes back empty, and the subsequent require_once $uscore_dir . '/functions/deprecated.php'; resolves to /functions/deprecated.php from the filesystem root, which does not exist, causing the fatal.

Steps to reproduce

Activate Codestar Framework 1.0.3.
From the shell, run any WP-loading command, e.g. wp option get blogname.
Observe the fatal above. (Lightweight commands like wp core version that do not load WordPress are unaffected.)

Environment

Codestar Framework 1.0.3 (cs-framework)
WordPress 7.0
PHP 8.1.34
WP-CLI (current)

Suggested fix

Inside cs_framework_init(), avoid relying on the global $uscore_dir value. Recomputing the path locally, for example $uscore_dir = plugin_dir_path( __FILE__ ); at the top of the function, or referencing a defined constant set with plugin_dir_path( __FILE__ ), makes the include path resilient regardless of the scope in which wp-settings.php is loaded.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions