I've been working on a platform application and I've run into a bunch of issues with the autoloader and am not quite sure what to do. This is a JWeb application and right off the top I get
Fatal error: Class 'JObject' not found in /home/owner/www/ebay/joomla-platform/libraries/joomla/filter/input.php on line 23This is fixable by renaming the JObject class to JBaseObject but then of course we have the same issue withFatal error: Class 'JObject' not found in /home/owner/www/ebay/joomla-platform/libraries/joomla/environment/uri.php on line 24Again, this is fixable by changing the reference to JBaseObject ... but then we come to w
Fatal error: Class 'JFactory' not found in /home/owner/www/ebay/joomla-platform/libraries/joomla/content/factory.php on line 22The problem is hereThe way it is written since Factory has only one part we go looking or JFactoryFactory but it doesn't exist so we don't find find anything hence the fatal error.
So, I'm happy to write something for the Factory special case but I don't know if there are some plans in mind already for it.But for the other issues I don't want to willy nilly start renaming classes since all that is going to do is to disguise the failures by changing the inputs. In other words, I think we need to start with writing the failing tests and then change the code so the tests pass. So right off the top of my head I would say it shouldn't be a fatal error if the autoloader doesn't find something using the naming conventions but instead there should probably be a fall back to something else like checking whether something has been loaded in another way.
Maybe you could post a short hello world examples that displays the behavior you're seeing? That would be helpful.
Rouven
Rouven
joomla-platform/libraries/joomla/application/web/web/client.php' (length=84)
but if you say
$this->client = new JApplicationWebWebclient;
it will look for
joomla-platform/libraries/joomla/application/web/webclient.php' (length=83)Or joomla/web/client verus joomla/webclient/webclientif you are using old style.Even though the camel case names make them more readable I wonder if we should be using them since IDEs probably won't be ableto handle correctly.Elin
> Well it's in fact not weird. The issues are when you create instances of other classes that don't use the autoloader from within a class that does and then those classes extend other classes that don't. jImport works okay for the first step (it will go attempt to create JURI or JLanguage, finding the file just fine) but then when it looks at what those classes extend it does not know not to run again because no instance of JObject exists at that point, which is the check that it does (see link in my original post). As I pointed out in my original post there is right now no way for the loader to know not to run when it is multiple steps away from the class where the Loader started. Hence it looks for things like JBaseObject or JFactoryFactory even though the appropriate files have been imported by jimport. Loader has no way to know that JObject shouldn't be expected to follow the rules it enforces. However if you do JLoader::Register you are just fine since it registers everything.
Both JFactory and JObject are indeed registered in the import.php file. I'd be really good if you could post an example that shows the error so other can do some testing.
> Remember that the CMS does not use the current platform and mainly relies on older classes and hence this issue would not come up. Well we do know that there was a problem with JRules versus JAccessRules references that also were expecting the autoloader and hence broken. https://groups.google.com/d/topic/joomla-dev-platform/wcZ0aKlBJAo/discussion and just using jimport would not solve. And in fact Andrew after first suggesting using jimport realized this and pointed out the need to use Jloader::Register
> https://groups.google.com/d/msg/joomla-dev-platform/wcZ0aKlBJAo/3t8KcSvFWU4J. So we've been through this discussion before, but apparently not gotten the lesson.
The issue here was that people weren't importing all the classes they were using but relied on other classes importing them. When we removed the jimports() from those classes this broke because now classes are only loaded when they're actually used.
On 03.02.2012, at 17:50, Elin Waring wrote:
> Another important thing to keep in mind is that, obviously, even if a class itself has a camel case name for readability (as opposed to autoloading) you must not use camel case when creating a new instance. JWebClient is a good example
JWebClient is another example of a class that can't be autoloaded right now. My preferred solution for this class would be renaming it to JApplicationWebClient and renaming its file from webclient.php to client.php.
Best regards
Rouven
JWebClient is certainly one of the easier cases. It should be fixed in a couple of days: https://github.com/joomla/joomla-platform/pull/828
Rouven