RTC Release Blocker bug PR-5.1-dev Pending

User tests: Successful: Unsuccessful:

avatar richard67
richard67
9 Mar 2024

Pull Request for Issue #42971 (part).

Summary of Changes

When updating from 5.1.0-alpha4 or any older 5.1.0-alpha or 5.0.x or 4.4.x, the update SQL script "5.1.0-2024-02-24.sql" is run, which migrates the Joomla core update site to TUF, see pull request (PR) #42799 .

The update SQL script creates a new table and does an INSERT statement on that table, then it does an UPDATE statement on the #__update_sites table.

Both statements INSERT and UPDATE contain the same subquery to get the update_site_id.

If that subquery returns more than 1 row, which can happen if there is more than 1 update site for the Joomla core, the INSERT will insert one record for each of these update sites.

But the UPDATE statement will fail with an SQL error no. 1242 "Subquery returns more than 1 row" on MySQL/MariaDB or "more than one row returned by a subquery used as an expression" on PostgreSQL.

This PR here fixes that by using the IN instead of the = operator so the UPDATE statement will update all rows returned by the subquery.

Testing Instructions

Pre-conditions

The test can be executed in a tool like e.g. phpMyAdmin for MySQL or MariaDB or phpPgAdmin for PostgreSQL databases.

It just needs a database with a recent Joomla 5.1 or 5.0.x or 4.4.x installation.

In all SQL statements in the following steps, replace the #__ in all table names by your actual database prefix including the underscore.

Step 1: Prepare a 2nd update site for the Joomla core.

You should of course not do that on a production site, and if you want to continue to use the site you should clean up the new records created by this step in the #__update_sites and the #__update_sites_extensions table after the test.

With MySQL or MariaDB:

INSERT INTO `#__update_sites` (`name`, `type`, `location`, `enabled`, `last_check_timestamp`) VALUES
('Test duplicate', 'collection', 'https://update.joomla.org/core/list.xml', 0, 0);

INSERT INTO `#__update_sites_extensions` (`update_site_id`, `extension_id`)
SELECT u.`update_site_id`, e.`extension_id`
  FROM (SELECT MAX(`update_site_id`) AS `update_site_id` FROM `#__update_sites`) AS u
  JOIN `#__extensions` AS e
 WHERE e.`type`='file' AND e.`element`='joomla';

With PostgreSQL:

INSERT INTO "#__update_sites" ("name", "type", "location", "enabled", "last_check_timestamp") VALUES
('Test duplicate', 'collection', 'https://update.joomla.org/core/list.xml', 0, 0);

INSERT INTO "#__update_sites_extensions" ("update_site_id", "extension_id")
SELECT u."update_site_id", e."extension_id"
  FROM (SELECT MAX("update_site_id") AS "update_site_id" FROM "#__update_sites") AS u
  JOIN "#__extensions" AS e ON 1=1
 WHERE e."type"='file' AND e."element"='joomla';

Step 2: Run the UPDATE statement of the unmodified update SQL script "5.1.0-2024-02-24.sql"

With MySQL or MariaDB see https://github.com/joomla/joomla-cms/blob/5.1-dev/administrator/components/com_admin/sql/updates/mysql/5.1.0-2024-02-24.sql#L21-L23

With PostgreSQL see https://github.com/joomla/joomla-cms/blob/5.1-dev/administrator/components/com_admin/sql/updates/postgresql/5.1.0-2024-02-24.sql#L21-L23

Result: See section "Actual result BEFORE applying this Pull Request" below.

Step 3: Run the UPDATE statement of the update SQL script "5.1.0-2024-02-24.sql" from this PR

With MySQL or MariaDB see

UPDATE `#__update_sites`
SET `type` = 'tuf', `location` = 'https://update.joomla.org/cms/'
WHERE `update_site_id` IN (SELECT ue.`update_site_id` FROM `#__update_sites_extensions` AS ue JOIN `#__extensions` AS e ON (e.`extension_id` = ue.`extension_id`) WHERE e.`type`='file' AND e.`element`='joomla');

With PostgreSQL see

UPDATE "#__update_sites"
SET "type" = 'tuf', "location" = 'https://update.joomla.org/cms/'
WHERE "update_site_id" IN (SELECT ue."update_site_id" FROM "#__update_sites_extensions" AS ue JOIN "#__extensions" AS e ON (e."extension_id" = ue."extension_id") WHERE e."type"='file' AND e."element"='joomla');

... or just replace the first = by IN in the WHEREclause of the UPDATE statement from the previous step 2.

Result: See section "Expected result AFTER applying this Pull Request" below.

Actual result BEFORE applying this Pull Request

With MySQL or MariaDB SQL error #1242 Subquery returns more than 1 row, with PostgreSQL ERROR: more than one row returned by a subquery used as an expression.

Expected result AFTER applying this Pull Request

Both update sites are updated by the UPDATE statement.

Link to documentations

Please select:

  • No documentation changes for docs.joomla.org needed

  • No documentation changes for manual.joomla.org needed

avatar richard67 richard67 - open - 9 Mar 2024
avatar richard67 richard67 - change - 9 Mar 2024
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 9 Mar 2024
Category SQL Administration com_admin Postgresql
avatar richard67 richard67 - change - 9 Mar 2024
Labels Added: PR-5.1-dev
avatar richard67 richard67 - change - 9 Mar 2024
The description was changed
avatar richard67 richard67 - edited - 9 Mar 2024
avatar richard67 richard67 - change - 9 Mar 2024
The description was changed
avatar richard67 richard67 - edited - 9 Mar 2024
avatar richard67 richard67 - change - 9 Mar 2024
The description was changed
avatar richard67 richard67 - edited - 9 Mar 2024
avatar richard67 richard67 - change - 9 Mar 2024
The description was changed
avatar richard67 richard67 - edited - 9 Mar 2024
avatar richard67 richard67 - change - 9 Mar 2024
The description was changed
avatar richard67 richard67 - edited - 9 Mar 2024
avatar richard67 richard67 - change - 9 Mar 2024
The description was changed
avatar richard67 richard67 - edited - 9 Mar 2024
avatar alikon alikon - test_item - 9 Mar 2024 - Tested successfully
avatar alikon
alikon - comment - 9 Mar 2024

I have tested this item ✅ successfully on 6988fcd


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/42988.

avatar viocassel viocassel - test_item - 9 Mar 2024 - Tested successfully
avatar viocassel
viocassel - comment - 9 Mar 2024

I have tested this item ✅ successfully on 6988fcd


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/42988.

avatar richard67 richard67 - change - 9 Mar 2024
Status Pending Ready to Commit
avatar richard67
richard67 - comment - 9 Mar 2024

RTC


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/42988.

avatar bembelimen bembelimen - change - 10 Mar 2024
Status Ready to Commit Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2024-03-10 02:52:39
Closed_By bembelimen
Labels Added: RTC Release Blocker bug
avatar bembelimen bembelimen - close - 10 Mar 2024
avatar bembelimen bembelimen - merge - 10 Mar 2024
avatar bembelimen
bembelimen - comment - 10 Mar 2024

Thx

Add a Comment

Login with GitHub to post a comment