- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 3.7k
BUG: Sample Data blog various issues #17930
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
Conversation
        
          
                plugins/sampledata/blog/blog.php
              
                Outdated
          
        
      | // Calculate menutype. | ||
| $menu['menutype'] = JApplicationHelper::stringURLSafe($menu['title']); | ||
| // Calculate menutype. The number of characters allowed is 24. | ||
| $type = JHtmlString::truncate($menu['title'], 23, true, false); | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please do not direct call a JHtml method.  JHtml::_('string.truncate', $menu['title'], 23, true, false);
| The hardcoding of aliases really seems more like a hack than a practical fix... | 
| 
 | 
| @mbabker @Bakual For categories, we have no counter and I do not know how to add one. We have only 2 categories. | 
| My concern isn't so much the fact we need changes (nobody's perfect), rather at a glance it seems like the way some things are handled seems more like a low level hack to work around an issue than actually fixing an issue (and we have a bad history of taking the low level hacks and not coming back to fix the deeper issue). | 
| The problem is that we have many languages using non-latin glyphs. Will change the alias for articles to @Bakual proposal. Not a big deal. | 
| 
 For categories and menuitems we could hardcode a number instead of the counter. Eg take the number that is already in the title language constant. | 
| 
 If we wanted to fix this in the stringUrlSafe method, we could add miliseconds to its fallback string generation. That could work as I doubt we add multiple articles in the same milisecond 😄 | 
| Forget those comments about the datetime stuff. I somehow wrongly assumed that is generated by the stringUrlSafe method. But it's done by the table. We could of course also add something like that. | 
| would not hardcoding a number be similar to hardcoding the more informative text i used? i mean as 'hacky' ? | 
| I have tested this item ✅ successfully on 88daa64 This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/17930. | 
| 
 It at least separates the text from code and still allows for translated alias. But yeah, it still is a bit of a hack. If we wanted to do a real fix, we would have to change the lines in the tables and return miliseconds instead of just seconds there. That would work. Not sure if it's worth it. | 
| In this last commit, I took off ALL hardcoded stuff and forced using unicodeslugs aliases temporarily when the language is not using latin glyphs (idea from @imanickam ). below examples in multilang Example of url obtained when clicking on an article title link from the blog category @mbabker Please test again. | 
| I have tested this item ✅ successfully on cca4fef (a) Install of Sample Data using the Sample Data Plugin in English (en-GB) - The back-end language was English - Mono lingual site This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/17930. | 
| @Bakual @AlexRed This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/17930. | 
| I have tested this item ✅ successfully on cca4fef This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/17930. | 
| RTC after two successful tests. | 
        
          
                plugins/sampledata/blog/blog.php
              
                Outdated
          
        
      | // Set unicodeslugs if alias is empty | ||
| if (trim(str_replace('-', '', $alias) == '')) | ||
| { | ||
| JFactory::getConfig()->set('unicodeslugs', 1); | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably reset this to whatever value it was beforehand. Right now this causes a side effect of changing the setting for everything that happens after this call.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be limited to the method concerned?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean limited to the method
Adding
$unicode = JFactory::getConfig()->get('unicodeslugs', 1);
And at the end of the method
JFactory::getConfig()->set('unicodeslugs', $unicode);
And this for each method?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There shouldn't be anything happening after that code which could produce any side effects. Only the AJAX response is left to be done by com_ajax.
But yeah, better safe than sorry 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Anytime you're making a configuration change if it's supposed to be temporary to work around an issue it should be immediately reverted to the state it was before just to make sure nothing unexpected happens.  As this one specifically is the first conditional hit in this step, if the configuration is changed then as is everything calling stringURLSafe afterwards (or anything relying on the unicodeslugs param) is arbitrarily left with unicodeslugs = 1.  Granted, the chances of this particular thing causing side effects is low, it is best practice to always reset a temporary change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will modify asap. I had tested though that after this temporary change, the real value is not changed in configuration.php when the script has finished running.
| OK now? | 



Pull Request for Issue #17917
Thanks @imanickam for your findings
Issues
The sample data blog can't work with languages using non latin glyphs because aliases are set to the same time stamp for all aliases and menutype is empty in that case.
This is due to the use of
JApplicationHelper::stringURLSafe()The
menutypecan use non latin glyphs but can't work for some languages because it should be limited to 24 characters in the db and it is defined in the existing code using the title which may be longer in the ini file.The
catidis hard coded as['9']although it should use the correct catid depending on the sample data blog installed.This is specially true when installing multiple sample data blogs in a multingual site (after switching admin language).
Changes in this PR
Truncating menutypes and not using
JApplicationHelper::stringURLSafe()as it is not anyway necessary there. Adding numbering.Hardcoding categories aliases to cope with the time stamp.
Hardcoding aliases for menu items to cope with the time stamp.
Adding numbering and default
sampleto articles aliases to make sure each alias is different including with non latin glyphs titles.Testing instructions.
This should be tested on a monolanguage site as well as on a multilingual site.
Monolanguage site:
Install the Tamil language pack on a clean installation of staging with no sample data.
ta-IN_joomla_lang_full_3.8.0v1.zip
Switch to Tamil and in the Control panel, install the sample data blog
Reinstall a clean site in the same conditions and check all is OK too with this French pack
fr-FR_joomla_lang_full_3.8.0v1.zip
Multilingual site:
Install a clean staging as multilingual. At time of installation, install both 3.7.5 Tamil and French language packs. Set Multilang to yes with content.
In admin, install the 2 packs above to update Tamil and French to 3.8.0.1
Switch languages in back-end and each time, install sample data for these languages (English too if desired).
Verify that both Oldest Posts modules and Mostly Read Posts are correctly set to use the Blog category in their languages.
Load frontend and switch languages. Check that all is fine.
We will now have a correctly functionning sample data blog.
IMHO this should go into 3.8.0
@imanickam
@Bakual
@mbabker