Problem/Motivation
Calling EntityEmbedDisplayManager::getDefinitionOptionsForEntityType() on PHP 8.1 triggers a deprecation:
Deprecated function: strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated
Drupal\Component\Plugin\PluginBase->getDerivativeId()() (Line: 83)
This happens because in FieldFormatterEntityEmbedDisplayBase's __contruct method EntityEmbedDisplayBase::setConfiguration() is called, and that method call then invokes FieldFormatterEntityEmbedDisplayBase::defaultConfiguration() before the plugin ID was set.
Steps to reproduce
E.g. execute Entity Embed tests on PHP 8.1.
Proposed resolution
In the constructor, set the the plugin ID manually before setConfiguration is invoked.
Remaining tasks
TBD.
User interface changes
Nothing!
API changes
Nothing!
Data model changes
Nothing!
Comments
Comment #2
huzookaComment #5
huzookaLet's use a test png with valid profile!
Comment #6
huzookaWe're expecting the same test failure what HEAD has at https://www.drupal.org/node/2239435/qa
Comment #7
huzookaComment #9
huzookaCoding standard violation is a preexisting thing, test failure is the same as on HEAD.
Comment #10
wim leersOhhhh — clever way to avoid file path futzing: by just using a file used by core! :D
Comment #13
dave reidI've gone through fixing the branch tests to all passing now. I think we can also avoid needing to use __construct() for all these plugins because it's better to just override create(). We can also just add a formatterPluginManager() method that will always return the service even if it hasn't been injected yet. Going to test against PHP 8.1 to see if that resolves the failures.
Comment #14
huzooka@Dave Reid, thank you for pushing this forward!
Comment #16
dave reidMerged the above, confirmed passing tests on PHP 8.1 into 8.x-1.x. Thanks!