EllisLab/CodeIgniter — Issue #805: cascading views doesn't work correctly for added application packages
Author: somomomo
Created: 2011-12-21 05:11:25+00:00
State: open

I wrote a more detailed post on StackOverflow about this (http://stackoverflow.com/questions/7759723/code-igniter-2-0-3-loader-add-package-path-view-cascading) but here's a quick rundown:

When adding an application package, if there is a naming collision in view files, setting the 2nd parameter in add_package_path to FALSE does not load the view file from the original environment and will still load the view file from the added package.

The bug is in the _ci_load function in the core Loader class. It starts at line 764 in the version 2.1.0 file where there's a check for the view file and the cascade value in the foreach loop. Since there's a check if the file exists first, the cascade value is irrelevant in determining whether the view file of the added package should be loaded. Thus, the cascade check does nothing if there is an actual conflict and the view file will always be loaded from the added package.

This bug has existed since at least 2.0.3 and I extended the_ci_load method in order to get around this. What I did was basically switch the order of the check for the view file and the cascade value so the cascade check is done first in the loop. Also, in the cascade check, I changed the break to be a continue. I'm actually thinking it may be better to put the check for cascade inside the beginning of the check for the view file but putting it before the view file check has worked for me.