Problem/Motivation
When using PHP 8.1 the following warning is displayed:
Deprecated function: Automatic conversion of false to array is deprecated in Drupal\metatag\Plugin\Field\FieldWidget\MetatagFirehose->formElement() (line 156 of modules/contrib/metatag/src/Plugin/Field/FieldWidget/MetatagFirehose.php).
Drupal\metatag\Plugin\Field\FieldWidget\MetatagFirehose->formElement(Object, 0, Array, Array, Object) (Line: 353)
Drupal\Core\Field\WidgetBase->formSingleElement(Object, 0, Array, Array, Object) (Line: 220)
Drupal\Core\Field\WidgetBase->formMultipleElements(Object, Array, Object) (Line: 111)
Drupal\Core\Field\WidgetBase->form(Object, Array, Object) (Line: 181)
Steps to reproduce
Not 100% sure of the case, it seems like somehow the item value contains invalid serialized data, which when unserialize is used FALSE is returned. Then when we are adding to $values[] later on this PHP warning is called.
Proposed resolution
Make sure that $values remains an array even upon unserialize() failing.
Comments
Comment #2
3liComment #3
damienmckennaThanks for reporting this bug and providing a patch.
How about always making sure that $values is always an array?
Comment #5
damienmckennaBetter comments. Also, the last test run shouldn't have failed.
Comment #6
damienmckennaComment #8
damienmckennaCommitted. Thank you!
Comment #10
klemendev commentedIt does not seem this fix was included in https://www.drupal.org/project/metatag/releases/8.x-1.22, was it?
Comment #11
damienmckennaThe change is still visible in the 8.x-1.22 codebase. If you are experiencing this problem please open a new issue so additional instances of this bug can be tracked down.
Comment #12
klemendev commentedI have checked and the change indeed is in 1.22. I was just asking because this change was not in the changelog/release notes of the release.