User tests: Successful: Unsuccessful:
Pull Request for Issue #15494.
use cache instead of query everytime the available languages
see #15494
reduce the number of duplicate query
unnecessary duplicate query for get languages
reduced this one only
#15494 (comment)
Status | New | ⇒ | Pending |
Category | ⇒ | Administration com_associations |
Labels |
Added:
?
|
yes matter for another PR.....
i'll fix the cs glitch....
hope cs fixed now
hi guys, just stoped by to say: why not reuse the already available method in the library
Joomla\CMS\Language\LanguageHelper::getContentLanguages($checkPublished = true, $checkInstalled = true, $pivot = 'lang_code', $orderField = null, $orderDirection = null)
See https://github.com/joomla/joomla-cms/blob/staging/libraries/src/Language/LanguageHelper.php#L336
wellcome back @andrepereiradasilva , we are missing you ,
i'll investigate further your suggestion, i hope in the week-end....
applyed the tips from @andrepereiradasilva
please re-test
I have tested this item
Changed my test to unsuccessful.
I get an error
Call to undefined method AssociationsHelper::getContentLanguages()
when trying to load the side to side page
Silly me, I'll do the needed change later sorry
Il 11 nov 2017 9:45 AM, "infograf768" notifications@github.com ha scritto:
Changed my test to unsuccessful.
I get an error
Call to undefined method AssociationsHelper::getContentLanguages()
when trying to load the face to face page—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#18544 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AALFsfJnFDGi1WH53fV_Sn6pPveR-M7bks5s1V6PgaJpZM4QYkba
.
re-re-test please
I have tested this item
Perfect this time.
perfection is my current challenge, unfortunately i already know that i cant win
@alikon can you please give Test Instructions?
I have tested this item
Thanks for Instructions @alikon
Status | Pending | ⇒ | Ready to Commit |
RTC after two successful tests.
Just want to point out that there is difference between the data returned by old code and new code. With the original code, all content languages (including unpublished) will be returned, with new code, only published content languages will be returned
Also, if we decide to use new code, I think it is better to call the new method directly instead of still calling AssociationsHelper::getContentLanguages (because this method is now basically, an alias of LanguageHelper::getContentLanguages() )
Status | Ready to Commit | ⇒ | Pending |
You are totally correct. I take off RTC.
We should be able to prepare a new Content Language but not put it online until Published.
With this patch, it is now impossible to do anything for such a content language in com_associations.
In fact I guess the solution is easy
return LanguageHelper::getContentLanguages(false, true);
is enough.
applyed the tips from @joomdonation
I have tested this item
Works fine now even if the Content Language is unpublished.
Only drawback is that it also proposes those which are in the Trash.
That case is not taken care of in LanguageHelper::getContentLanguages()
@infograf768 reggarding the trashed language, true. the language helper method could be improved (while preserving B/C).
Something like this. Not tested. Replaced $checkPublished (boolean) argument for $publishedStates (array) and using a B/C layer for that parameter.
/**
* Get a list of content languages.
*
* @param array $publishedStates Array with the content language published states. Null or empty array for all.
* @param boolean $checkInstalled Check if the content language is installed.
* @param string $pivot The pivot of the returning array.
* @param string $orderField Field to order the results.
* @param string $orderDirection Direction to order the results.
*
* @return array Array of the content languages.
*
* @since 3.7.0
*/
public static function getContentLanguages($publishedStates = array(1), $checkInstalled = true, $pivot = 'lang_code', $orderField = null, $orderDirection = null)
{
// B/C layer. Before __DEPLOY_VERSION__.
if ($publishedStates === true)
{
$publishedStates = array(1);
}
elseif ($publishedStates === false)
{
$publishedStates = null;
}
// [code removed for brevity...]
// Check if the language is published, if needed.
if ($publishedStates !== null && $publishedStates !== array())
{
foreach ($languages as $key => $language)
{
if (in_array((int) $language->published, $publishedStates, true) === false)
{
unset($languages[$key]);
}
}
}
// [code removed for brevity...]
}
then, for published/unpublished, you could call it like this
LanguageHelper::getContentLanguages(array(0, 1), true);
BTW @alikon unless things changed recently i don't think it's B/C to completly remove a public method in 3.x, you should proxy it to languagehelper method and them put a deprecated 4.0 message.
Category | Administration com_associations | ⇒ | Administration com_associations Libraries |
managed the trashed lanugages
Works here
@alikon If I am not mistaken, the changes you made to \Joomla\CMS\Language\LanguageHelper::getContentLanguages() will cause B/C issue. Before the change, if someone calls \Joomla\CMS\Language\LanguageHelper::getContentLanguages() , the result will include trashed content languages. After your changes, it won't include trashed content languages anymore.
I think the propose change from @andrepereiradasilva is better. It extends the method to allow us to get content languages we want based on passed publish states. I made a PR to your branch alikon#38, please review it and if you agree, merge it so that we can have this issue sorted.
thanks folks for teamworking, hope now issues are solved in a B/C way
I have tested this item
TBH, folks, I see absolutely no reason why anyone would list Trashed Content Languages.
In this case, but also everywhere else in J where we use the method.
I have tested this item
@infograf768 can you please retest?
I have tested this item
Status | Pending | ⇒ | Ready to Commit |
RTC. Thanks to all.
Status | Ready to Commit | ⇒ | Fixed in Code Base |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2017-11-18 15:49:11 |
Closed_By | ⇒ | mbabker | |
Labels |
Added:
?
|
I would suggest this for
getContentLanguages()
.