Skip to content

Conversation

@richard67
Copy link
Member

@richard67 richard67 commented May 12, 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.

@richard67 richard67 changed the 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 May 12, 2021
@richard67 richard67 changed the 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 May 12, 2021
@richard67 richard67 changed the 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 May 12, 2021
@zero-24
Copy link
Contributor

zero-24 commented May 12, 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?

@richard67
Copy link
Member Author

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.

@richard67
Copy link
Member Author

@zero-24 Done, changed.

@richard67
Copy link
Member Author

@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.

@sandewt
Copy link
Contributor

sandewt commented May 12, 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.

@alikon
Copy link
Contributor

alikon commented May 12, 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.

@alikon
Copy link
Contributor

alikon commented May 12, 2021

RTC


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

@joomla-cms-bot joomla-cms-bot added the RTC This Pull Request is Ready To Commit label May 12, 2021
@richard67 richard67 added this to the Joomla 4.0 milestone May 12, 2021
@Quy Quy merged commit 9653158 into joomla:4.0-dev May 12, 2021
@joomla-cms-bot joomla-cms-bot removed the RTC This Pull Request is Ready To Commit label May 12, 2021
@Quy
Copy link
Contributor

Quy commented May 12, 2021

Thanks!

@richard67
Copy link
Member Author

Thanks all!

@richard67 richard67 deleted the 4.0-dev-fix-sql-error-on-update-from-3.10 branch May 12, 2021 20:07
@richard67
Copy link
Member Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants