User tests: Successful: Unsuccessful:
Pull Request for Issue #16289
To please @Bakual here is a script one can run which will generate a local stub file holding all of the mapped classes that core has.
Run php/stubGenerator.php
, see file written at JPATH_ROOT . '/stubs.php'
, enjoy IDE auto complete.
Status | New | ⇒ | Pending |
Category | ⇒ | Repository |
Labels |
Added:
?
|
Done.
I have tested this item
Unfortunately the script didn't work for me. I get this messages:
D:\xampp\htdocs\joomla4\build>php stubGenerator.php
Deprecated: Bootstrapping Joomla using the D:\xampp\htdocs\joomla4\libraries\import.legacy.php file is deprecated. Use D:\xampp\htdocs\joomla4\libraries/bootstrap.php instead. in D:\xampp\htdocs\joomla4\libraries\import.legacy.php on line 18
Call Stack:
0.0002 354584 1. {main}() D:\xampp\htdocs\joomla4\build\stubGenerator.php:0
0.0007 369072 2. require_once('D:\xampp\htdocs\joomla4\libraries\import.legacy.php') D:\xampp\htdocs\joomla4\build\stubGenerator.php:25
0.0007 369392 3. trigger_error() D:\xampp\htdocs\joomla4\libraries\import.legacy.php:18
Deprecated: Bootstrapping Joomla using the D:\xampp\htdocs\joomla4\libraries\cms.php file is deprecated. Use D:\xampp\htdocs\joomla4\libraries/bootstrap.php instead. in D:\xampp\htdocs\joomla4\libraries\cms.php on line 17
Call Stack:
0.0002 354584 1. {main}() D:\xampp\htdocs\joomla4\build\stubGenerator.php:0
0.0299 461816 2. require_once('D:\xampp\htdocs\joomla4\libraries\cms.php') D:\xampp\htdocs\joomla4\build\stubGenerator.php:28
0.0299 462136 3. trigger_error() D:\xampp\htdocs\joomla4\libraries\cms.php:17
Error displaying the error page: Application Instantiation Error: Class \Joomla\Component\Fields\Administrator\Plugin\FieldsPlugin does not exist
````<hr /><sub>This comment was created with the <a href="https://github.com/joomla/jissues">J!Tracker Application</a> at <a href="https://issues.joomla.org/tracker/joomla-cms/16291">issues.joomla.org/tracker/joomla-cms/16291</a>.</sub>
Test was done on the 4.0-dev branch if that matters.
It does matter. I wrote and tested this on 3.8 because that's where most
of the library namespacing is going. Either you've hit a bug on 4.0 or
it'll need minor adjustments when merging up.
On Sun, May 28, 2017 at 3:28 PM Thomas Hunziker notifications@github.com
wrote:
Test was done on the 4.0-dev branch if that matters.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#16291 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAWfoSONQm6s_a-b2RKKftHCKzVJn0fOks5r-XaSgaJpZM4Noc5r
.
--
I have tested this item
It indeed works fine on 3.8
The issues in 4.0 come from non-existing observer classes and the field plugin classes don't autoload. If I comment those class alias out, it works as well.
Rough guess but it would highly depend on when the mapping for components
is loaded. The CLI script is only including the libraries bootstrap, so if
there's a step to boot component stuff I don't have it (at least on 3.8).
On Sun, May 28, 2017 at 9:14 PM Thomas Hunziker notifications@github.com
wrote:
@laoneo https://github.com/laoneo Do you have an idea why the classes
from the extensions.classmap.php (FieldsPlugin and FieldsListPlugin) don't
autoload within this script? That is probably a bug in 4.0 but since it
actually works when creating a field I have no clue where the issue is.—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#16291 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAWfoYrU8xcyhOmEXKSbAItEfmhd5lTWks5r-cd5gaJpZM4Noc5r
.
--
In 3.8, that extension.classmap file doesn't exist. In 4.0 it is included here: https://github.com/joomla/joomla-cms/blob/4.0-dev/libraries/classmap.php#L12 (part of the regular classmap file).
The "problem" in that case is the alias is defined but the class that's being resolved doesn't autoload. So the generator when merged up to 4.0 will have to either register the autoloader for extensions that have mappings in that file or manually include the classes. Relatively easy to accomplish, but has to be done separate from this since the logic won't apply in 3.x.
Yes, that's why I pinged @laoneo. Imho it doesn't make much sense to register the alias if the autoloader can't load them at that point. Seems to me either those extension alias are loaded to early or the script misses part of the autoloading logic.
But yeah, it's not an issue of the stubGenerator and this PR. It just showed a potential flaw in J4.
I just moved the files into a separate file because actually we don't know exactly what to do with the old extension classes. This here would help for extensions that they can autoload classes https://github.com/joomla/joomla-cms/pull/15609/files#diff-ac14d0b3dd6bab616ec8dc3e0b36e1f5R12.
Maybe we just shouldn't register the alias for extensions in a central place but instead do it in the extension itself where they also have their autoloading stuff. Because 3rd parties can't do the same anyway.
That's not going to fly for at least Fields and Smart Search because they provide classes that plugins are supposed to be extending.
Either way, registering aliases is not a problem in and of itself. You hit a tricky scenario where the aliases are registered but the real classes are never loaded. In normal use of the CMS it'll be fine, but for our second class citizens (command line scripts), it may present a problem.
Status | Pending | ⇒ | Fixed in Code Base |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2017-05-29 15:08:32 |
Closed_By | ⇒ | wilsonge |
Can you add some documentation to the file please to at least give a clue what this file is for and who and why it might be used