- Issue created by @localgov
- π¬π§United Kingdom Finn Lewis
Sorry, that was me that reported the above, just logged in on the wrong account.
- Merge request !54Issue #3514975: Remove static declaration to avoid fatal php error. β (Open) created by Finn Lewis
- π©πͺGermany jurgenhaas Gottmadingen
I'm seeing the same issue and it breaks all our pipelines.
- π³π±Netherlands johnv
Thanks, committed. Will create a new release today.
- π³π±Netherlands johnv
A new version 1.25 is released.
Thanks for your fast and efficient testing process! - πΊπΈUnited States alfattal Minnesota
I'm getting the same fatal error in the latest version (1.26) released today.
- πΊπ¦Ukraine _shy Ukraine, Lutsk πΊπ¦
I'm also getting the same error just in another file, here -
\Drupal\office_hours\Plugin\Field\FieldType\OfficeHoursItemList
I prepared a quick patch for that fix. - π©πͺGermany harkonn
The fix looks good (again). We need another release please.
- π³π±Netherlands johnv
Strange, I cannot reproduce the error.
Is it dependent on a PHP version?
The patch loose the 'static' performatnce improvement.Will the following work for you , too?
public function createItem($offset = 0, $value = NULL) { $day = $value['day'] ?? NULL; static $plugin_type = 'field_type'; static $pluginManager = NULL; // Avoid PHP Fatal error: Constant expression contains invalid operations $pluginManager ??= \Drupal::service("plugin.manager.field.$plugin_type");
- π©πͺGermany harkonn
Hi @johnv. You are right, the PHP version seems to be the problem. I tested the original code on PHP 8.2 and i got the mentioned error in
OfficeHoursItemList
while installing office_hour via `drush en`.
As mentioned on php.net your original code should work with PHP 8.3+:Prior to PHP 8.3.0, static variables could only be initialized using a constant expression. As of PHP 8.3.0, dynamic expressions (e.g. function calls) are also allowed
I tested your suggested code and it fixes the problem for PHP 8.2 and keeps the variable being properly initialized. Looks good for me. Thank you :)
It looks to me like you dont work with merge-requests. Will you commit the code-change yourself?
- πΊπΈUnited States fholub13
+1 RTBC for MR 58
Using PHP 8.1 on Drupal 10.4.4.
- π³π±Netherlands johnv
Please test the dev version and report back. I wil create a new version afterwards.
- π©πͺGermany harkonn
I testet your commit on
drupal/office_hours:1.x-dev@dev
and it works on PHP 8.2. I switch to RTBC. Thank you.