Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[4.1] Fix the upgrade path #36585

Merged
merged 17 commits into from
Jan 25, 2022
Merged

[4.1] Fix the upgrade path #36585

merged 17 commits into from
Jan 25, 2022

Conversation

dgrammatiko
Copy link
Contributor

@dgrammatiko dgrammatiko commented Jan 6, 2022

Pull Request for Issue # .

Summary of Changes

  • Introduced a function in the script.php that will run independently of the batch work of the db updates. The reason is that this particular db fix is essential so that the UI will not become broken if for any reason the update files fail somehow

Testing Instructions

Using https://test5.richard-fath.de/Joomla_4.1.0-dev-Development-Update_Package_test-with-sql-error.zip try to

  • Update from 3.10.x to the 4.1 => actual messed result
  • Update from 4.0.x to the 4.1 => actual messed result
    (these SHOULD FAIL leaving you with unstyled front/backend templates)

Using https://test5.richard-fath.de/Joomla_4.1.0-dev+pr.36585-Development-Update_Package_test-with-sql-error.zip try to

  • Update from 3.10.x to the 4.1 => expected usable result
  • Update from 4.0.x to the 4.1 => expected usable result
    (these should show an SQL error at the end, but the backend is usable and the db fixer can be used)

Actual result BEFORE applying this Pull Request

When the database update fails before the update for child templates would have run, the UI is unusable.

j4 1-test-pr-36585_after-update-from-4 0-without-patch

Expected result AFTER applying this Pull Request

The UI is usable. An SQL error is shown, but the backend works, and the database fixer can be used.

j4 1-test-pr-36585_after-update-from-4 0-with-patch

Documentation Changes Required

@brianteeman @joeforjoomla could you test this one?

@richard67 I hope I didn't messed up here

@richard67
Copy link
Member

