? Release Blocker ? Pending

User tests: Successful: Unsuccessful:

avatar richard67
richard67
31 Oct 2021

Pull Request for Issues #35949 and #35915 .

Summary of Changes

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.

Testing Instructions

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

  2. Open the following update SQL script of the Weblinks component in a text editor:

  • administrator/components/com_weblinks/sql/updates/mysql/4.0.0.sql when using a MySQL or MariaDB database
  • administrator/components/com_weblinks/sql/updates/postgresql/4.0.0.sql when using a PostgreSQL database
  1. In the first SQL statement, remove the ending names quote for the table name and change the column name so it looks as follows:
  • With MySQL or MariaDB database
ALTER TABLE `#__weblinks MODIFY `createdXXX` datetime NOT NULL;
  • With PostgreSQL database
ALTER TABLE "#__weblinks ALTER COLUMN "createdXXX" DROP DEFAULT;

After having made the change, save the file.

  1. Go to the "System" dashboard and check the icon shown for "Maintenance: Database".
    Result: The database check failed.
    2021-10-31_snap-1

  2. 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.
    2021-10-31_snap-2

  3. Apply the patch of this PR.

  4. Repeat step 4.
    Result: The database check shows there is a problem.
    2021-10-31_snap-3

  5. 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.
    2021-11-01_snap-1

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

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

Actual result BEFORE applying this Pull Request

Database checker broken.

Expected result AFTER applying this Pull Request

Database checker works.

Other information

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.

Documentation Changes Required

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.

avatar richard67 richard67 - open - 31 Oct 2021
avatar richard67 richard67 - change - 31 Oct 2021
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 31 Oct 2021
Category Libraries
avatar richard67
richard67 - comment - 31 Oct 2021

I think this is a release blocker.

avatar richard67 richard67 - change - 31 Oct 2021
The description was changed
avatar richard67 richard67 - edited - 31 Oct 2021
avatar richard67 richard67 - change - 31 Oct 2021
The description was changed
avatar richard67 richard67 - edited - 31 Oct 2021
avatar richard67 richard67 - change - 31 Oct 2021
The description was changed
avatar richard67 richard67 - edited - 31 Oct 2021
avatar richard67
richard67 - comment - 31 Oct 2021

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.

avatar richard67 richard67 - change - 31 Oct 2021
The description was changed
avatar richard67 richard67 - edited - 31 Oct 2021
avatar richard67 richard67 - change - 31 Oct 2021
The description was changed
avatar richard67 richard67 - edited - 31 Oct 2021
avatar richard67 richard67 - change - 31 Oct 2021
The description was changed
avatar richard67 richard67 - edited - 31 Oct 2021
avatar richard67 richard67 - change - 31 Oct 2021
The description was changed
avatar richard67 richard67 - edited - 31 Oct 2021
avatar richard67 richard67 - change - 31 Oct 2021
The description was changed
avatar richard67 richard67 - edited - 31 Oct 2021
avatar richard67 richard67 - change - 1 Nov 2021
The description was changed
avatar richard67 richard67 - edited - 1 Nov 2021
avatar richard67 richard67 - change - 1 Nov 2021
The description was changed
avatar richard67 richard67 - edited - 1 Nov 2021
avatar richard67 richard67 - change - 1 Nov 2021
The description was changed
avatar richard67 richard67 - edited - 1 Nov 2021
avatar richard67 richard67 - change - 1 Nov 2021
The description was changed
avatar richard67 richard67 - edited - 1 Nov 2021
avatar richard67 richard67 - change - 1 Nov 2021
The description was changed
avatar richard67 richard67 - edited - 1 Nov 2021
avatar rjharishabh rjharishabh - test_item - 1 Nov 2021 - Tested successfully
avatar rjharishabh
rjharishabh - comment - 1 Nov 2021

I have tested this item successfully on 18815fb

PHP 8.0.6 and MySQLi 10.4.19-MariaDB


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

avatar RickR2H RickR2H - test_item - 1 Nov 2021 - Tested successfully
avatar RickR2H
RickR2H - comment - 1 Nov 2021

I have tested this item successfully on 18815fb

Patch works as described.


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

avatar RickR2H RickR2H - change - 1 Nov 2021
Status Pending Ready to Commit
Labels Added: ?
avatar RickR2H
RickR2H - comment - 1 Nov 2021

RTC


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

avatar richard67 richard67 - change - 2 Nov 2021
Labels Added: ? Release Blocker
avatar richard67 richard67 - change - 2 Nov 2021
The description was changed
avatar richard67 richard67 - edited - 2 Nov 2021
avatar richard67
richard67 - comment - 2 Nov 2021

@rjharishabh @RickR2H Could you test again? Note that there is a new test step 10 for a code review check. Thanks in advance.

avatar richard67 richard67 - change - 2 Nov 2021
Status Ready to Commit Pending
avatar richard67
richard67 - comment - 2 Nov 2021

Back to pending. Needs new tests due to changes.


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

avatar rjharishabh rjharishabh - test_item - 2 Nov 2021 - Tested successfully
avatar rjharishabh
rjharishabh - comment - 2 Nov 2021

I have tested this item successfully on 25c8959

PHP 8.0.6 and MySQLi 10.4.19-MariaDB
XAMPP on Windows 10


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

avatar alikon alikon - test_item - 2 Nov 2021 - Tested successfully
avatar alikon
alikon - comment - 2 Nov 2021

I have tested this item successfully on 25c8959

postgres


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

avatar alikon alikon - change - 2 Nov 2021
Status Pending Ready to Commit
avatar alikon
alikon - comment - 2 Nov 2021

RTC


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

avatar richard67
richard67 - comment - 3 Nov 2021

@wilsonge Better now?

avatar wilsonge wilsonge - close - 3 Nov 2021
avatar wilsonge wilsonge - merge - 3 Nov 2021
avatar wilsonge wilsonge - change - 3 Nov 2021
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
avatar wilsonge
wilsonge - comment - 3 Nov 2021

Yup - thanks!

avatar richard67
richard67 - comment - 3 Nov 2021

Thanks all.

Add a Comment

Login with GitHub to post a comment