codeigniter-template icon indicating copy to clipboard operation
codeigniter-template copied to clipboard

Cannot access protected property MY_Loader::$_ci_cached_vars

Open carlotrimarchi opened this issue 14 years ago • 7 comments

Hi, when I try to run the dwoo_test I get this error:

PHP Fatal error: Cannot access protected property MY_Loader::$_ci_cached_vars in /home/carlo/public_html/website/application/libraries/MY_Parser.php on line 146

I'm using the last CodeIgniter version downloaded from github.

Any ideas?

carlotrimarchi avatar Oct 28 '11 16:10 carlotrimarchi

This is caused because CodeIgniter changed $_ci_cached_vars to a protected variable. Hopefully this can get fixed on either end.

jackperry avatar Nov 01 '11 15:11 jackperry

so, there's nothing I can do right now?

carlotrimarchi avatar Nov 02 '11 15:11 carlotrimarchi

You can comment out line 146 in MY_Parser.php, but I wouldn't recommend it, I don't know if it breaks anything anywhere else.

jackperry avatar Nov 02 '11 15:11 jackperry

I'd prefer waiting for an official fix. Do you know if they are still developing this project?

carlotrimarchi avatar Nov 15 '11 14:11 carlotrimarchi

this library doesn't come with a MY_Parser class so I'm guessing that is your code that is breaking. $_ci_cached_vars is protected but you can now use $this->load->get_var('foo') instead of $this->load->_ci_cached_vars['foo']

ruthlessfish avatar Nov 15 '11 15:11 ruthlessfish

@bubbafoley: the My_Parser is a Dwoo Parser Class. I'm using it since it's explained so in the documentation:

NOTE: You can only use the Parser if you have also installed a Parser extensions like codeigniter-dwoo. This is because CI_Parser does not play nicely with arrays.

anyway, the line throwing the error is this:

$data = array_merge($data, $this->_ci->load->_ci_cached_vars);

carlotrimarchi avatar Nov 16 '11 18:11 carlotrimarchi

Ah, I see now. That's a bug in the codeigniter-dwoo library so you might be better off moving this issue over there https://github.com/philsturgeon/codeigniter-dwoo.

What I would do, though, is create application/core/MY_Loader.php and redeclare _ci_cached_vars as public

<?php

class MY_Loader extends CI_Loader {
    public $_ci_cached_vars;
}

ruthlessfish avatar Nov 16 '11 18:11 ruthlessfish