? Pending

User tests: Successful: Unsuccessful:

avatar sakiss
sakiss
12 Mar 2021

Summary of Changes

Removal of the unused $contexts parameter in the function batchCopy

Testing Instructions

Batch copy a couple of articles

Actual result BEFORE applying this Pull Request

They are copied

Expected result AFTER applying this Pull Request

They are copied

Documentation Changes Required

DKN

avatar sakiss sakiss - open - 12 Mar 2021
avatar sakiss sakiss - change - 12 Mar 2021
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 12 Mar 2021
Category Libraries
avatar brianteeman
brianteeman - comment - 12 Mar 2021

What makes you think this is unused?

avatar sakiss
sakiss - comment - 12 Mar 2021

What makes you think this is unused?

Check inside the function

avatar brianteeman
brianteeman - comment - 12 Mar 2021

You mean like here where you removed context

				$result = $this->batchCopy($commands[$this->batch_copymove], $pks);
				if (\is_array($result))
				{
					foreach ($result as $old => $new)
					{
						$contexts[$new] = $contexts[$old];
					}
					$pks = array_values($result);
avatar sakiss
sakiss - comment - 12 Mar 2021

i mean inside the batchCopy fn

avatar joomdonation
joomdonation - comment - 12 Mar 2021

@sakiss Although method batchCopy inside AdminModel class does not use that parameter, there are classes (which extends AdminModel) expect to receive this parameter like this https://github.com/joomla/joomla-cms/blob/4.0-dev/administrator/components/com_categories/src/Model/CategoryModel.php#L940 , so you cannot remove it.

avatar sakiss
sakiss - comment - 12 Mar 2021

@joomdonation To my knowledge, calling a function with more than it's declared params it's legal php without any effect.
http://sandbox.onlinephpfunctions.com/code/fa82bad0a6f49003f0d651a931be49e2ce104066

avatar joomdonation
joomdonation - comment - 12 Mar 2021

Yes @sakiss. But what if the model class which extends AdminModel need to use that data for some reasons? With your change, they won't receive that parameter anymore (not only core model classes but also third party extensions)

Also, although it is legal, I think that the number of parameters should be the same.

avatar sakiss sakiss - change - 12 Mar 2021
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2021-03-12 15:15:14
Closed_By sakiss
Labels Added: ?
avatar sakiss
sakiss - comment - 12 Mar 2021

@joomdonation this change does not affect function overrides in child classes whatsoever.
The only concern is that in php 8, if a function is overwritten and introduces additional parameters, these should have default values. Otherwise an error is generated.
Because changing all the classes that extend that fn, adding default params, is PIITA and also error prone for 3rd party extensions, i am closing the PR.

avatar sakiss sakiss - close - 12 Mar 2021

Add a Comment

Login with GitHub to post a comment