Release Blocker bug PR-5.1-dev Pending

User tests: Successful: Unsuccessful:

avatar richard67
richard67
28 Mar 2024

Pull Request for Issue #43151 .

Summary of Changes

This pull request (PR) changes the syntax of the INSERT statement in the 5.1.0-2024-02-24.sql update SQL script introduced with PR #42799 for changing the core update site to TUF from row wise "normal" insert syntax INSERT INTO .. VALUES (...); to the INSERT INTO ... SELECT FROM syntax, which also works when the SELECT statement returns multiple rows, which can happen on sites with a long update history.

This solves the mentioned issue where you get 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 on such a site.

When I have made my PR #42988 , which was included in 5.1.0-beta2 to solve this issue, I hadn't noticed that the SQL error happens with the INSERTstatement before the UPDATE statement fixed by that PR.

But that PR was right. It needs both fixes, the one from that PR and the one from this PR here, to finally solve that issue.

Testing Instructions

Pre-conditions

The instructions below are for the case that you don't have a site which runs into that error because it doesn't have multiple update sites for the core.

Alternatively, if you have a copy of such a site, just update it to the latest 5.1 nightly build from here https://developer.joomla.org/nightly-builds.html to get the actual result, and update to ther pakckage created by drone for this PR which you can find here https://artifacts.joomla.org/drone/joomla/joomla-cms/5.1-dev/43169/downloads/75077/ for the expected result.

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 Joomla 5.1.0-alpha or 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 CREATE TABLE 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#L5-L14 .

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#L5-L14 .

Step 3: Run the INSERT 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#L17-L18 .

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#L18-L19 .

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

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

With MySQL or MariaDB see

INSERT INTO `#__tuf_metadata` (`update_site_id`, `root`)
SELECT ue.`update_site_id`,
'{"signed":{"_type":"root","spec_version":"1.0","version":2,"expires":"2025-03-02T11:22:17Z","keys":{"07eb082f367c034a95878687f6648aa76d93652b6ee73e58817053d89af6c44f":{"keytype":"ed25519","scheme":"ed25519","keyid_hash_algorithms":["sha256","sha512"],"keyval":{"public":"9b2af2d9b9727227735253d795bd27ea8f0e294a5f3603e822dc5052b44802b9"}},"1b1b1dd55b2c1c7258714cf1c1ae06f23e4607b28c762d016a9d81c48ffe5669":{"keytype":"ed25519","scheme":"ed25519","keyid_hash_algorithms":["sha256","sha512"],"keyval":{"public":"a18e5ebabc19d5d5984b601a292ece61ba3662ab2d071dc520da5bd4f8948799"}},"2dcaf3d0e552f150792f7c636d45429246dcfa34ac35b46a44f5c87cd17d457e":{"keytype":"ed25519","scheme":"ed25519","keyid_hash_algorithms":["sha256","sha512"],"keyval":{"public":"cb0a7a131961a20edea051d6dc2b091fb650bd399bd8514adb67b3c60db9f8f9"}},"31dd7c7290d664c9b88c0dead2697175293ea7df81b7f24153a37370fd3901c3":{"keytype":"ed25519","scheme":"ed25519","keyid_hash_algorithms":["sha256","sha512"],"keyval":{"public":"589d029a68b470deff1ca16dbf3eea6b5b3fcba0ae7bb52c468abc7fb058b2a2"}},"9e41a9d62d94c6a1c8a304f62c5bd72d84a9f286f27e8327cedeacb09e5156cc":{"keytype":"ed25519","scheme":"ed25519","keyid_hash_algorithms":["sha256","sha512"],"keyval":{"public":"6043c8bacc76ac5c9750f45454dd865c6ca1fc57d69e14cc192cfd420f6a66a9"}}},"roles":{"root":{"keyids":["1b1b1dd55b2c1c7258714cf1c1ae06f23e4607b28c762d016a9d81c48ffe5669","2dcaf3d0e552f150792f7c636d45429246dcfa34ac35b46a44f5c87cd17d457e"],"threshold":1},"snapshot":{"keyids":["07eb082f367c034a95878687f6648aa76d93652b6ee73e58817053d89af6c44f","2dcaf3d0e552f150792f7c636d45429246dcfa34ac35b46a44f5c87cd17d457e"],"threshold":1},"targets":{"keyids":["31dd7c7290d664c9b88c0dead2697175293ea7df81b7f24153a37370fd3901c3"],"threshold":1},"timestamp":{"keyids":["9e41a9d62d94c6a1c8a304f62c5bd72d84a9f286f27e8327cedeacb09e5156cc"],"threshold":1}},"consistent_snapshot":true},"signatures":[{"keyid":"2dcaf3d0e552f150792f7c636d45429246dcfa34ac35b46a44f5c87cd17d457e","sig":"2a225a560ec0837b721d4c5e379fedbd3c7c9079a94e6b31e47e0184c8b95421b6036b4286c5d90f29ab4c468d79a712fdb65e96511394ceb3aa8e2b3983a501"},{"keyid":"1b1b1dd55b2c1c7258714cf1c1ae06f23e4607b28c762d016a9d81c48ffe5669","sig":"8ce0b2a7bdc1e6dcba12081f440510df0a593c072dcf591631c2dd0f456844a7da63be8e8ac31ffbddf42641fde84dc733a336031d182c2163b4c1eaf2117005"}]}'
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

INSERT INTO "#__tuf_metadata" ("update_site_id", "root")
SELECT ue."update_site_id",
'{"signed":{"_type":"root","spec_version":"1.0","version":2,"expires":"2025-03-02T11:22:17Z","keys":{"07eb082f367c034a95878687f6648aa76d93652b6ee73e58817053d89af6c44f":{"keytype":"ed25519","scheme":"ed25519","keyid_hash_algorithms":["sha256","sha512"],"keyval":{"public":"9b2af2d9b9727227735253d795bd27ea8f0e294a5f3603e822dc5052b44802b9"}},"1b1b1dd55b2c1c7258714cf1c1ae06f23e4607b28c762d016a9d81c48ffe5669":{"keytype":"ed25519","scheme":"ed25519","keyid_hash_algorithms":["sha256","sha512"],"keyval":{"public":"a18e5ebabc19d5d5984b601a292ece61ba3662ab2d071dc520da5bd4f8948799"}},"2dcaf3d0e552f150792f7c636d45429246dcfa34ac35b46a44f5c87cd17d457e":{"keytype":"ed25519","scheme":"ed25519","keyid_hash_algorithms":["sha256","sha512"],"keyval":{"public":"cb0a7a131961a20edea051d6dc2b091fb650bd399bd8514adb67b3c60db9f8f9"}},"31dd7c7290d664c9b88c0dead2697175293ea7df81b7f24153a37370fd3901c3":{"keytype":"ed25519","scheme":"ed25519","keyid_hash_algorithms":["sha256","sha512"],"keyval":{"public":"589d029a68b470deff1ca16dbf3eea6b5b3fcba0ae7bb52c468abc7fb058b2a2"}},"9e41a9d62d94c6a1c8a304f62c5bd72d84a9f286f27e8327cedeacb09e5156cc":{"keytype":"ed25519","scheme":"ed25519","keyid_hash_algorithms":["sha256","sha512"],"keyval":{"public":"6043c8bacc76ac5c9750f45454dd865c6ca1fc57d69e14cc192cfd420f6a66a9"}}},"roles":{"root":{"keyids":["1b1b1dd55b2c1c7258714cf1c1ae06f23e4607b28c762d016a9d81c48ffe5669","2dcaf3d0e552f150792f7c636d45429246dcfa34ac35b46a44f5c87cd17d457e"],"threshold":1},"snapshot":{"keyids":["07eb082f367c034a95878687f6648aa76d93652b6ee73e58817053d89af6c44f","2dcaf3d0e552f150792f7c636d45429246dcfa34ac35b46a44f5c87cd17d457e"],"threshold":1},"targets":{"keyids":["31dd7c7290d664c9b88c0dead2697175293ea7df81b7f24153a37370fd3901c3"],"threshold":1},"timestamp":{"keyids":["9e41a9d62d94c6a1c8a304f62c5bd72d84a9f286f27e8327cedeacb09e5156cc"],"threshold":1}},"consistent_snapshot":true},"signatures":[{"keyid":"2dcaf3d0e552f150792f7c636d45429246dcfa34ac35b46a44f5c87cd17d457e","sig":"2a225a560ec0837b721d4c5e379fedbd3c7c9079a94e6b31e47e0184c8b95421b6036b4286c5d90f29ab4c468d79a712fdb65e96511394ceb3aa8e2b3983a501"},{"keyid":"1b1b1dd55b2c1c7258714cf1c1ae06f23e4607b28c762d016a9d81c48ffe5669","sig":"8ce0b2a7bdc1e6dcba12081f440510df0a593c072dcf591631c2dd0f456844a7da63be8e8ac31ffbddf42641fde84dc733a336031d182c2163b4c1eaf2117005"}]}'
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';
.

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

No SQL error, for each update site a record is inserted into the #__tuf_metadata table.

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 - 28 Mar 2024
avatar richard67 richard67 - change - 28 Mar 2024
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 28 Mar 2024
Category SQL Administration com_admin Postgresql
avatar richard67 richard67 - change - 28 Mar 2024
The description was changed
avatar richard67 richard67 - edited - 28 Mar 2024
avatar richard67 richard67 - change - 28 Mar 2024
Labels Added: bug PR-5.1-dev
avatar richard67 richard67 - change - 28 Mar 2024
The description was changed
avatar richard67 richard67 - edited - 28 Mar 2024
avatar richard67 richard67 - change - 28 Mar 2024
The description was changed
avatar richard67 richard67 - edited - 28 Mar 2024
avatar dautrich dautrich - test_item - 28 Mar 2024 - Tested successfully
avatar dautrich
dautrich - comment - 28 Mar 2024

I have tested this item ✅ successfully on c114f39


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

avatar dautrich
dautrich - comment - 28 Mar 2024

I'd like to stress that this PR allows a smooth update of a site with duplicate update sources. It does not remove the duplicates.

I have a rather old site with three entries for Joomla update in the #__update_sites table (with IDs 1, 41, and 104):
grafik

They also can be found in table #__update_sites_extensions:
grafik

After the update, they also appear in table #__tuf_metadata:
grafik

I'd propose to remove the duplicate entries (in my case, IDs 1 and 41) asap. Since Joomla update sources cannot be deleted in the backend, the removal has to be done in the database tables by using phpMyAdmin or similar.

As with all manipulations at database level, it is advisable to take a backup beforehand and/or exercise on a development platform.

avatar LadySolveig LadySolveig - change - 28 Mar 2024
Labels Added: Release Blocker
avatar LadySolveig LadySolveig - change - 28 Mar 2024
Status Pending Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2024-03-28 19:23:51
Closed_By LadySolveig
avatar LadySolveig LadySolveig - close - 28 Mar 2024
avatar LadySolveig LadySolveig - merge - 28 Mar 2024
avatar LadySolveig
LadySolveig - comment - 28 Mar 2024

Thank you @richard67 and also for testing @dautrich

Add a Comment

Login with GitHub to post a comment