Global variable issue when running with WP-CLI
-
I’m having difficulty using the plugin from WP-CLI. It seems as if some of the global variables which Custom Logging Service uses — for example, $severity_list and $clgs_last_log in custom_logging_service.php, are not global and so remain unset, causing problems later on when they’re used.
I’m confused by this because they’re defined in the top level of the file, so I would assume they *must* be globals because of PHP’s variable scope; but I wonder if WP-CLI is doing some kind of strange voodoo that prevents them from actually being global, despite being on the top-level.
$cgls_db is already explicitly marked global and there are no problems with that variable.
Marking those variables global seems to fix my problem. I’m not sure if there are other potential bugs lurking due to the lack of an explicit global declaration.
- The topic ‘Global variable issue when running with WP-CLI’ is closed to new replies.