Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Articles count in "List all categories" #5416

Closed
wants to merge 10 commits into from

Conversation

smanzi
Copy link

@smanzi smanzi commented Dec 13, 2014

Fixes articles count in "List all categories": articles for non active language were erroneously accounted for (see: #5412)

Fixes articles count in "List all categories": articles for non
active language were erroneously accounted for (see: 5412)
@smanzi
Copy link
Author

smanzi commented Dec 13, 2014

I also took the occasion for cleaning up the code in JCategories::_load() for the 'countItems' option...

@smanzi
Copy link
Author

smanzi commented Dec 13, 2014

Travis not very clear on this...

FILE: ...avis/build/joomla/joomla-cms/libraries/legacy/categories/categories.php
--------------------------------------------------------------------------------
FOUND 2 ERROR(S) AFFECTING 2 LINE(S)
--------------------------------------------------------------------------------
270 | ERROR | Expected 1 space after "%s"; %s found
275 | ERROR | Expected 1 space after "%s"; %s found
--------------------------------------------------------------------------------

I think it is the double spaces after the .= operators... let's try!

@smanzi
Copy link
Author

smanzi commented Dec 13, 2014

There is conceptual error: the active language must be taken into account when computing the instance hash...
Going to fix this

@smanzi
Copy link
Author

smanzi commented Dec 13, 2014

I have a fix ready but I cannot sync my local repo with upstream... I hope it is GitHub momentary issue...

@smanzi
Copy link
Author

smanzi commented Dec 13, 2014

Fixed!

@smanzi
Copy link
Author

smanzi commented Dec 14, 2014

Don't panic: "smz" is my new GitHub account

@smz
Copy link
Contributor

smz commented Dec 14, 2014

Confirmed!

@AlexRed
Copy link
Contributor

AlexRed commented Dec 17, 2014

Successfull test.


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

@smz
Copy link
Contributor

smz commented Dec 17, 2014

@AlexRed Thank-you for testing, Alessandro!

What I forgot to underline in the presentation of this PR is that this issue is particularly nasty when the returned count should be zero and instead it is non-zero: there you have an empty category displayed while it should not.

I know that mixing articles tagged for different languages inside a common category is not considered a best practice and common wisdom is against this, but I think instead that this gives you a further degree of freedom that may be leveraged in different scenarios. Sometimes best practices and common wisdom derive from the necessity to work around existing issues...

@stellainformatica
Copy link
Contributor

@test:
Patch tested, it solves the issue.


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

@smz
Copy link
Contributor

smz commented Dec 18, 2014

@stellainformatica Thanks for testing, ste, appreciated!

C'mon guys/girls, some more tests and comments, so we have the opportunity of this bug being fixed!

@infograf768
Copy link
Member

@smz
Please kindly look at
#4937

I had already found that issue while testing your patch when I saw that report.
Looks like in config.xml as well as categories/default.xml, the field
<field name="maxLevelcat
is wrong.
I.e. it does not include "None" with value "0"
Therefor the code to diisplay the subcategories should also include "None" and the display conditions should take into account "All" and "None"

Looks also that the issue exists for other core components.

@smz
Copy link
Contributor

smz commented Dec 18, 2014

@infograf768 JM, I may be, as they say, "thick as brick", but I fail to understand if you're telling me that what I'm trying to solve here is a consequence of #4937 (and hence once fixed that, this issue will be automatically fixed as well) or if you are asking me to try to fix #4937 too while I'm trying to fix this...

Sorry, sometimes is not so easy to understand between each other, especially when both are not using their native language!

@infograf768
Copy link
Member

Just asking if you have time to also fix #4937 as you have been working on categories. :)
This would be another PR, as I see it, as it concerns quite a few files and tests and the issue is different

@smz
Copy link
Contributor

smz commented Dec 18, 2014

Ah, OK! Will look into it and let you know if I'm able to... Right now I'm preparing a new commit to #5463 as I discovered that the dates conditions ("before", "after" and "exact") are not translated in the query description and so I'm adding 3 new strings for i18n...

@brianteeman brianteeman added the RTC This Pull Request is Ready To Commit label Dec 20, 2014
@infograf768
Copy link
Member

@smz
Don't we also have to port this PR here to the other core components as you did in #5469 ?

@smz
Copy link
Contributor

smz commented Dec 21, 2014

@infograf768 JM, if we are convinced this is the correct behavior for all components, I think we can just get rid of the new option and modify the library with the following:

        $options['currentlang'] = JLanguageMultilang::isEnabled() ? 1 : 0;
        if ($options['currentlang'] == 1)
        {
            $options['currentlang'] = JFactory::getLanguage()->getTag();
        }

doing that we will have it automatically applied to all current and future components. What do you think?

@smz
Copy link
Contributor

smz commented Dec 21, 2014

P.S.: I already checked that it does not have any detrimental effect in backend...

@smz
Copy link
Contributor

smz commented Dec 21, 2014

or better:

$options['currentlang'] = JLanguageMultilang::isEnabled() ? JFactory::getLanguage()->getTag() : 0;

@infograf768
Copy link
Member

Have you tested?


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

@smz
Copy link
Contributor

smz commented Dec 24, 2014

Not yet, TBH... If all is well I'll push a commit, OK?

@smz
Copy link
Contributor

smz commented Dec 24, 2014

I mean: I already tested in com_content, but not with other components.

@wilsonge
Copy link
Contributor

All fixed with smz#2

@smz
Copy link
Contributor

smz commented Dec 25, 2014

@wilsonge Thanks, George, merged!

@smz
Copy link
Contributor

smz commented Dec 25, 2014

com_contact items count issue is fixed in #5515 (I think this is so trivial it may jump to merge...)

Small typo: double semicolon
@infograf768
Copy link
Member

OK here. Need one more tester?

@smz
Copy link
Contributor

smz commented Dec 25, 2014

@infograf768 JM, we also have @AlexRed and @stellainformatica tests (if you still consider those as valid), but what do you think about my concern about the need to use $db->quote with string constants inside a query [see: https://github.com//pull/5416#issuecomment-68076921]?

@infograf768
Copy link
Member

@smz
Copy link
Contributor

smz commented Dec 25, 2014

Seems to be OK here...

@smz
Copy link
Contributor

smz commented Dec 28, 2014

@infograf768 JM, what do we do with this? In the meanwhile I discovered that it solves the same issue (wrong articles count) also for mod_articles_categories...

@smz
Copy link
Contributor

smz commented May 4, 2015

Sorry, guys, may I ask why this PR which fixes a bug and has been extensively discussed/tested isn't apparently considered for merging?

@brianteeman
Copy link
Contributor

OK here. Need one more tester?


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

@smz
Copy link
Contributor

smz commented May 4, 2015

That looks more as a question than a statement and http://issues.joomla.org/tracker/joomla-cms/5416 says we already have 2 successfull test, but, please, feel free to test yourself.

@dgrammatiko
Copy link
Contributor

@test OK
Sorry Sergio for the very late response here, I thought this has been merged already

@smz
Copy link
Contributor

smz commented May 8, 2015

@dgt41
No problem, Dimitris! Actually I think this PR already had 2 positive tests (three counting JM)

@wilsonge wilsonge closed this in 497e2da May 9, 2015
@wilsonge
Copy link
Contributor

wilsonge commented May 9, 2015

Merged - thanks for bringing to my attention. For some reason I thought I'd merged this earlier in the week. Totally my bad! Sorry!

@smz
Copy link
Contributor

smz commented May 9, 2015

It's OK, George! Thanks!

@zero-24 zero-24 added this to the Joomla! 3.4.2 milestone May 9, 2015
@zero-24 zero-24 added the RTC This Pull Request is Ready To Commit label May 9, 2015
@smz smz deleted the ListCategoriesItemsCount branch May 29, 2015 01:31
johanjanssens pushed a commit to joomlatools/joomla-fork that referenced this pull request Jun 19, 2015
@@ -259,20 +261,21 @@ protected function _load($id)
->where('badcats.id is null');

// Note: i for item
if (isset($this->_options['countItems']) && $this->_options['countItems'] == 1)
if ($this->_options['currentlang'] !== 0 || $this->_options['countItems'] == 1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one makes third party extensions fail on multilang sites, which don't want this part activated. The whole option of "currentlang" has no business here. It counters "countItems". The first part of this if needs to be removed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please make an example?

That condition is essential for returning the correct items in multilingual environments: you want to get items that are flagged for either the current language or *

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before your change, you were able to disable the whole counting stuff. Your change forces this to be enabled when you are in a multi-language site, regardless of the component even using any language stuff at all. With your change, I can't switch this off.

I have a component that uses the category system, but does not have a catid field in the data table. So, since I don't need the whole counting thing and it is also not applicable to my situation, I disabled it for my JCategories implementation. This change forces this option to ON and since I don't have a DB table field for the category ID, I get a nice big error page with a broken query.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How would you solve the original issue this PR has solved without breaking your component?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is already a PR #7303 by Hannes. I think it should fix both the original issue from here and the regression introduced.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet