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()calledunset($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
QueueTesterrors 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-devand 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 installedmongodb/mongodbversion.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 missingcreatedonce, from an ObjectId_idor else the claim time, so that releasing and claiming again never changes it. releaseItem()anddeleteItem()use the stored_id: they used to rebuild an ObjectId, which failed for any other_idtype.- The documents such producers must write are documented in
docs/modules/mongodb_storage.md. The payload stays PHP-serialized.
- Claims now also match items without
releaseItem()results: tests pin that it returns TRUE only for a claimed item, like core'sMemoryqueue, and the docs compare it with other backends, following the comparison in #3626967: Evaluate implementing DelayableQueueInterface.- Queues accept any
TimeInterfaceservice, not only core'sTimeclass. - Watchdog: the overview filter uses the request session instead of writing
$_SESSIONdirectly, deprecated in Drupal 11.2 and unsupported in Drupal 12.
Remaining tasks
- Review and merge.
- The Drupal 12 items found on the way (PHPUnit attributes,
#[RunTestsInSeparateProcesses],#[LegacyRequirementsHook],RequirementSeverity,xpath()) belong to #3626729: Drupal 12 pre-release compatibility.
User interface changes
None.
API changes
countCollection()is deprecated.Item::fromDoc()is marked@internal, and throws on a document lacking_id,createdorexpires.Item::mongoId()is new.Queue::claimItem()returnsItem|false, andQueueandQueueFactorytake aTimeInterface.
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
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
Comment #2
fgmComment #4
fgmComment #6
fgmMerged in today's HEAD.