User tests: Successful: Unsuccessful:
Pull Request for Issue #25574 .
Removes unneeded exception.
Create a contact.
VIew contacts list.
Works.
An error has occurred.
$i is not allowed to be 0
No.
Status | New | ⇒ | Pending |
Category | ⇒ | Administration com_contact com_content |
I have tested this item
Marking as a success because it fixes the problem but I have no idea what the code was supposed to have done or why it was added
Marking as a success because it fixes the problem but I have no idea what the code was supposed to have done or why it was added
Was added due to suggestion by @wilsonge : #25451 (comment).
If it's required it's required in both files.
But I don't get this. Before the PR this was a required variable - this was the signature.
public function featured($value = 0, $i, $canChange = true)
As far as I can see this is always used with a value. So how is this ever taking the default value of the function of 0. Or are we saying in some case here https://github.com/joomla/joomla-cms/blob/4.0-dev/administrator/components/com_contact/tmpl/contacts/default.php#L127 $i
is somehow 0?
I'm not disputing we somehow broke this btw. But to understand the correct fix I need to understand why it's broken. Reverting that part isn't good enough - because if 0 is a valid value then it's a really bad default (I really wish we didn't have to set a default but.....)
Or are we saying in some case here https://github.com/joomla/joomla-cms/blob/4.0-dev/administrator/components/com_contact/tmpl/contacts/default.php#L127 $i is somehow 0?
Yes, $i
is the array key:
Or maybe just make the parameter mandatory? No need for exceptions then.
I have just come across this problem.
Does anyone know why $i
was given a default value?
In the case of $published
, the parameter $i
is a mandatory parameter.
joomla-cms/libraries/cms/html/jgrid.php
Line 174 in e4c2d1f
In my opinion, we should keep this consistent in the project.
It's because of codestyle:
Arguments with default values must be at the end of the argument list
In the case of Joomla\Component\Contact\Administrator\Service\HTML::featured($value = 0, $i, $canChange = true)
mandatory parameter $i
was after optional parameter $value
.
Maybe we could make $value
required instead.
Required $value
parameter would also be more consistent to astridx's code snippet. Reading the code of these 2 functions modified by this PR, I think the $value
parameter should be required, then you also can make the $i
required. The exceptions you could add back and change them so $i
lower than zero are not allowed, if that is useful.
When testing this we should test both contacts view and com_content stuff, e.g. articles view, because this PR modifies files for both.
OK let's make $value required. I think in this case it's acceptable
Labels |
Added:
?
|
Status | Pending | ⇒ | Fixed in Code Base |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2019-07-23 18:18:34 |
Closed_By | ⇒ | wilsonge |
Thanks!
I have tested this item✅ successfully on 91a699e
Marking as a success because it fixes the problem but I have no idea what the code was supposed to have done or why it was added
This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/25576.