?
Referenced as Pull Request for: # 6026
avatar bassmanpaul
bassmanpaul
6 Feb 2015

I experienced a scenario where I was testing an install package (which was corrupt) and it brought to light a couple of PHP notices in the JInstallerHelper class.

The File:

libraries/cms/installer/helper.php line 197 & 221

Issue 1 (line 197):

$dirList = array_merge(JFolder::files($extractdir, ''), JFolder::folders($extractdir, ''));

As JFolder::files() & JFolder::folders() can return false which would break array_merge(). One solution would be type casting:

$dirList = array_merge((array)JFolder::files($extractdir, ''), (array)JFolder::folders($extractdir, ''));

Issue 2 (line 221):

if (!count($files))

Again JFolder::files() could return false so the count() of false would be 1 as opposed to 0. (see: http://php.net/manual/en/function.count.php#example-5167) Therefore as this is a false positive may I suggest something like:

if (!$files || !count($files))

or

if (!is_array($files) || !count($files))

If everyone likes the suggestions I will happily create a Pull Request.

avatar bassmanpaul bassmanpaul - open - 6 Feb 2015
avatar wilsonge
wilsonge - comment - 7 Feb 2015

A PR would be awesome thanks! Awesome spot!

avatar brianteeman brianteeman - change - 7 Feb 2015
Labels Added: ?
avatar zero-24
zero-24 - comment - 8 Feb 2015

@bassmanpaul can you add a PR with that changes? Here is a simple step by step guide how to do it: https://docs.joomla.org/Using_the_Github_UI_to_Make_Pull_Requests

avatar bassmanpaul bassmanpaul - reference | - 9 Feb 15
avatar bassmanpaul
bassmanpaul - comment - 9 Feb 2015

Done:

#6026

avatar zero-24 zero-24 - change - 9 Feb 2015
Status New Closed
Closed_Date 0000-00-00 00:00:00 2015-02-09 16:48:31
Closed_By zero-24
avatar joomla-cms-bot
joomla-cms-bot - comment - 9 Feb 2015

Set to "closed" on behalf of @zero-24 by The JTracker Application at issues.joomla.org/joomla-cms/6000

avatar joomla-cms-bot joomla-cms-bot - close - 9 Feb 2015
avatar zero-24
zero-24 - comment - 9 Feb 2015

Closing as we have a PR thanks @bassmanpaul


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/6000.
avatar joomla-cms-bot joomla-cms-bot - close - 9 Feb 2015

Add a Comment

Login with GitHub to post a comment