User tests: Successful: Unsuccessful:
Pull Request for Issue #42971 (part).
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.
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.
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';
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.
UPDATE statement of the update SQL script "5.1.0-2024-02-24.sql" from this PRWith MySQL or MariaDB see
With PostgreSQL see
... 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.
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.
Both update sites are updated by the UPDATE statement.
Please select:
No documentation changes for docs.joomla.org needed
No documentation changes for manual.joomla.org needed
| Status | New | ⇒ | Pending |
| Category | ⇒ | SQL Administration com_admin Postgresql |
| Labels |
Added:
PR-5.1-dev
|
||
I have tested this item ✅ successfully on 6988fcd
| Status | Pending | ⇒ | Ready to Commit |
RTC
| 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
|
||
Thx
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.