Support » Plugin: WPAdverts - Classifieds Plugin » Fatal error making WP-CLI unusable

  • Resolved Luis Martins

    (@lmartins)


    Hi,

    Just wanted to let you know that when enabled, the plugin trigger a fatal error making it impossible to use WP-CLI:

    PHP Fatal error: Incorrect module name [config] in /Users/luismartins/Sites/sitename/wp-content/plugins/wpadverts/includes/functions.php on line 32

    Thanks.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Greg Winiarski

    (@gwin)

    Hi, I got your email regarding this issue as well, i will reply here so anyone else having a similar issue maybe will find it useful.

    Either way, I am not that familiar with WP CLI, but it seems that it is ignoring global variables set in wpadverts.php, specifically in this case variable $adverts_namespace is being ignored it should have a “config” key it is explicitly set in wpadverts/wpadverts.php file.

    When i will find some free time i will install WP CLI and check this on my own, in the meantime, you would need to contact WP CLI support, maybe they can shed some light on this, knowing how WPAdverts is using global variables.

    Hi Greg, thanks for your feedback.
    A bit surprising you haven’t tried WP CLI, you really should give it a go. Globals are always problematic, but I’ll check with them too to see if there’s something that can be done here. They will probably say this should avoid globals. Lets see.

    Plugin Author Greg Winiarski

    (@gwin)

    Hi, i will look into both the global variable and WP CLI :), although removing the global variable might be difficult as the addons are using it as well.

    @gwin If you explicitly globalize the global (e.g. global $adverts_namespace), the issue will be fixed.

    WP-CLI loads WordPress inside of a function, which means any implicitly global variables are no longer global.

    Plugin Author Greg Winiarski

    (@gwin)

    Thanks for feedback, if i understand correctly i need to change in wpadverts/wpadverts.php file lines

    
    // define global $adverts_config variable
    $adverts_config = null;
    
    // define global $adverts_namespace variable
    $adverts_namespace = array( 'config' => array(
    

    to

    
    // define global $adverts_config variable
    global $adverts_config = null;
    
    // define global $adverts_namespace variable
    global $adverts_namespace = array( 'config' => array(
    

    If that’s the case i will make such update in next WPAdverts release.

    Plugin Author Greg Winiarski

    (@gwin)

    or rather

    
    // define global $adverts_config variable
    global $adverts_config;
    $adverts_config = null;
    
    // define global $adverts_namespace variable
    global $adverts_namespace;
    $adverts_namespace = array( 'config' => array(
    
Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Fatal error making WP-CLI unusable’ is closed to new replies.