Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stubGenerator.php gives Fatal Error #17736

Closed
Bakual opened this issue Aug 27, 2017 · 8 comments
Closed

stubGenerator.php gives Fatal Error #17736

Bakual opened this issue Aug 27, 2017 · 8 comments

Comments

@Bakual
Copy link
Contributor

Bakual commented Aug 27, 2017

Steps to reproduce the issue

Try to run stubGenerator.php

Expected result

Creates a stubs.php file

Actual result

Creates fatal error:

Fatal error: Cannot use Joomla\CMS\Table\Observer\ContentHistory as ContentHistory because the name is already in use in D:\xampp\htdocs\joomla\libraries\src\Table\Category.php on line 15

Call Stack:
    0.0003     355000   1. {main}() D:\xampp\htdocs\joomla\build\stubGenerator.php:0
    2.1262    2510496   2. Joomla\CMS\Application\CliApplication->execute() D:\xampp\htdocs\joomla\build\stubGenerator.php:90
    2.1262    2510496   3. StubGenerator->doExecute() D:\xampp\htdocs\joomla\libraries\src\Application\CliApplication.php:145
    2.1540    5253376   4. ReflectionClass->__construct() D:\xampp\htdocs\joomla\build\stubGenerator.php:75
    2.1540    5253520   5. spl_autoload_call() D:\xampp\htdocs\joomla\build\stubGenerator.php:75
    2.1540    5253608   6. JLoader::loadByPsr4() D:\xampp\htdocs\joomla\build\stubGenerator.php:75

Additional comments

Removing the line https://github.com/joomla/joomla-cms/blob/staging/libraries/classmap.php#L61 solves the issue, but isn't the right solution I guess.
I'm not sure if that is an issue only in the stubGenerator script or if that is something which can happen in production as well.

@mbabker
Copy link
Contributor

mbabker commented Aug 27, 2017

Nope, not the right fix.

Need to do use Joomla\CMS\Table\Observer\ContentHistory as ContentHistoryObserver; in that file then changes references to the observer to use the aliased name.

There's both a Joomla\CMS\Table\Observer\ContentHistory and Joomla\CMS\Table\ContentHistory and you can't reference the same short name twice in one file. Since Joomla\CMS\Table\Category is in the namespace as the latter, it's automatically referencing the class in the same namespace first (PHP behavior).

@alikon
Copy link
Contributor

alikon commented Aug 28, 2017

unable to replicate, runned stubGenerator.php but
stubs.php file created without Fatal error

@Bakual
Copy link
Contributor Author

Bakual commented Aug 28, 2017

unable to replicate, runned stubGenerator.php but

On current staging? That's strange.

@brianteeman
Copy link
Contributor

worked for me too

@Bakual
Copy link
Contributor Author

Bakual commented Aug 29, 2017

May that be related to the PHP version? Mine is 7.0.4 (XAMPP on Windows). But given Michaels explanation I would expect it to fail on all versions anyway. 😕

@alikon
Copy link
Contributor

alikon commented Aug 29, 2017

yes current staging, mine PHP is 7.0.22 ubuntu

@Bakual
Copy link
Contributor Author

Bakual commented Aug 29, 2017

Updated now XAMPP to PHP 7.1.8 and it works again. So looks indeed like a bug in 7.0.4. I've read that it was fixed with PHP 7.0.7.

I'm closing this issue then.

@Bakual Bakual closed this as completed Aug 29, 2017
@fred-the-coder
Copy link

FYI this issue occurs as well while retrieving a JTable instance for "Category" (JTable::getInstance('Category')) with PHP 5.6.38.
Moving to PHP 7.1.22 is solving the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants