PHP 7.2 Compat - Fix count() uses#18438
Merged
rdeutz merged 1 commit intojoomla:stagingfrom Nov 30, 2017
mbabker:php72-countable
Merged
PHP 7.2 Compat - Fix count() uses#18438rdeutz merged 1 commit intojoomla:stagingfrom mbabker:php72-countable
rdeutz merged 1 commit intojoomla:stagingfrom
mbabker:php72-countable
Conversation
ggppdk
reviewed
Oct 30, 2017
| $categoryId = $this->getState('filter.category_id'); | ||
| $categoryId = $this->getState('filter.category_id', array()); | ||
| $level = $this->getState('filter.level'); | ||
|
|
Contributor
There was a problem hiding this comment.
hhmm my PR has added this PHP 7.2 issue
Just with the above default value 'array(),' if someone uses
index.php?option=com_content&view=articles&filter[category_id]=0
then we will get same warning,
so maybe better to replace the following code with
$categoryId = !is_array($categoryId)
? ($categoryId ? array($categoryId) : array())
: $categoryId;
Contributor
|
I have tested this item ✅ successfully on 26ee013 This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/18438. |
Contributor
|
I have tested this item ✅ successfully on ca74bf9 This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/18438. |
Contributor
|
I have tested this item ✅ successfully on ca74bf9 This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/18438. |
|
Ready to Commit after two successful tests. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary of Changes
PHP 7.2 disallows the use of the
count()function on non countable items (arrays or objects implementing theCountableinterface). We have places in our API where null values were being returned then pushed into acount()call, this PR addresses three uses found on a cursory click through a CMS install using PHP 7.2.0RC5.Testing Instructions
To verify:
Updater.phpfile by way of the plugin which checks for updates and sends an email notification triggering an update check. This is caused by properties in theCollectionAdapterclass not being initialized as empty arrays and therefore when no updates are found the properties are still set as null versus being array.com_contentarticles model. This is caused by a state value not setting an appropriate default if the state value is null.Apply the patch and repeat these steps.
(If you do not reinstall before item 1, you will need to clear the update check timestamps for the
plg_system_updatenotificationplugin params and the Joomla! Core update site).Expected result
Data is displayed without error.
Actual result
Errors as a result of trying to count a non-countable item.