Jump to content

setting var called 'file' in the view load to a error


Blesta Addons

Recommended Posts

we have a custom plugin, when we set a var called 'file' to the view we get a error, we have tested in so many plugins

$this->set('file', $file_info);

when we change the var from file to any other word like files or file_info the view is rendered successfully . the error we get is

 file_exists() expects parameter 1 to be a valid path, object given on line 157 in /home/xxxxxx/public_html/blesta/vendors/minphp/bridge/src/Lib/View.php 

 

Link to comment
Share on other sites

Correct.  If we look at the minphp Bridge View class we see in the fetch method these lines of code:

        if (is_array($this->vars)) {
            extract($this->vars);
        }

        if (!file_exists($file)) {
            throw new Exception(sprintf('Files does not exist: %s', $file));
        }

In this case $this->vars contains all variables set using $this->set().  When the 'file' variable is extracted it overwrites $file with the value you set.  In this case it sounds like you set an object which is of course not a valid argument for file_exists().  I suppose the bridge could handle it more quietly by adding a flag such as EXTR_SKIP or EXTR_PREFIX_SAME to the call to extract.  In any case, it is not allowed to set a variable named $file to the view.

Link to comment
Share on other sites

  • Tyson locked this topic
Guest
This topic is now closed to further replies.
×
×
  • Create New...