philsturgeon / codeigniter-template

Template library for CodeIgniter which supports modules, themes, partial views, etc.
411 stars 178 forks source link

Cannot access protected property MY_Loader::$_ci_cached_vars #22

Open carlotrimarchi opened 13 years ago

carlotrimarchi commented 13 years ago

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?

jackperry commented 12 years ago

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

carlotrimarchi commented 12 years ago

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

jackperry commented 12 years ago

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.

carlotrimarchi commented 12 years ago

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

ruthlessfish commented 12 years ago

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']

carlotrimarchi commented 12 years ago

@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);
ruthlessfish commented 12 years ago

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;
}