@dgrammatiko There is no need to remove the statement from the update SQL script. It does not do any harm as long as it does not have any syntax errors (which it doesn't).

Your proposed solution here is the fallback case that the SQL statement for some reason (SQL error in some other statement running in some other script before that one) has not been run. In such a case the backend is not usable, that's why we need the fallback.

@richard67
Copy link
Member

P.S.: So I suggest you revert the changes on the 2 update SQL scripts and adust the PR description accordingly.

@dgrammatiko
Copy link
Contributor Author

I suggest you revert the changes on the 2 update SQL scripts and adust the PR description accordingly.

Done

@richard67
Copy link
Member

P.P.S.: Thanks for following my suggestion. I see my comment was not 100% right because the new fix runs before the update SQL scripts, so it is not really a fallback, but we should not change the old scripts if not necessary so the suggestion is still ok.

But now I ask myself what happens when we update from 3.10 to 4.1.

In this case with one of the early 4.0 update SQL scripts the atum and cassiopeia templates are added. Your new patch will run before that so it has nothing to update. So we again rely on the 4.1 update SQL to do that.

I think you should move the call to your new function to after the SQL updates so it is really a fallback like I first thought before I have noticed the call order.

@dgrammatiko
Copy link
Contributor Author

I think you should move the call to your new function to after the SQL updates so it is really a fallback like I first thought before I have noticed the call order.

If the SQL updates have some fatal error will the function run then? That was my point running it before the SQL part...

@richard67
Copy link
Member

If the SQL updates have some fatal error will the function run then? That was my point running it before the SQL part...

Up to now I think it will be the case, and if in future some proper error handling will be added we have to make sure it is run also when the SQL updates have failed (i.e. are incomplete).

@joeforjoomla
Copy link
Contributor

I have tested this item ✅ successfully on 3bf7f17


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

@dgrammatiko
Copy link
Contributor Author

@bembelimen consider this one as a release blocker

{
$db = Factory::getDbo();

array_map(

This comment was marked as abuse.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

functional programming? No real reason, it's a bit shorter

This comment was marked as abuse.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't believe everything you find on the internet :)

FWIW browsers (JS) are optimizing for these functions and I would expect PHP would be doing that as well but for PHP I don't have any data...

Edit: actually this comment aligns with what I wrote ;)

This comment was marked as abuse.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Functional programming is very popular in the JS space and the reason is because React, Vue, Svelte, etc basically made the UI a function of the state UI = Fn(state)

This comment was marked as abuse.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hate that I can't use the spread operator yet...

This comment was marked as abuse.

dgrammatiko and others added 2 commits January 7, 2022 17:59
Co-authored-by: Phil E. Taylor <phil@phil-taylor.com>
Co-authored-by: Phil E. Taylor <phil@phil-taylor.com>
@AJAY007L
Copy link

AJAY007L commented Jan 8, 2022

I have tested this item ✅ successfully on ca3738f


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

@dgrammatiko dgrammatiko marked this pull request as draft January 8, 2022 12:39
@richard67
Copy link
Member

richard67 commented Jan 8, 2022

Unfortunately the new procedure added by this PR will not be executed if the update SQL scripts fail, and it is no solution to move the call to it to before the update SQL scripts run because then the statement in the new procedure will have no effect.

I think it needs the changes from PR #36506 and then see if we still need the fix from here and where we can hook it in so it is also called when the update SQL scripts fail.

@dgrammatiko
Copy link
Contributor Author

@richard67 since the other PR was already merged is this one needed anymore?

@dgrammatiko
Copy link
Contributor Author

I will create the 2 packages tomorrow

@richard67
Copy link
Member

I am just on it. Waiting for drone to build the one with the PR.

@richard67
Copy link
Member

@dgrammatiko I have created the update packages:

@dgrammatiko
Copy link
Contributor Author

Nice, I've updated the description, now we need couple brave testers

@richard67
Copy link
Member

8 tests if one has both kinds of databases MySQL and PostgreSQL.

For each db type 4 tests:

  • Update from 3.10.x to the 4.1 package with SQL error and without your PR => actual messed result
  • Update from 4.0.x to the 4.1 package with SQL error and without your PR => actual messed result
  • Update from 3.10.x to the 4.1 package with SQL error and with your PR => expected usable result
  • Update from 4.0.x to the 4.1 package with SQL error and with your PR => expected usable result

@richard67
Copy link
Member

@dgrammatiko Please update your testing instructions to make clear it needs to update from 3.10.x or 4.0.x. Updating from 4.1 (e.g. a previous beta) will not be affected by the change in this PR.

@richard67
Copy link
Member

The update tests from 4.0 with both kinds of database I just have finished with success. Now I have a short break, and then I make the tests from 3.10.

@richard67
Copy link
Member

@dgrammatiko I've pimped the testing instructions a bit, I hope that's ok.

@brianteeman
Copy link
Contributor

I can test but not until tomorrow pm

@richard67
Copy link
Member

I have tested this item ✅ successfully on 73b97af

For each db type MySQL and PostgreSQL I have tested the following 4 tests (so 8 tests in total):

  • Update from 3.10.x to the 4.1 package with SQL error and without your PR => actual messed result
  • Update from 4.0.x to the 4.1 package with SQL error and without your PR => actual messed result
  • Update from 3.10.x to the 4.1 package with SQL error and with your PR => expected usable result
  • Update from 4.0.x to the 4.1 package with SQL error and with your PR => expected usable result

When updating from 3.10 there was an additional problem with and without this PR applied, which I will describe more detailed in my next comment.

But that's not related to this PR and has to be fixed with another PR.


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

@richard67
Copy link
Member

@dgrammatiko When updating from 3.10 there is an additional issue not related to your PR. But maybe you should mention it or link to this comment in the testing instructions so people will not count it as failed test.

After the files have been updated (but I think before the database update starts), you get a blank page, and the page title shows an error message (full message in a tool tip when hovered):

j4 1-test-pr-36585_after-update-from-3 10-without-patch_1

Then just refresh the page, and the update continues and then ends as described in the testing instructions.

The database checker will show errors because the old update SQL scripts with versions from 2.5. to 3.x have not been deleted.

When testing the update from 4.0, the blank page does not happen. There will also old files not be deleted, but because there are no old update SQl files to be deleted, there will not be such database checker errros like after an update from 3.10.

But all that happens with and without your PR and so has to be fixed elsewhere.

@brianteeman
Copy link
Contributor

In all my original tests I never saw that blank page error

@richard67
Copy link
Member

@brianteeman I could just reproduce that several times when updating a current 3.10-dev to 4.1, using a "normal" update package without any SQL error, e.g. the last nightly build https://developer.joomla.org/nightlies/Joomla_4.1.0-dev-Development-Update_Package.zip or the custom update URL https://update.joomla.org/core/nightlies/next_minor_list.xml for that nightly.

@dgrammatiko
Copy link
Contributor Author

@richard67 @brianteeman isn't that the bug where an instance of $this->db was replaced by $db in the Table.php?

@richard67
Copy link
Member

@richard67 @brianteeman isn't that the bug where an instance of $this->db was replaced by $db in the Table.php?

Yes, was my PR #36733 ... but it was not in table but in redirect, and here I do not have redirects enabled.

@dgrammatiko
Copy link
Contributor Author

dgrammatiko commented Jan 24, 2022

Yes, was my PR #36733 ... but it was not in table but in redirect, and here I do not have redirects enabled.

Actually the problem is different, in 3.10 the driver is JDatabaseDriverMysqli

		$db = isset($config['dbo']) ? $config['dbo'] : \JFactory::getDbo();

In 4.1 it's JDatabaseDriverMysqli

$db = $config['dbo'] ?? Factory::getDbo();

In short, the alias is not yet established...

BTW this raises some questions...

@richard67
Copy link
Member

Actually the problem is different, in 3.10 the driver is JDatabaseDriverMysqli

		$db = isset($config['dbo']) ? $config['dbo'] : \JFactory::getDbo();

In 4.1 it's JDatabaseDriverMysqli

$db = $config['dbo'] ?? Factory::getDbo();

In short, the alias is not yet established...

Please post that also in the new issue #36833 . Thanks in advance.

@laoneo
Copy link
Member

laoneo commented Jan 25, 2022

I have partially tested it with success as I had a branch from 4.0.6 with npm ci done. Then I switched to 4.1, did npm ci, which resulted in template files not loaded. Then run the SQL update script from this pr, did an npm ci and template did load fine then.

Didn't test the installer script.

@RickR2H
Copy link
Member

RickR2H commented Jan 25, 2022

I have tested this item ✅ successfully on f77dfc4

Bug confirmed for 3.10.5 and 4.0.6.
Patch worked and upgrading to 4.1 from J3 and J4 with the patched package was successful. In both cases DB repair worked and fixed the errors.


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

@richard67
Copy link
Member

RTC


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

@joomla-cms-bot joomla-cms-bot added the RTC This Pull Request is Ready To Commit label Jan 25, 2022
@bembelimen bembelimen merged commit 5f68ac3 into joomla:4.1-dev Jan 25, 2022
@joomla-cms-bot joomla-cms-bot removed the RTC This Pull Request is Ready To Commit label Jan 25, 2022
@bembelimen
Copy link
Contributor

Thx

@bembelimen bembelimen added this to the Joomla 4.1.0 milestone Jan 25, 2022
@brianteeman
Copy link
Contributor

I can test but not until tomorrow pm

I guess I dont need to test this then

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.

None yet