? Pending

User tests: Successful: Unsuccessful:

avatar alexva24
alexva24
26 Jan 2016

Internal counter needs to update after new pathways set

avatar alexva24 alexva24 - open - 26 Jan 2016
avatar alexva24 alexva24 - change - 26 Jan 2016
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 26 Jan 2016
Labels Added: ? ?
avatar joomla-cms-bot
joomla-cms-bot - comment - 26 Jan 2016

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.

avatar alexva24
alexva24 - comment - 28 Jan 2016

Nothing to test

avatar brianteeman
brianteeman - comment - 28 Jan 2016

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

avatar alexva24
alexva24 - comment - 28 Jan 2016

Pathways counter needs to update after new pathways set. This PR fixed this bug.

avatar brianteeman
brianteeman - comment - 28 Jan 2016

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/

avatar alexva24
alexva24 - comment - 28 Jan 2016

In source code

avatar mbabker
mbabker - comment - 28 Jan 2016

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.

avatar alexva24
alexva24 - comment - 28 Jan 2016

$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!!!

avatar mbabker
mbabker - comment - 28 Jan 2016

Thank you, that gives folks an easy way to validate what you've changed.

avatar sovainfo
sovainfo - comment - 28 Jan 2016

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.

avatar alexva24
alexva24 - comment - 28 Jan 2016

@sovainfo, I agree with you.

avatar brianteeman brianteeman - change - 29 Jan 2016
Labels Removed: ?
avatar alexva24
alexva24 - comment - 4 Feb 2016

Countable interface implemented on JPathways class

avatar anibalsanchez anibalsanchez - test_item - 5 Feb 2016 - Tested unsuccessfully
avatar anibalsanchez
anibalsanchez - comment - 5 Feb 2016

I have tested this item :red_circle: unsuccessfully on e1bb5d5

Tested with the suggested code:

Fatal error: Call to undefined method JApplicationAdministrator::getPathways()


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/8987.

avatar mbabker
mbabker - comment - 5 Feb 2016

The method's name is getPathway(), plural I'm going to assume is a typo.

avatar alexva24
alexva24 - comment - 6 Feb 2016

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);

avatar sovainfo
sovainfo - comment - 6 Feb 2016

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!

avatar alexva24
alexva24 - comment - 6 Feb 2016

@sovainfo JPathway::getInstance('site') and JFactory::getApplication()->getPathway() returns JPathway object with protected property _pathway

avatar sovainfo
sovainfo - comment - 6 Feb 2016

No, it doesn't. The getPathway() returns: return array_values($pw);
At least in j345, maybe staging is different.

EDIT: It is not different!

avatar alexva24
alexva24 - comment - 6 Feb 2016

count(JPathway::getInstance('site')) simpler than count(JPathway::getInstance('site')->getPathway())

avatar sovainfo
sovainfo - comment - 6 Feb 2016

And count($pathways) is simpler than that!

avatar alexva24
alexva24 - comment - 6 Feb 2016

@sovainfo But before your need to set variable $pathways

avatar sovainfo
sovainfo - comment - 6 Feb 2016

No, you don't. IF there is a need for a count without the values then count($app->getPathway()) will do.

avatar brianteeman brianteeman - change - 13 Apr 2016
Category Libraries
avatar roland-d
roland-d - comment - 1 Aug 2016

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.


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/8987.

avatar ggppdk
ggppdk - comment - 1 Aug 2016

I do not say it is enough to accept a PR without testing although the fix is obvious

  • I have seen this bug a few years ago, but since the variable is currently not used for something important, that is the reason i did not report

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)

  • the other commits to implement the countable interface are not 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

avatar alexva24 alexva24 - change - 19 Feb 2018
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2018-02-19 09:47:57
Closed_By alexva24
avatar alexva24 alexva24 - close - 19 Feb 2018

Add a Comment

Login with GitHub to post a comment