Skip to content

Remove all default values for type 'text' or 'mediumtext' - redo of PR #17860#27937

Merged
wilsonge merged 9 commits intojoomla:stagingfrom
richard67:staging-redo-pr-17860
Feb 18, 2020
Merged

Remove all default values for type 'text' or 'mediumtext' - redo of PR #17860#27937
wilsonge merged 9 commits intojoomla:stagingfrom
richard67:staging-redo-pr-17860

Conversation

@richard67
Copy link
Copy Markdown
Member

@richard67 richard67 commented Feb 15, 2020

Redo of Pull Request (PR) #17860 .

Important for maintainers: When merging, please don't do a squash commit. I don't want the commit history and so the credits for the author of the original PR being lost.

Summary of Changes

Removed all default values for SQL type text or in case of MySQL also mediumtext for databases MySQL and PostgreSQL. For MS SQL Server nothing to be done since there VARCHAR columns are used in these cases.

Thanks to @eXsiLe95 for the original PR.

There were a few things missing and to be changed, see comments in the original PR.

This PR here takes over the work and completes it. Commit history is preserved so some credits still go to the original PR's author. In addition, a few inconsistencies between PostgreSQL and MySQL are fixed regarding such database columns of SQL type text or in case of MySQL also mediumtext.

Testing Instructions

Important: Both of the following 2 tests should be tested on both kinds of database MySQL and PostgreSQL. If you have both kinds of database available, test both. In any case please report back with which kind(s) of database you have tested, and in case or errors also the version(s).

Test 1 - New installation

Step 1: Apply the patch of this PR to a clean, current staging branch or nightly build or a 3.9.15.

Step 2: Make a new installation.

Step 3: Login to backend.

Step 4. Go to Extensions -> Manage -> Database.

Result: No database problems shown. Database schema version is 3.9.16-2020-02-15.

