Problem/Motivation
When upgrading a Drupal 8 site to Drupal 9, and running drush updatedb, I got this error:
Unable to decode output into JSON: Syntax error
Fatal error: Declaration of Drupal\search_api\Processor\ConfigurablePropertyBase::setConfiguration(?array $c
onfiguration): Drupal\search_api\Processor\ConfigurablePropertyBase must be compatible with Drupal\search_ap
i\Processor\ConfigurablePropertyInterface::setConfiguration(?array $configuration): Drupal\search_api\Proces
sor\ConfigurablePropertyInterface in /........./web/modules/contrib/search_api/src/Processor/Con
figurablePropertyBase.php on line 11
Proposed resolution
I was able to get the updates to run by changing:
public function setConfiguration(?array $configuration): self;
to
public function setConfiguration(?array $configuration);
Not a PHP expert (still learning as a front-ender), so no idea why this works, just figured I'd share. Not sure if the issue was with Drush, my Drupal codebase, or this module.
Comments
Comment #2
drunken monkeyThanks a lot for reporting this problem!
The attached patch should fix this. It seems we weren’t careful in our code to still keep compatible with PHP 7.3, the oldest version we officially support.
Please test/review!
However, the correct fix for you would be to update to a newer version of PHP, if at all possible. PHP 7.3 has been unsupported for over a year now, so running it constitutes a security risk for your site.
Comment #5
keshavv commentedI have tested the patch, Confirmed that this will solve the issue.
I have created the MR, So it can be merge easily.
Comment #6
dalemoore commentedThanks. The updates were already performed so I don't know that I can test, but I applied the one-line fix and tried running updatedb and no errors.
Comment #8
drunken monkeyOK, the fix should be fine anyways. Still, thanks for providing feedback!
Committed.
PS: The error should probably also appear when navigating through the Search API admin UI. For instance, try adding a field to an index.