Problem/Motivation
Sporadically we get the following warning:
Warning: uasort(): Array was modified by the user comparison function in Drupal\Core\Plugin\DefaultLazyPluginCollection->sort() (line 100 of core/lib/Drupal/Core/Plugin/DefaultLazyPluginCollection.php).
A 100% repo is to use the "Entity Browser Module" when using a file field (in our case inside a field collection) with the File Browser widget.
Proposed resolution
According to this link:
http://shout.setfive.com/2013/06/14/symfony2-usort-array-was-modified-by...
The problem lies in the lazy loading of the plugin collection. So the fix is simple. In the sort() function (DefaultLazyLoadingPluginCollection) iterate through the array like this:
public function sort() {
// iterate to populatae the array
foreach($this->instanceIDs as $id){
$pluginId = $this->get($id)->getPluginId();
}
// original code
uasort($this->instanceIDs, array($this, 'sortHelper'));
return $this;
}
Remaining tasks
reviews needed, tests to be written and run
User interface changes
none
API changes
none
Data model changes
none
Original report by [username]
none