User tests: Successful: Unsuccessful:
Pull Request for Issues #35949 and #35915 .
When an SQL statement in an update SQL script of the core or (new in Joomla 4!) a 3rd party extension has a syntax error in an ALTER TABLE <tableName> MODIFY <columnName>...
or an ALTER TABLE <tableName> CHANGE <columnName>...
SQL statement, the check query used by the database checker to check that column will fail with an SQL syntax error.
This error happens already when calling $this->db->setQuery
, but the try block to handle exceptions does not include that, it handles only the $this->db->loadRowList
call.
This leads to the database checker being broken, see testing instructions or the issue for details.
This PR fixes it by moving the $this->db->setQuery
inside the try block in the "check" method of the change item.
The same applies when the database checker would try to fix that problem, so it needs the same fix for the "fix" method.
In addition I've fixed the wrong documentation of the "check" method.
Install Weblinks 4.0.0. You can download it from here: https://github.com/joomla-extensions/weblinks/releases/download/4.0.0/pkg-weblinks-4.0.0.zip .
Open the following update SQL script of the Weblinks component in a text editor:
ALTER TABLE `#__weblinks MODIFY `createdXXX` datetime NOT NULL;
ALTER TABLE "#__weblinks ALTER COLUMN "createdXXX" DROP DEFAULT;
After having made the change, save the file.
Go to the "System" dashboard and check the icon shown for "Maintenance: Database".
Result: The database check failed.
Use the link to go to the database checker.
Result: An error alert shows a message about an SQL syntax error, and the database checker doesn't show any rows with the core or extensions, so nothing can be fixed.
Hint: Depending on your database server type and version it might be a different error message which is shown. The important thing is that there is an error message about an SQL error and nothing is shown below it except of the "No matching results" alert.
Apply the patch of this PR.
Repeat step 4.
Result: The database check shows there is a problem.
Repeat step 5.
Result: An error alert shows a message about an SQL syntax error, and the database checker shows rows with the core or extensions. The tool tip shown when moving over the badge with the problem shows which database column in which SQL script has caused the problem.
Select the Weblinks component using the check box at the left of the row and use the "Update Structure" button.
Result: No change, but also no uncaught exception like it would happen without the 2nd change in this PR for the "fix" method of the change item.
Code review: Check that the changes in the documentation of the "check" method here reflect what the function does.
Note: "Skipped" means that a check item has no check query because it does not change structure, e.g. an INSERT statement, and these will later be reported as "skipped" in the tool tip with the details.
Database checker broken.
Database checker works.
For 3.10 we don't need this fix because when having an SQL error in a core update SQL script like tested here with the Weblinks component, the database checker view is not broken on a 3.10.
None for this PR.
But as far as I know our Joomla 4 documentation lacks information about the fact that in Joomla 4 the database schema checker also checks update SQL scripts of 3rd party extensions.
Status | New | ⇒ | Pending |
Category | ⇒ | Libraries |
Reason for release blocker: In J4 it is much more likely than in J3 that the issue breaks the database checker because in J4 it checks also update SQL scripts of 3rd party extensions.
I have tested this item
PHP 8.0.6 and MySQLi 10.4.19-MariaDB
I have tested this item
Patch works as described.
Status | Pending | ⇒ | Ready to Commit |
Labels |
Added:
?
|
RTC
Labels |
Added:
?
Release Blocker
|
@rjharishabh @RickR2H Could you test again? Note that there is a new test step 10 for a code review check. Thanks in advance.
Status | Ready to Commit | ⇒ | Pending |
Back to pending. Needs new tests due to changes.
I have tested this item
PHP 8.0.6 and MySQLi 10.4.19-MariaDB
XAMPP on Windows 10
I have tested this item
postgres
Status | Pending | ⇒ | Ready to Commit |
RTC
Status | Ready to Commit | ⇒ | Fixed in Code Base |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2021-11-03 14:37:11 |
Closed_By | ⇒ | wilsonge |
Yup - thanks!
Thanks all.
I think this is a release blocker.