? ? ? Pending

User tests: Successful: Unsuccessful:

avatar richard67
richard67
12 May 2021

Pull Request for Issue # .

Summary of Changes

With PR #33550 , com_csp war removed from the 4.0-dev branch, an update SQL 4.0.0-2021-05-04.sql was provided to remove the #__csp table from database when updating to the next J4 version, and the statement to create that table was removed from the old update SQL 4.0.0-2018-06-03.sql.

The last change causes an SQL error when updating from 3.10 because that table doesn't exist.

This this pull request (PR) fixes that by adding " IF NOT EXISTS" to the "DROP TABLE" statement in the SQL update script mentioned above.

Furthermore, this PR corrects the wrong names quoting in the 4.0.0-2021-05-04.sql file for PostgreSQL from PR #33550 . No idea how I could miss that on review.

Testing Instructions

This PR needs to be tested with both types of databases, MySQL (or MariaDB) and PostgreSQL.

Testers please report back which type you have used.

If you can test with both, please do that.

Update a 3.10 to the latest nightly build, with debug system on and error reporting set to maximum.

For reproducing the issue, use the regular nightly build custom update URL or package, for testing the fix from this PR use the custom update URL or package created by drone for this PR.

At the end of the update, check if errors are shown in backend or your PHP error log.

After the update has finished, check in file administrator/logs/joomla_update.php which SQL statements was executed as last for that update.

Actual result BEFORE applying this Pull Request

  • On MySQL or MariaDB databases:

You get an SQL error:

Unknown table `xyz.#__csp`

with "xyz" being the database name, and "#__" being the table prefix.

The last SQL statement logged in administrator/logs/joomla_update.php is:

Ran query from file 4.0.0-2021-05-04. Query text: DELETE FROM `#__extensions` WHERE `name` = 'com_csp' and `type` = 'component' an.
  • On PostgreSQL databases:

You get an SQL error:

syntax error at or near "`" LINE 1: DELETE FROM `#__extensions` WHERE `name` = 'com_csp' and ...

with "#__" being the table prefix.

The last SQL statement logged in administrator/logs/joomla_update.php is:

Ran query from file 4.0.0-2021-05-01. Query text: UPDATE "#__template_styles"    SET "params" = '{"hue":"hsl(214, 63%, 20%)","bg-l.

Expected result AFTER applying this Pull Request

No SQL error.

The last SQL statement logged in administrator/logs/joomla_update.php is:

Ran query from file 4.0.0-2021-05-07. Query text: UPDATE `#__mail_templates`    SET `subject` = 'COM_PRIVACY_EMAIL_DATA_EXPORT_COM.

(On PostgreSQL of course with the right names quoting.)

Documentation Changes Required

None.

avatar richard67 richard67 - open - 12 May 2021
avatar richard67 richard67 - change - 12 May 2021
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 12 May 2021
Category SQL Administration com_admin Postgresql
avatar richard67 richard67 - change - 12 May 2021
The description was changed
avatar richard67 richard67 - edited - 12 May 2021
avatar richard67 richard67 - change - 12 May 2021
Title
[4.0] Fix SQL error about unknown table "#__csp" when updating from 3.10
[4.0] [WiP] Fix SQL error about unknown table "#__csp" when updating from 3.10
avatar richard67 richard67 - edited - 12 May 2021
avatar richard67 richard67 - change - 12 May 2021
The description was changed
avatar richard67 richard67 - edited - 12 May 2021
avatar richard67 richard67 - change - 12 May 2021
Labels Added: ? ?
avatar richard67 richard67 - change - 12 May 2021
The description was changed
avatar richard67 richard67 - edited - 12 May 2021
avatar richard67 richard67 - change - 12 May 2021
The description was changed
avatar richard67 richard67 - edited - 12 May 2021
avatar richard67 richard67 - change - 12 May 2021
Title
[4.0] [WiP] Fix SQL error about unknown table "#__csp" when updating from 3.10
[4.0] Fix SQL error about unknown table "#__csp" when updating from 3.10
avatar richard67 richard67 - edited - 12 May 2021
avatar richard67 richard67 - change - 12 May 2021
The description was changed
avatar richard67 richard67 - edited - 12 May 2021
avatar richard67 richard67 - change - 12 May 2021
Title
[4.0] Fix SQL error about unknown table "#__csp" when updating from 3.10
[4.0] Fix SQL error when updating from 3.10
avatar richard67 richard67 - edited - 12 May 2021
avatar richard67 richard67 - change - 12 May 2021
The description was changed
avatar richard67 richard67 - edited - 12 May 2021
avatar richard67 richard67 - change - 12 May 2021
The description was changed
avatar richard67 richard67 - edited - 12 May 2021
avatar zero-24
zero-24 - comment - 12 May 2021

Not all supported databases support DROP TABLE ... IF EXISTS

What database does not support it? On a quick look there seem to be support on mysql/mariadb & PostgreSQL? Or do i miss something?

avatar richard67
richard67 - comment - 12 May 2021

What database does not support it? On a quick look there seem to be support on mysql/mariadb & PostgreSQL? Or do i miss something?

@zero-24 Maybe not, but I'm also not sure now if the schema checker supports it. With this PR here now I'm sure it works.

But I will check and maybe improve.

avatar richard67 richard67 - change - 12 May 2021
Labels Added: ?
Removed: ?
avatar richard67
richard67 - comment - 12 May 2021

@zero-24 Done, changed.

avatar richard67
richard67 - comment - 12 May 2021

@zero-24 P.S.: The database fixer ignores DROP TABLE statements since ever. That's another issue, and to fix this it would need to change also some update SQL for the finder, which drops and then creates again tables.

avatar richard67 richard67 - change - 12 May 2021
The description was changed
avatar richard67 richard67 - edited - 12 May 2021
avatar sandewt sandewt - test_item - 12 May 2021 - Tested successfully
avatar sandewt
sandewt - comment - 12 May 2021

I have tested this item successfully on ee67f41

10.4.14-MariaDB

Joomla_3.10.0-alpha6 update to Joomla_4.0.0-beta8

Before:

  • JInstaller: :Install: Error SQL Unknown table 'joomla_310-2.rtxc5_csp'
  • 2021-05-12T15:41:08+00:00 INFO ::1 update Ran query from file 4.0.0-2021-05-04. Query text: DELETE FROM #__extensions WHERE name = 'com_csp' and type = 'component' an.

After:

  • 2021-05-12T15:18:23+00:00 INFO ::1 update Ran query from file 4.0.0-2021-05-07. Query text: UPDATE #__mail_templates SET subject = 'COM_PRIVACY_EMAIL_DATA_EXPORT_COM.

This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/33820.
avatar alikon alikon - test_item - 12 May 2021 - Tested successfully
avatar alikon
alikon - comment - 12 May 2021

I have tested this item successfully on ee67f41


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

avatar alikon alikon - change - 12 May 2021
Status Pending Ready to Commit
avatar alikon
alikon - comment - 12 May 2021

RTC


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

avatar Quy Quy - change - 12 May 2021
Status Ready to Commit Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2021-05-12 20:05:22
Closed_By Quy
Labels Added: ? ?
Removed: ?
avatar Quy Quy - close - 12 May 2021
avatar Quy Quy - merge - 12 May 2021
avatar Quy
Quy - comment - 12 May 2021

Thanks!

avatar richard67
richard67 - comment - 12 May 2021

Thanks all!

avatar richard67
richard67 - comment - 12 May 2021

Especially thanks to @zero-24 and @SharkyKZ pushing me into the right direction for the better fix.

Add a Comment

Login with GitHub to post a comment