Skip to content

Commit

Permalink
Be sure $array is an array to avoid errors in the log
Browse files Browse the repository at this point in the history
Signed-off-by: emanuele <emanuele45@gmail.com>
  • Loading branch information
emanuele45 committed Aug 23, 2015
1 parent d1976d6 commit 9a5be41
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions sources/ext/bad-behavior/badbehavior-plugin.php
Expand Up @@ -220,6 +220,9 @@ function bb2_insert($settings, $package, $key)
*/
function bb2_multi_implode($array, $glue = ',', $trim_all = false)
{
if (!is_array($array))
$array = array($array);

foreach ($array as $key => $value)
{
if (is_array($value))
Expand Down

5 comments on commit 9a5be41

@joshuaadickerson
Copy link
Contributor

Choose a reason for hiding this comment

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

When is it not an array?

@emanuele45
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The first time it is called from the outside. It may happen.

@joshuaadickerson
Copy link
Contributor

Choose a reason for hiding this comment

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

Prone to error. We should keep away from this and move to type hint... in the future

@emanuele45
Copy link
Contributor Author

Choose a reason for hiding this comment

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

But type hinting returns an error and wouldn't be much different from not having the is_array check.

@joshuaadickerson
Copy link
Contributor

@joshuaadickerson joshuaadickerson commented on 9a5be41 Sep 16, 2015 via email

Choose a reason for hiding this comment

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

Please sign in to comment.