-
JoomGuy
-
-
Offline
-
Moderator
-
-
Joomla Enthusiast, Lover of Cooking
- Posts: 1115
- Thank you received: 195
-
Karma: 64
-
|
Tomaselli wrote:
if you debug the loader.php file, you'll notice that some classes are not loaded there, even if the code would be written to load those missing classes. At this point, later in the running application, the missing libraries are loaded, so for sure those libraries are not loaded with the file loader.php.
Moreover if you take a look on the classeslist variable (getting it using the JLoader::getClassesList() or CkJLoader::getClassesList(), it's the same) you'll also notice thar there are some classes WRONGLY named but still loaded, this may causes bugs if later we try to load those classes naming them in the correct way in the classes list, because they are not recognized in the classes list so in the best case you'll load twice, if you are not pushed out from the running application by the fatal error: "Cannot redeclare class".
Looking at a helpers/loader.php file you'll see all of your models being registered 'manually' with the register() method and a comment: // Register all Models because of unsolved random JLoader issue.
// Cook offers 3 months subscribtion for the person who solve this issue.
Is it possible that you've made some changes post-cook that have resulted in certain classes not loading? I mean, especially since you've now passed the $force & $recursive args.
Gez
|
Need help with your Cook/Joomla Project? . PM me to find out what I can help with. NO time wasters please!!!
|
-
Tomaselli
-
-
Offline
-
Elite Member
-
- Posts: 293
- Thank you received: 87
-
Karma: 46
-
|
nope, nothing changed about class loading and file inclusion.
|
The following user(s) said Thank You: JoomGuy
|
-
JoomGuy
-
-
Offline
-
Moderator
-
-
Joomla Enthusiast, Lover of Cooking
- Posts: 1115
- Thank you received: 195
-
Karma: 64
-
|
Hmmmmm....
last thing I can think of for the moment is ensuring that the $reset (false) & $prepend (true) are passed into the CkJLoader::registerPrefix() method... Also, I just noticed there isn't a 4th argument documented in the docBlock.
@admin???
|
Need help with your Cook/Joomla Project? . PM me to find out what I can help with. NO time wasters please!!!
Last Edit: 09 Jan 2014 12:05 by JoomGuy.
|
-
admin
-
-
Offline
-
Administrator
-
-
Chef
- Posts: 3711
- Thank you received: 987
-
Karma: 140
-
|
It took me time to read all.
Firstly, if my debugger was working, I could dig in and explose the bug !!!
I am using Aptana on mac OS 10.9. It was not working before neither.
So if somebody can explain me well how to install it, with a good tutorial, it would be wonderfull.
Also I would like to know if the loader is used correctly for the forks :
- Forks files are forced to be loaded at the bottom of the files. A simple registration should be enough.
I does not understand well the whole mechanism. Who wrote this loader ? Can we contact him directly ?
I love this loader, and simply I do not understand to use it correctly, before to say there is a bug in.
I thing Cook is the problem.
Let's see our files :
With the fork system, there are 2 classes to register everytime, so the name convention can be wrong.
Another point is the name convetion using 'Ck' wich is not a folder.
Wanted workflow: (class/model/list given as example)
When cook registers ClassModelList, it will search in
classes/model/list
8< First possible problem : class becomes : 'classes'. So cook need one line to specify it (What it does, but not clean)
Then, in the classes/model/list.php, there is 2 class declarations :
- MycomClassModelList (At the end of the file)
- MycomCkClassModelList (the cook generated source)
8< Is it a problem to have 2 class declaration ? Question to myself.
Another normal issue. Registering 2 times.
It is normal because it forces the registration of Models one by one for workaround.
What to say more ?
I need also to check more accuratly the sources you have furnished. (just read)
|
Coding is now a piece of cake
The following user(s) said Thank You: JoomGuy
|
-
admin
-
-
Offline
-
Administrator
-
-
Chef
- Posts: 3711
- Thank you received: 987
-
Karma: 140
-
|
Ouch !
I have found and I have finished the fix (4 AM). It works !!!
The upgrade tomorrow, because I need to check precisely that all classes load well.
The prize was won by : admin !!
The closest was Tomaselli, because the problem was from discover() function. And you have rewrited there.
But the method you have used is 100% wrong because you are loading all the files in memory.
Should I must remember you that JLoader is here to avoid loading in memory ? !!
And then, on top of that, you parse the PHP... the cherry on the cake.
So the result, if you want your php make a pause for 2 seconds, call the loader !!! lol
A Joomla issue revealed :
When you call discover(), with the recursive flag, it work half.
The files are correctly browsed recursively, but the class namespacing is not working. It always return the first and the last parts. All the relative directory is missing in the class name.
My comment about this JLoader is that I saw a dirty discover function that I had to rewrite. And also a code not that amazing, to stay polite. Very confusing and very long for not that much. Or I miss something maybe ?
The functions there has been rewrited many times (it is my supposition when I see the 'since' functions headers, showing the version)
The registerPrefix is now useless.
If I understand well, with a prefix, it is not anymore necessary to 'register'. the class will be founded on the fly.
It can be better to use the prefixes, but at the end, with all exceptions, it is not possible to load ONLY the component name as prefix.
So the iteration of every single folder is necessary is you use registerPrefix.
Also registerPrefix can be source of bugs and conflicts.
In the way I have chosen, all classes are registered, wich takes in memory the size of an array indexing all files. Small memory, not a problem at all.
I prefer the less optimized but secure way.
In any case, the classes are not loaded until use. This is the point of JLoader.
If you read the new discover function, you will see even few more details (commented code)
Now,
The loader only discover() the component base name, and everything is loaded automatically.
But with exceptions on some folders (_fork, fork, models, views, controllers, legacy). Others folders works perfectly.
Sincerly I cook cannot furnish a unified way, because 'helpers' for instance is plural, and should be singular. (So discover is now also able to remove plurals: classes > class)
views, controllers, Models (+ rules, fields), are also excluded from the automatic loader because it depends the client side (site/admin)
Finally : Cook will provide a complete override super class, whatever the Joomla version and remove the loader.php from 'legacy' folder.
Some defined standard are fixed in discover(), wich was not before. It makes the component much simple now and working.
Anyway, you will never need anymore to load the JLoader, because everything now is namespaced. (except bloody MCV exceptions folders)
I am ver satisfied of the accomplished work. Must check it double if all is working.
To make simple. From the coming upgrade (2.6.3), you will call your class exactly the same way than are your folders, and they will be registered automatically, avoiding loading of the file until it is really used.
I also have created a tiny dumper for debugging easier the JLoader. It will be furnished in the super class.
Hold on.
|
Coding is now a piece of cake
The following user(s) said Thank You: Tomaselli
|
-
JoomGuy
-
-
Offline
-
Moderator
-
-
Joomla Enthusiast, Lover of Cooking
- Posts: 1115
- Thank you received: 195
-
Karma: 64
-
|
admin wrote:
Ouch !
I have found and I have finished the fix (4 AM). It works !!!
The upgrade tomorrow, because I need to check precisely that all classes load well.
The prize was won by : admin !! OMG!!! Well done @admin!
Maybe the loader has changed recently??? I've been using in J!3.2.0 without any issues at all in my custom lib although, the use is slightly different.
Anyway, K++ for you sir!!!
Thanks again for your hard work to fix this!
|
Need help with your Cook/Joomla Project? . PM me to find out what I can help with. NO time wasters please!!!
|
-
Tomaselli
-
-
Offline
-
Elite Member
-
- Posts: 293
- Thank you received: 87
-
Karma: 46
-
|
thanks for fixing that.
@Admin wrote: The closest was Tomaselli, because the problem was from discover() function. And you have rewrited there.
But the method you have used is 100% wrong because you are loading all the files in memory.
Should I must remember you that JLoader is here to avoid loading in memory ? !!
And then, on top of that, you parse the PHP... the cherry on the cake.
So the result, if you want your php make a pause for 2 seconds, call the loader !!! lol.................................A Joomla issue revealed :
When you call discover(), with the recursive flag, it work half.
The files are correctly browsed recursively, but the class namespacing is not working. It always return the first and the last parts. All the relative directory is missing in the class name.
I knew that, that's why I made quick and dirty workaround, and I also knew it is a slow way (surely it's not 2 sec, it's less than a sec if Ckdiscover is used only when really needed), but it was my first thought to quickly fix it and go ahead.
By the way I'm glad you had the time to fix it
|
|
|