![]() |
Incorrect directory order for loading core classes? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Incorrect directory order for loading core classes? (/showthread.php?tid=38158) Pages:
1
2
|
Incorrect directory order for loading core classes? - El Forum - 01-31-2011 [eluser]crikey[/eluser] Hi, I was replacing the Router.php class by copying it into application/core, but the system/core/Router.php was always being loaded. I had to make a change to the load_class() function in system/core/Common.php to fix it. Common.php, Line 129: Code: foreach (array(BASEPATH, APPPATH) as $path) changed to: Code: foreach (array(APPPATH, BASEPATH) as $path) // swapped directory order Can we get this fix done so that we don't have to rename/delete the files in system/core for them to be replaced? Sorry if this has already been addressed. Thanks, Grant Incorrect directory order for loading core classes? - El Forum - 01-31-2011 [eluser]CMCDragonkai[/eluser] The original line should work, because the APPPATH is meant to replace the BASEPATH. It's accessed by the foreach on the second iteration. Incorrect directory order for loading core classes? - El Forum - 01-31-2011 [eluser]InsiteFX[/eluser] Extend the Router class with a MY_Router and then place it into application/core InsiteFX Incorrect directory order for loading core classes? - El Forum - 01-31-2011 [eluser]crikey[/eluser] @CMCDragonkai: if the file exists it breaks out of the loop, so the second iteration isn't performed. @InsiteFX: I understand that is one way of doing it, but the User Guide doesn't indicate that... it simply says "To use one of your own system classes instead of a default one simply place your version inside your local application/core directory". http://ellislab.com/codeigniter/user-guide/general/core_classes.html Maybe the User Guide needs to be a bit clearer then... although it seems more like the intended behaviour is different to the actual behaviour (i.e. a bug). Incorrect directory order for loading core classes? - El Forum - 02-15-2011 [eluser]HdotNET[/eluser] I'll actually second what @crikey has said. The first iteration definitely takes precedence, meaning that a stock system/libraries/[core-file].php will always be loaded from CodeIgniter.php As it is at present you can't replace, as defined in the user guide, a core file unless you extend using the MY_ method Code: foreach (array(APPPATH, BASEPATH) as $path) ....for line 129 would be the correct order for the user guide to be correct. http://ellislab.com/codeigniter/user-guide/general/core_classes.html Another point to mention is the following, the Log class is mentioned on this page as a core class, naturally as it used by default within the framework. The guide implies that it should be replaced/extended within your application/core/ directory. But the log class lives in the system/libraries folder, thus to override/replace this file you need to place it in your application/libraries folder. But due to the original problem found by @crikey you can't actually replace it, only extend. AFAIK this is the only 'core' file that isn't in the 'core' directory... wonder why? H Incorrect directory order for loading core classes? - El Forum - 04-13-2011 [eluser]YangHax[/eluser] I'll also side with crikey; this is clearly a bug. Incorrect directory order for loading core classes? - El Forum - 04-13-2011 [eluser]InsiteFX[/eluser] It's very simple! If the Class Library you are extending is in system/core then your new Class Library goes into application/core If the Class Library you are extending is in system/libraries then your Class Library goes into application/libraries InsiteFX Incorrect directory order for loading core classes? - El Forum - 04-13-2011 [eluser]YangHax[/eluser] We're not extending it, we're replacing it. Incorrect directory order for loading core classes? - El Forum - 04-13-2011 [eluser]wh1tel1te[/eluser] It's not a bug. CI by default does not allow you to literally replace any core libraries. Your "fix" is an adjustment to allow yourself to replace them, which was never intended to be allowed. Doing it by the docs, you would still extend the core libraries, but replace the methods with your own. If you think that being able to do a literal replace of the core libraries by placing them in your app's core directory should be a default feature, you may wish to request it via the appropriate channels (uservoice I think?). Incorrect directory order for loading core classes? - El Forum - 04-13-2011 [eluser]InsiteFX[/eluser] Well, good luck! When you install a new version of CodeIgniter! InsiteFX |