Skip to content
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

array_column broken in PHP 7.0.32, breaks services/Plugins.php #3453

Closed
khalwat opened this issue Nov 8, 2018 · 5 comments
Closed

array_column broken in PHP 7.0.32, breaks services/Plugins.php #3453

khalwat opened this issue Nov 8, 2018 · 5 comments

Comments

@khalwat
Copy link
Contributor

khalwat commented Nov 8, 2018

Description

As part of services/Plugins.php, it does the following:

        // Sort plugins by their names
        $names = array_column($this->_plugins, 'name');
        array_multisort($names, SORT_NATURAL | SORT_FLAG_CASE, $this->_plugins);

https://github.com/craftcms/cms/blob/develop/src/services/Plugins.php#L236

array_column() is apparently broken on PHP 7.0.32, and possibly earlier, since the change list for PHP 7.0.32 is pretty sparse: http://php.net/ChangeLog-7.php

It just returns an empty array here, which then causes array_multisort() to throw an exception, since the arrays of of a different length.

@engram-design wrote this alternate code, which causes it to work fine:

// Sort plugins by their names
$names = [];
foreach ($this->_plugins as $plugin) {
   $names[] = $plugin->name;
}

Steps to reproduce

@engram-design narrowed it down to a simple test case:

$class = new \stdClass();
$class->name = 'Test';
var_dump($class);

$names = array_column([$class], 'name');
var_dump($names);

// Produces:
object(stdClass)#769 (1) { ["name"]=> string(4) "Test" }
array(0) { }

Additional info

  • Craft version: 3.0.30.1
  • PHP version: 7.0.32

Submitted PHP bug: https://bugs.php.net/bug.php?id=77119

@engram-design
Copy link
Contributor

See also https://bugs.php.net/bug.php?id=77119

@marionnewlevant
Copy link

Exactly the same thing was happening to me, but it has also mysteriously stopped. I think something was done to the php install, but I'm not sure what. It is still reporting 7.0.32

@brandonkelly
Copy link
Member

We just released 3.0.30.2 with a fix for this.

@djAjax
Copy link

djAjax commented Feb 1, 2019

The same issue in PHP 7.0.33

@brandonkelly
Copy link
Member

@djAjax where? the particular array_column() call this issue is about has been updated. Can you post a new issue, and include a stack trace pulled from your log files in storage/logs/?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants