User tests: Successful: Unsuccessful:
Removal of the unused $contexts
parameter in the function batchCopy
Batch copy a couple of articles
They are copied
They are copied
DKN
Status | New | ⇒ | Pending |
Category | ⇒ | Libraries |
What makes you think this is unused?
Check inside the function
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);
i mean inside the batchCopy fn
@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.
@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
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.
Status | Pending | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2021-03-12 15:15:14 |
Closed_By | ⇒ | sakiss | |
Labels |
Added:
?
|
@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.
What makes you think this is unused?