User tests: Successful: Unsuccessful:
Internal counter needs to update after new pathways set
Status | New | ⇒ | Pending |
Labels |
Added:
?
?
|
Nothing to test
Then it will be closed.
Please describe the issue that this Pull Request resolves. How to replicate that problem and how to see the results of this Pull Request
Pathways counter needs to update after new pathways set. This PR fixed this bug.
How can I see this bug!!!
On 28 January 2016 at 14:55, Aleksey Vaganov notifications@github.com
wrote:
Pathways counter needs to update after new pathways set. This PR fixed
this bug.—
Reply to this email directly or view it on GitHub
#8987 (comment).
Brian Teeman
Co-founder Joomla! and OpenSourceMatters Inc.
http://brian.teeman.net/
In source code
There needs to be a way to reproduce this or it'll never get tested. Even if it's telling someone to put a var_dump() in somewhere to compare results before and after. Simply reading the source code isn't going to cut it, I'm reading it and I'm not immediately grasping what your change is doing.
$pathways = JFactory::getApplication()->getPathways();
print_r($pathways);
$pathways->setPathways(array());
print_r($pathways);
// Pathways->_count must be a zero, but it stay on old value. It's a bug!!!
Thank you, that gives folks an easy way to validate what you've changed.
Haven't been able to find a reference to _count other than in the addItem method of JPathway.
Sounds like it is not used, no wonder it is not properly maintained. Agree with @alexva24 that his change would maintain it properly, only see no reason to do it.
Suggest to remove _count and use count($app->getPathway()) or count($pathway) instead.
Labels |
Removed:
?
|
Countable interface implemented on JPathways class
I have tested this item unsuccessfully on e1bb5d5
Tested with the suggested code:
Fatal error: Call to undefined method JApplicationAdministrator::getPathways()
The method's name is getPathway()
, plural I'm going to assume is a typo.
To test Countable interface implementation use code bellow:
$pathways = JFactory::getApplication()->getPathway();
echo count($pathways);
$pathways->setPathway(array());
echo count($pathways);
$pathways->addItem('Anchor1', '/link1');
echo count($pathways);
That is not testing the count interface, it is testing the php count function.As already mentioned that works, no need to test that.
To test the count interface you would need to get an instance of the Pathway and call the count method:
JPathway::getInstance('site')->count();
Which is why I concluded there is no need for Pathway to maintain a count. No need to implement the count interface either. Considering it only returns an array of values and php count can be used to count them!
No, it doesn't. The getPathway() returns: return array_values($pw);
At least in j345, maybe staging is different.
EDIT: It is not different!
count(JPathway::getInstance('site')) simpler than count(JPathway::getInstance('site')->getPathway())
And count($pathways) is simpler than that!
No, you don't. IF there is a need for a count without the values then count($app->getPathway()) will do.
Category | ⇒ | Libraries |
I agree with @sovainfo here. A simple count($app->getPathway()) will do. I do not see the need to implement a Countable interface for this. As mentioned before it is a value that doesn't seem to be used because it is a protected variable and only used internally to increment the value. For what it is worth, I would say the deprecation would just say that the $_count will be removed in 4.0.
I do not say it is enough to accept a PR without testing although the fix is obvious
But code review,
is more than enough to confirm the issue, since the involved code is too small
Please click at the very 1st commit to see the fix, (only the 1 commit of this PR is needed)
Explanation:
The class has a property:
protected $_count = 0;
When you an item the above property, is incremented, click here to confirm this:
https://github.com/joomla/joomla-cms/blob/staging/libraries/cms/pathway/pathway.php#L175
When you use setPathWay, it is not set to new value, click here to confirm this:
https://github.com/joomla/joomla-cms/blob/staging/libraries/cms/pathway/pathway.php#L127-L135
To cut this short, only the 1st commit is needed, no need to implement a Countable interface
Status | Pending | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2018-02-19 09:47:57 |
Closed_By | ⇒ | alexva24 |
Please add more information to your issue. Without test instructions and/or any description we will close this issue within 4 weeks. Thanks.
This is an automated message from the J!Tracker Application.