Step 5: Follow the testing instructions of PR #17860 , i.e.:

  • Go to administrator > Modules and set it to Administrator.
  • Try to create a new Administrator Menu (for example), so that there is no editor tool in the creation window (because that's where the content comes from).
  • Save this module.

Result: No SQL error, module is saved.

Step 6: Verify that following works as before and there are no SQL errors shown which are related to invalid default values for columns of type text or in case of MySQL also mediumtext:

  • Creating and editing categories
  • Creating and editing fields and field groups
  • Smart Search
  • Action logs
  • Content history

Result: No SQL errors related to invalid default values for columns of type text or in case of MySQL also mediumtext.

Step 7: Using a tool like e.g. PhpMyAdmin or PhpPgAdmin, verify in Joomla database tables that none of the table columns of SQL type text or in case of MySQL also mediumtext has a default value.

Result: No database table columns of SQL type text or in case of MySQL also mediumtext with a default value.

Test 2 - Update SQL scripts

Step 1: On a clean, current staging branch or nightly build or a 3.9.15 without the patch of this PR applied, or on an older Joomla version, make a new installation.

Step 2: Apply the patch of this PR.

Step 3: Login to backend.

Step 4: Go to Extensions -> Manage -> Database.

Result: Depends on the databasase type and the Joomla version.

  • MySQL: On current staging or nightly, only "1 Problem: Database schema version not up to date" is shown. For older Joomla versions there might be some database errors shown similar to those mentioned for PostgreSQL. These errors then refer to wrong database columns of type text or mediumtext.
  • PostgreSQL: On current staging or nightly, 34 database problems are found, which all belong to update sql script 3.9.16-2020-02-15.sql. The problems refer to wrong database columns of type text. For older Joomla versions there might be shown more database errors of this type.

Step 5: Use the "Fix" button.

Result: No database problems shown. Database schema version is 3.9.16-2020-02-15.

Step 6: Follow the testing instructions of PR #17860 , i.e.:

  • Go to administrator > Modules and set it to Administrator.
  • Try to create a new Administrator Menu (for example), so that there is no editor tool in the creation window (because that's where the content comes from).
  • Save this module.

Result: No SQL error, module is saved.

Step 7: Verify that following works as before and there are no SQL errors shown which are related to invalid default values for columns of type text or in case of MySQL also mediumtext:

  • Creating and editing categories
  • Creating and editing fields and field groups
  • Smart Search
  • Action logs
  • Content history

Result: No SQL errors related to invalid default values for columns of type text or in case of MySQL also mediumtext.

Step 8: Using a tool like e.g. PhpMyAdmin or PhpPgAdmin, verify in Joomla database tables that none of the table columns of SQL type text or in case of MySQL also mediumtext has a default value.

Result: No database table columns of SQL type text or in case of MySQL also mediumtext with a default value.

Test 3 - Update to patched nightly build of today plus this PR applied

Step 1: On a Joomla 3.9.15 or any other 3.9.x but not current staging or nightly, go to the Joomla Update Component, change update channel to "Custom URL" and enter following custom URL:
https://test5.richard-fath.de/test-pr-27937_list.xml.
Or download the patched update comtainer from here
https://test5.richard-fath.de/Joomla_3.9.16-dev-Development-Update_Package_2020-02-15_pr-27937.zip
and use the "Upload & Update" functionality of the Joomla Update component, then you can also update a current staging or nightly.

Step 2: Start the update.

Result: Update finishs with success.

Step 3. Go to Extensions -> Manage -> Database.

Result: No database problems shown. Database schema version is 3.9.16-2020-02-15.

Step 4: Follow the testing instructions of PR #17860 , i.e.:

  • Go to administrator > Modules and set it to Administrator.
  • Try to create a new Administrator Menu (for example), so that there is no editor tool in the creation window (because that's where the content comes from).
  • Save this module.

Result: No SQL error, module is saved.

Step 5: Verify that following works as before and there are no SQL errors shown which are related to invalid default values for columns of type text or in case of MySQL also mediumtext:

  • Creating and editing categories
  • Creating and editing fields and field groups
  • Smart Search
  • Action logs
  • Content history

Result: No SQL errors related to invalid default values for columns of type text or in case of MySQL also mediumtext.

Step 6: Using a tool like e.g. PhpMyAdmin or PhpPgAdmin, verify in Joomla database tables that none of the table columns of SQL type text or in case of MySQL also mediumtext has a default value.

Result: No database table columns of SQL type text or in case of MySQL also mediumtext with a default value.

Expected result

  • No database table columns of SQL type text or in case of MySQL also mediumtext has a default value.
  • No SQL error when creating an admin module as descibed in the testing instructions of PR Removed all default values for type 'TEXT' #17860 .
  • No SQL errors related to invalid default values for columns of type text or in case of MySQL also mediumtext in other cases.

Actual result

  • There are database table columns of SQL type text or in case of MySQL also mediumtext which have a default value.
  • You might get SQL error when creating an admin module as descibed in the testing instructions of PR Removed all default values for type 'TEXT' #17860 .
  • Depending on your Joomla version you might such SQL errors in other cases, too.

Documentation Changes Required

None.

@richard67 richard67 marked this pull request as ready for review February 15, 2020 14:53
@richard67
Copy link
Copy Markdown
Member Author

@alikon Ready for test.

@richard67
Copy link
Copy Markdown
Member Author

@SharkyKZ @Quy @jwaisner and whoever else has time: Please test ... the more testers for MySQL and PostgreSQL. the better. I really want to be sure that it doesn't break anything.

@richard67 richard67 requested a review from HLeithner February 15, 2020 15:33
@brianteeman
Copy link
Copy Markdown
Contributor

Why are you changing existing sql update files? they should be immutable

@richard67
Copy link
Copy Markdown
Member Author

@brianteeman No they aren't. We have to do that in the way I did in order not to let the database checker/fixer report errors. I had explained that in past, and I also explained in a comment here: #17860 (comment). Trust me, I know what I'm doing here.

@richard67
Copy link
Copy Markdown
Member Author

@rdeutz @wilsonge @HLeithner If one of you has time: Please confirm my comment above. It has been explained to Brian several times but he doesn't want to understand it.

@brianteeman
Copy link
Copy Markdown
Contributor

You are making the changes required in this file 3.9.16-2020-02-15.sql so why would you need to make them in a previous file

@richard67
Copy link
Copy Markdown
Member Author

richard67 commented Feb 15, 2020

You are making the changes required in this file 3.9.16-2020-02-15.sql so why would you need to make them in a previous file

@brianteeman Because the database checker/fixer will report errors for these old files if I don't change them. Then you fix it, and then in the next step it will repost errors for the same columns of the new update sql, and if you fix them it will again report errors for the old script and so on and so on, so you end in an endless fixing loop.

P.S.: The checker goes through all present update sql files from old version to new version and checks if column definition in database matches what he finds in that particular sql file. It always starts e.g. with the 2.5 file, if present. So you can do a change for a column only in 1 file. If you later have to change the same column in a later file, you either have to comment out the change in the old file, or adapt it if it is in a create table statement.

@richard67
Copy link
Copy Markdown
Member Author

@brianteeman P.P.S.: If we would throw away the (almost) useless db ckecker and fixer it would all as you say.

@brianteeman
Copy link
Copy Markdown
Contributor

I am sure you are wrong because the only time these changes will be seen is after you have upgraded the site and therefore already have the correct database.

Anyway this PR cannot be truly tested without testing an upgrade using the joomlaupdate component

@richard67
Copy link
Copy Markdown
Member Author

richard67 commented Feb 15, 2020

@brianteeman You are wrong, I think. Asfar as I know, the db checker "Extensions -> Manage -> Database" checks all the old files again, regardless if after new installation or after an update.

P.S.: But of course I can build an update container and provide a custom update URL to check updating with the Joomla Update Component. Will do so in a few minutes.

@brianteeman
Copy link
Copy Markdown
Contributor

database

@jwaisner
Copy link
Copy Markdown
Member

jwaisner commented Feb 15, 2020

I have tested this item ✅ successfully on 993254e

New install works with no issues and database is up to date. All table updating functions work as well.

Update function works on an existent install then applying the PR. All table updating functions work as well.

This was tested on MySQL database.

@richard67
Copy link
Copy Markdown
Member Author

@jwaisner Thanks for testing. I have added a third test with Joomla Update Component. Could you test that, too, and report back the result?

@richard67
Copy link
Copy Markdown
Member Author

@brianteeman I have added a 3rd test for updating the with the Joomla Update component, as you suggested. Regarding what you show in your video: Maybe something is wrong on MySQL then with the db checker? On PostgreSQL you can see in my 2nd test that it is necessary to update the old scripts. Otherwise if not updated you would end in the endless fixer loop as I described before.

@brianteeman
Copy link
Copy Markdown
Contributor

Steps to reproduce why the old updates do not need to be changed

  1. Add just this file 3.9.16-2020-02-15.sql
  2. Go to DB checker
  3. It should look like this
    image
  4. Apply db fix
  5. It will now look like this
    image

So please show me why you need to change the old files

@richard67
Copy link
Copy Markdown
Member Author

richard67 commented Feb 15, 2020

@brianteeman Do following: On a clean staging apply from this PR only the changed files joomla.sql for nex installations and only add the new update SQL files 3.9.16-2020-02-15.sql. Then make a new installation. Then login to backend and check "Extensions -> Manage -> Database". It will show what happens when making a new installation with the joomla.sql modified by this PR and not having the old sql update files modified.

@brianteeman
Copy link
Copy Markdown
Contributor

So I can now confirm the issue on new installs only and NOT on upgrades. To me thats an issue in the installer that should be fixed. You shouldn't even have the update sql files on a new install.

@richard67
Copy link
Copy Markdown
Member Author

So I can now confirm the issue on new installs only and NOT on upgrades. To me thats an issue in the installer that should be fixed. You shouldn't even have the update sql files on a new install.

Agree, but thats a larger, conceptional issue not touched by this PR. I agree with you about how it should be. And I hope I ever have the time and the courage to fix that.

@brianteeman and @jwaisner Please waith with testing the 3rd test with the update component .. I have to fix the xml so Joomla Update finds an update.

@brianteeman
Copy link
Copy Markdown
Contributor

I stand by my comment that old update sql files should be immutable. The fact you are changing them is because of a bug elsewhere. Fix the problem, don't use a band aid.

@richard67
Copy link
Copy Markdown
Member Author

@jwaisner @brianteeman Update custom URL XML is fixed, you can text updating from any 3.9 version, but not from current staging or nightly because these already have same version as my update container. But you can test with any 3.9.x

@richard67
Copy link
Copy Markdown
Member Author

I stand by my comment that old update sql files should be immutable. The fact you are changing them is because of a bug elsewhere. Fix the problem, don't use a band aid.

@brianteeman I promise you now to fix that during our both lifetime, but it's not a small thing so it really needs a bit time, and the issue solved with this PR (and the preceeding one) has to be fixed before.

@chmst
Copy link
Copy Markdown
Contributor

chmst commented Feb 15, 2020

I have tested this item ✅ successfully on 993254e

Tested only MySQL.

Following exactly the test instructions, everything works as described.


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

@HLeithner
Copy link
Copy Markdown
Member

Since our db fix can't handle it correctly we don't have another option.

@alikon
Copy link
Copy Markdown
Contributor

alikon commented Feb 16, 2020

I have tested this item ✅ successfully on 993254e

tested on postgresql 11.5


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

@alikon
Copy link
Copy Markdown
Contributor

alikon commented Feb 16, 2020

RTC


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

@joomla-cms-bot joomla-cms-bot added the RTC This Pull Request is Ready To Commit label Feb 16, 2020
@alikon
Copy link
Copy Markdown
Contributor

alikon commented Feb 16, 2020

the main point here is:

  • to remove wrong DDL a field type like TEXT cannot have default

plus we need to do the same on J4 as an example
https://github.com/joomla/joomla-cms/blob/4.0-dev/installation/sql/mysql/joomla.sql#L747

@alikon alikon self-requested a review February 16, 2020 08:42
@richard67
Copy link
Copy Markdown
Member Author

richard67 commented Feb 16, 2020

@brianteeman One more explanation for you, not because I want to argue who is right or wrong but because I want you and other readers understand. Regarding your gif: The db checker checks only database stuff which appears in any update sql script. Furthermore, for create table statements or create index it doesn't check the table or index details, it checks only if the table or index with that name exists or not. That means when you change in db the type of a table column which doesn't appear in any update sql script in any "alter table ... modify ..." or "alter table ... change ..." statement, the db checker will not notice it. I think this is what your animated gif shows. This just for your and others' understanding.

@richard67
Copy link
Copy Markdown
Member Author

plus we need to do the same on J4 as an example
https://github.com/joomla/joomla-cms/blob/4.0-dev/installation/sql/mysql/joomla.sql#L747

Yes, this here has to be merged up into 3.10-dev and 4.0-dev after merged into staging, and it might have to be completed in J4 then by handling columns having been added in J4. I will keep an eye on it and if no bus hits me before will do that work then.

@richard67
Copy link
Copy Markdown
Member Author

Important for maintainers: When merging, please don't do a squash commit. I don't want the commit history and so the credits for the author of the original PR being lost.

@richard67
Copy link
Copy Markdown
Member Author

Last commit was only a grammar change in a comment, so reviews and tests and RTC should still be valid.

@wilsonge wilsonge merged commit 90736a8 into joomla:staging Feb 18, 2020
@joomla-cms-bot joomla-cms-bot removed the RTC This Pull Request is Ready To Commit label Feb 18, 2020
@wilsonge
Copy link
Copy Markdown
Contributor

I think we all agree the db fixer tool needs to be adapted to an approach that makes it immutable. But given we don't have that agree modification the old files is an unfortunate reality :(

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.

9 participants