2

I am getting this in my logs:

ERROR - 2015-02-02 18:36:08 --> Severity: Warning  --> Creating default object from empty value /home/admin/web/mysite.com/public_html/OpenVBX/libraries/Plugin.php 61

Plugin.php line 61 is:

$this->config->disabled = isset($this->config->disabled)? $this->config->disabled : false;

Surrounding line 61 is:

    if(is_file($this->plugin_path . '/plugin.json'))
    {
        $config_contents = file_get_contents($this->plugin_path . '/plugin.json');
        if(!empty($config_contents))
        {
            $this->config = json_decode($config_contents);
        }

        /* Optional arguments should be checked and declared here */
        $this->config->disabled = isset($this->config->disabled)? $this->config->disabled : false;
        $this->config->name = isset($this->config->name)? $this->config->name : 'Unknown';
        $this->config->author = isset($this->config->author)? $this->config->author : 'Unknown';
        $this->config->description = isset($this->config->description)? $this->config->description : '';
        $this->config->url = isset($this->config->url)? $this->config->url : '';
        $this->config->version = isset($this->config->version)? $this->config->version : '';
    }

Any ideas on how to fix this? instead of just turning off/lowersing error reporting?

Thanks!

AMQ
  • 21
  • 2
  • 1
    `var_dump( $this->config );` on the line before, see what's in it. – Alexander O'Mara Feb 03 '15 at 00:57
  • 2
    It looks like `$this->config` only gets initialized in that `if()` condition from `json_decode()`. You will probably need something like `else { $this->config = new stdClass(); }` there. – Michael Berkowski Feb 03 '15 at 00:58
  • See also http://stackoverflow.com/a/8900730/541091 – Michael Berkowski Feb 03 '15 at 00:59
  • $this->config is probably null... – Whirlwind Feb 03 '15 at 00:59
  • I have tried @MichaelBerkowski solution, same error. Script in question is: https://github.com/twilio/OpenVBX/blob/master/OpenVBX/libraries/Plugin.php#L61 – AMQ Feb 04 '15 at 02:11
  • @AMQ You have it initializing to `stdClass()` [at line 71](https://github.com/twilio/OpenVBX/blob/master/OpenVBX/libraries/Plugin.php#L71), but it also needs to initialize in an `else` block [at line 60, after the `if()`](https://github.com/twilio/OpenVBX/blob/master/OpenVBX/libraries/Plugin.php#L60) so that it is an object in at line 61 no matter what occurred before. – Michael Berkowski Feb 04 '15 at 02:21

0 Answers0