Blesta Addons Posted September 14, 2017 Report Share Posted September 14, 2017 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 activa 1 Link to comment Share on other sites More sharing options...
Jono Posted September 14, 2017 Report Share Posted September 14, 2017 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. activa 1 Link to comment Share on other sites More sharing options...
Recommended Posts