? Pending

User tests: Successful: Unsuccessful:

avatar mbabker
mbabker
13 Dec 2017

Summary of Changes

A side effect of using lowercased aliases in JLoader to cope with class aliasing issues, the log messages now also used the lowercased aliased name, and that just makes the log messages a little hard to read. This PR changes JLoader::registerAlias() so that the lowercased alias is stored as a separate variable, making the original alias (with proper casing) available in the deprecation tracker.

Testing Instructions

Code review, check deprecation logs (must have this enabled, options in log plugin) for class name casing.

Expected result

JCacheExceptionConnecting has been aliased to Joomla\CMS\Cache\Exception\CacheConnectingException and the former class name is deprecated. The alias will be removed in 5.0

Actual result

jcacheexceptionconnecting has been aliased to Joomla\CMS\Cache\Exception\CacheConnectingException and the former class name is deprecated. The alias will be removed in 5.0

avatar mbabker mbabker - open - 13 Dec 2017
avatar mbabker mbabker - change - 13 Dec 2017
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 13 Dec 2017
Category Libraries
avatar joomdonation joomdonation - test_item - 19 Dec 2017 - Tested successfully
avatar joomdonation
joomdonation - comment - 19 Dec 2017

I have tested this item successfully on 8bac562

Deprecation logging shows class name in correct case now. Also, navigate to random pages and it is still working as expected

Not related to this but StubGenerator still generate class name is lower case :(


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/19050.

avatar mbabker
mbabker - comment - 19 Dec 2017

Not related to this but StubGenerator still generate class name is lower case :(

It's because it uses the $classAlias property which is written to with lowercased aliases. FWIW Nicholas' tool just parses out the libraries/classmap.php file to get a list of classes, so he's not really using the API either and the output from his tool is fine (but he's also supporting more versions with his tool and all the API pieces aren't consistently there).

StubGenerator may be able to be updated to use JLoader::getDeprecatedAliases() as that would have the correctly cased aliases and it would allow us to generate a stub class doc block with a @deprecated <version> tag so that IDEs also report the aliases as deprecated (this was one of the complaints I had seen about our script that Nicholas' tool addresses).

avatar joomdonation
joomdonation - comment - 19 Dec 2017

Yes, use JLoader::getDeprecatedAliases() solves that issue, thanks

public function doExecute()
{
	$file = "<?php\n";

	foreach (JLoader::getDeprecatedAliases() as $deprecation)
	{
		$oldName = $deprecation['old'];
		$newName = $deprecation['new'];

		// Figure out if the alias is for a class or interface
		$reflection = new ReflectionClass($newName);
		$type       = $reflection->isInterface() ? 'interface' : 'class';
		$modifier   = ($reflection->isAbstract() && !$reflection->isInterface()) ? 'abstract ' : '';

		$file .= "$modifier$type $oldName extends $newName {}\n";
	}
	// And save the file locally
	file_put_contents(JPATH_ROOT . '/stubs.php', $file);

	$this->out('Stubs file written', true);
}
avatar mbabker mbabker - change - 23 Dec 2017
Status Pending Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2017-12-23 15:55:25
Closed_By mbabker
Labels Added: ?
avatar mbabker mbabker - close - 23 Dec 2017
avatar mbabker mbabker - merge - 23 Dec 2017

Add a Comment

Login with GitHub to post a comment