Pending

User tests: Successful: Unsuccessful:

avatar ManoharPaturi
ManoharPaturi
4 Oct 2026

Pull Request resolves #

  • I read the Generative AI policy and my contribution is either not created with the help of AI or is compatible with the policy and GNU/GPL 2 or later.

Summary of Changes

MetadataManager::createRecordIfNonExisting() checks whether a session metadata record exists before inserting it. The guard compares against the wrong constant:

$exists = $this->checkSessionRecordExists($session->getId());

// Only touch the database if the record does not already exist
if ($exists !== self::$sessionRecordExists) {
    return;
}

With this comparison the method returns when no record was found and only attempts the insert when a record is already present, which is the opposite of both the method name and the comment above the guard. The insert for an existing record then fails on the primary key and the failure is swallowed, so in practice the method has never created anything.

This PR compares against self::$sessionRecordDoesNotExist instead, so the record is inserted when it is missing. When the state cannot be determined because the existence query failed, nothing is written, matching the conservative handling in createOrUpdateRecord().

The method currently has no callers in the core code base, so no behavioural change is expected anywhere in the CMS; it is public API of a class marked @internal and should behave as documented for any consumer. A unit test class is added covering the missing, existing and undetermined record states; two of the three cases fail against the previous guard.

Testing Instructions

Run the new unit tests:

libraries/vendor/bin/phpunit tests/Unit/Libraries/Cms/Session/MetadataManagerTest.php

Actual result BEFORE applying this Pull Request

createRecordIfNonExisting() inserts nothing when the metadata record is missing and attempts a duplicate insert when it already exists, which fails on the primary key.

Expected result AFTER applying this Pull Request

createRecordIfNonExisting() inserts the metadata record when it is missing, does nothing when it exists, and does nothing when the record state cannot be determined.

Link to documentations

  • No documentation changes for guide.joomla.org needed
  • No documentation changes for manual.joomla.org needed
avatar ManoharPaturi ManoharPaturi - open - 4 Oct 2026
avatar ManoharPaturi ManoharPaturi - change - 4 Oct 2026
Status New ⇒ Pending
avatar joomla-cms-bot joomla-cms-bot - change - 4 Oct 2026
Category ⇒ Libraries Unit Tests

Add a Comment

Login with GitHub to post a comment