?
avatar Bakual
Bakual
27 Aug 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.

avatar Bakual Bakual - open - 27 Aug 2017
avatar joomla-cms-bot joomla-cms-bot - change - 27 Aug 2017
Labels Added: ?
avatar joomla-cms-bot joomla-cms-bot - labeled - 27 Aug 2017
avatar franz-wohlkoenig franz-wohlkoenig - change - 27 Aug 2017
Category Libraries
avatar mbabker
mbabker - comment - 27 Aug 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).

avatar franz-wohlkoenig franz-wohlkoenig - change - 28 Aug 2017
Status New Discussion
avatar alikon
alikon - comment - 28 Aug 2017

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

avatar Bakual
Bakual - comment - 28 Aug 2017

unable to replicate, runned stubGenerator.php but

On current staging? That's strange.

avatar brianteeman
brianteeman - comment - 28 Aug 2017

worked for me too

avatar Bakual
Bakual - comment - 29 Aug 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. 😕

avatar alikon
alikon - comment - 29 Aug 2017

yes current staging, mine PHP is 7.0.22 ubuntu

avatar Bakual
Bakual - comment - 29 Aug 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.

avatar Bakual Bakual - change - 29 Aug 2017
Status Discussion Closed
Closed_Date 0000-00-00 00:00:00 2017-08-29 06:51:10
Closed_By Bakual
avatar Bakual Bakual - close - 29 Aug 2017
avatar fred-the-coder
fred-the-coder - comment - 19 Sep 2018

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.

Add a Comment

Login with GitHub to post a comment