Page MenuHomeDevCentral

Ensure Notifications Center CI jobs run smoothly in PHP 8.1
Closed, ResolvedPublic

Description

rNOTIF is being upgraded to run under PHP 8.1 and recent Laravel version.

As such, CI should cope with those modernized tools.

Event Timeline

dereckson renamed this task from Ensure test-notifications-phab run smoothly in PHP 8.1 to Ensure Notifications Center CI jobs run smoothly in PHP 8.1 .May 8 2022, 15:07
dereckson claimed this task.
dereckson triaged this task as High priority.
dereckson created this task.

phpDox isn't currently compatible with PHP 8.1. Deprecations are transformed into fatal errors, even if at the start an error_reporting() instruction is left.

As a workaround, here phpDox 0.12.0-27-geb943cb-dirty, with PHP 8.1 deprecation notices for signatures mismatch addressed.

Some have been reported upstream, but as the phpDox dependencies inherit PHP builtin classes to override signatures, e.g. transforming a string|bool into a string, throwing an exception instead of returning false, perhaps upstream will adopt another approach than use false signatures.

It has been manually deployed on WindRiver and Zateki (Jenkins agent for CI, PHP 8 flavour).

Still some issues with phpdox at https://ci.nasqueron.org/job/test-notifications-php/222/console (job triggered after commit is published to GitHub):

[phpdox] [21.05.2022 - 20:03:31] The following file(s) had errors during processing and were excluded:
[phpdox] [21.05.2022 - 20:03:31]  - /home/app/workspace/test-notifications-php/app/Analyzers/Jenkins/JenkinsPayloadAnalyzer.php (Undefined array key 403 [Lexer.php:323])
[phpdox] [21.05.2022 - 20:03:31] Saving results to directory '/home/app/workspace/test-notifications-php/build/phpdox'
[phpdox] [21.05.2022 - 20:03:31] Resolving inheritance

[phpdox] ErrorException: E_DEPRECATED 
[phpdox] Location: /opt/phpdox/vendor/theseer/fdomdocument/src/fDOMElement.php (Line 276)
[phpdox] 
[phpdox] DOMElement::setAttribute(): Passing null to parameter #2 ($value) of type string is deprecated

For the test-notifications-php job, the builds fail because some tests are skipped.

3 tests are marked as incomplete, which isn't acceptable for the current plugin config.

INFO: The total number of tests for the threshold 'Skipped Tests' exceeds the specified "failure threshold" value.
INFO: Setting the build status to FAILURE
Build step 'Publish xUnit test result report' changed build result to FAILURE

Configuration in Jenkins UI:

image.png (377×1 px, 36 KB)

Issue reported for threshold solved.

Lexer.php 403 key issue still to solve, but not breaking the build.

phpDox isn't currently compatible with PHP 8.1. Deprecations are transformed into fatal errors, even if at the start an error_reporting() instruction is left.

As a workaround, here phpDox 0.12.0-27-geb943cb-dirty, with PHP 8.1 deprecation notices for signatures mismatch addressed.

Some have been reported upstream, but as the phpDox dependencies inherit PHP builtin classes to override signatures, e.g. transforming a string|bool into a string, throwing an exception instead of returning false, perhaps upstream will adopt another approach than use false signatures.

It has been manually deployed on WindRiver and Zateki (Jenkins agent for CI, PHP 8 flavour).

PHP 8.2 introduced a new bunch of deprecations, and sometimes, we need to update Jenkins PHP agents images, so a manual fix isn't desired.

Meanwhile, in November 2022, maintainer stated intent to improve the situation, without any time frame estimate.

As such, best course of action seems to prepare a temporary phpdox fork to use on our CI infrastructure.
Plan is to maintain it as long as needed, ie until we don't use phpdox (we don't have plan not to use it) or upstream makes it compatible with PHP 8.

For reference, the fork has been prepared like this:

  1. Clone phpdox
  2. Commit PHP 8.1 fixes from the archive
  3. Clone fDOMDocument, mkdir lib/fDOMDocument and git mv * lib/fDOMDocument/
  4. Define a new remote for fDOMDocument, fetch it
  5. Merge unrelated history, so we've a lib/ folder with it, with history fully preserved (no rewrite to do the git mv but a specific commit allows to avoid to lost hashes)
  6. Clean fDOMocument tags
  7. Apply PHP 8.1 fixes for fDOMocument (this commit is suspect for the (libxml_get_last_error())->message in exception removal, I think code has been committed afterwards)
  8. Apply PHP 8.2 fixes
  9. Release a new number 0.13.0 to get an unofficial bumped semver release version