?
avatar demis-palma
demis-palma
17 Aug 2017

Steps to reproduce the issue

Using the following code raises a PHP warning:

class MyLog extends JLog
{
	public static function add($entry, $priority = self::INFO, $category = '', $date = null)
	{
	}
}

PHP Warning: Declaration of MyLog::add($entry, $priority = self::INFO, $category = '', $date = NULL) should be compatible with Joomla\CMS\Log\Log::add($entry, $priority = self::INFO, $category = '', $date = NULL, array $context = Array) in ... on line ...

Expected result

Semantic versioning is respected and the addition of new parameters that break third party extensions are deferred to the next major release.

Actual result

Semantic versioning is violated by new parameter $context that break third party extensions.

avatar demis-palma demis-palma - open - 17 Aug 2017
avatar joomla-cms-bot joomla-cms-bot - change - 17 Aug 2017
Labels Added: ?
avatar joomla-cms-bot joomla-cms-bot - labeled - 17 Aug 2017
avatar mbabker
mbabker - comment - 17 Aug 2017

We have added optional parameters to existing APIs in past releases. This is not an issue.

The warning is annoying but it will not break extensions.

avatar demis-palma
demis-palma - comment - 17 Aug 2017

I suspected this kind of reply. 😞
However, this kind of warning can't be muted with @ because it happens at compile time, and can prevent the header() function from working properly. (Cannot modify header information - headers already sent)

I suspect that it will cause more problems than we can expect at first glance.

avatar mbabker
mbabker - comment - 17 Aug 2017

I know it can be problematic, I still have code that is 2.5/3.x compatible that emits warnings because of changed signatures in 3.0 but works all the same. Hence the reason I personally don't class it as a B/C break.

Adding mandatory arguments or changing interfaces definitely falls under the B/C realm. But for these kinds of things, unless we start using func_get_args() in all the methods to hack around the warning that will be emitted, it's just something we make sure is properly documented going forward.

avatar demis-palma
demis-palma - comment - 17 Aug 2017

I understand.
But is there any particular advantage adding this new parameter right now? Can't it wait the 4.0?

avatar mbabker
mbabker - comment - 17 Aug 2017

Yes. We added a PSR-3 compatible bridge and need to be able to pass the extra data from the bridge class into our logging class.

avatar Bakual Bakual - change - 17 Aug 2017
Status New Closed
Closed_Date 0000-00-00 00:00:00 2017-08-17 14:19:49
Closed_By Bakual
avatar Bakual Bakual - close - 17 Aug 2017
avatar Bakual
Bakual - comment - 17 Aug 2017

Semantic Versioning explicitely allows this kind of thing. A generated PHP warning is not a B/C break. It requries only a new minor version if you add new optional arguments to a function.

I'm closing this issue.

Add a Comment

Login with GitHub to post a comment