Problem/Motivation

On PHP 8.5, PHPStan reported two errors in modules/mongodb_storage/tests/src/Kernel/QueueTest.php, the only ones left in the phpstan (max PHP version) CI job after #3542043: Allow compatibility with `ext-mongodb` version 2.0 and #3458044: [PHP 8.4] Fix implicitly nullable type declarations:

  • tearDown() called unset($this->queueFactory): "Cannot unset property ... because it might have hooks in a subclass" (unset.possiblyHookedProperty, from PHP 8.4 property hooks).
  • $rm->setAccessible(TRUE) is deprecated in PHP 8.5, and has had no effect since PHP 8.1.

Fixing them showed the static analysis could go much further, and working through it surfaced several real defects, so the scope grew beyond those two lines. #3626739: Fix test flakiness depends on this issue landing first.

Proposed resolution

Implemented in the MR:

  • PHP 8.5: the two QueueTest errors above.
  • Static analysis: PHPStan passes up to level 6, on Drupal 10 as on Drupal 11, and every PHP file declares strict types. The configuration moves to phpstan.neon.dist, which the CI templates detect. PHPMD annotations are dropped, PHPMD being obsolete.
  • Development dependencies: drupal/core-dev and the CI templates provide PHPUnit, Prophecy and PHP_CodeSniffer, so each core version gets matching ones. Only Drush stays, as ^14 || ^13.8.0 || ^12.5.3, since the module ships Drush commands. This lets the next major composer job resolve.
  • Library version: libraryApiVersion() reports the installed mongodb/mongodb version. countCollection() is deprecated in 8.x-2.2 and removed from 8.x-2.3: see the change record.
  • Queues fed by other applications: in enterprise integration, other applications may insert items directly into a queue collection.
    • Claims now also match items without expires, and store a missing created once, from an ObjectId _id or else the claim time, so that releasing and claiming again never changes it.
    • releaseItem() and deleteItem() use the stored _id: they used to rebuild an ObjectId, which failed for any other _id type.
    • The documents such producers must write are documented in docs/modules/mongodb_storage.md. The payload stays PHP-serialized.
  • releaseItem() results: tests pin that it returns TRUE only for a claimed item, like core's Memory queue, and the docs compare it with other backends, following the comparison in #3626967: Evaluate implementing DelayableQueueInterface.
  • Queues accept any TimeInterface service, not only core's Time class.
  • Watchdog: the overview filter uses the request session instead of writing $_SESSION directly, deprecated in Drupal 11.2 and unsupported in Drupal 12.

Remaining tasks

User interface changes

None.

API changes

  • countCollection() is deprecated.
  • Item::fromDoc() is marked @internal, and throws on a document lacking _id, created or expires. Item::mongoId() is new.
  • Queue::claimItem() returns Item|false, and Queue and QueueFactory take a TimeInterface.

Data model changes

None for items created by Drupal. Items from other producers get created and expires stored at their first claim.

AI disclosure

This issue and MR are prepared with AI assistance.

Issue fork mongodb-3626726

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

fgm created an issue. See original summary.

fgm’s picture

Issue summary: View changes

fgm’s picture

Issue summary: View changes
Status: Active » Needs review
Related issues: +#3626739: Fix test flakiness, +#3626729: Drupal 12 pre-release compatibility

  • fgm committed 61e2541b on 8.x-2.x
    feat: #3626726 Ensure PHP 8.5 compatibility
    
    * PHP 8.5 compatibility
    *...
fgm’s picture

Status: Needs review » Fixed

Merged in today's HEAD.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.