User tests: Successful: Unsuccessful:
Pull Request for Issue #24535 (part).
This PR fixes all datetime columns of com_fields tables so there will not be any Invalid value '0000-00-00 00:00:00' for datetime error anymore on MySQL 5.7 or later when strict mode is enabled, and the datetime (MySQL) or timestamp without time zone (PostgreSQL) columns will allow NULL values wherever useful/possible.
Following is changed:
#__fields's columns created_time and modified_time will be treated in the same way as e.g. columns created and modified of the #__banners table in PR #26372 , i.e. they will get no default value.#__fields_groups's columns created and modified.publish_up and publish_down of the #__banners table in PR #26372 .The default value is only used when inserting new records without specifying values for that particular column. Not having a default will enforce to insert new records with values for these columns being provided and throw an SQL error if some of these values is not specified, i.e. such errors will not be hidden anymore.
Old data will be updated as little as possible. The created and created_time columns will be not touched at all. We can assume that for core components there is no data with values '0000-00-00 00:00:00' on MySQL or '1970-01-01 00:00:00' on PostgreSQL, and data created by 3rd party components should not be modified. The modified and modified_time column will be set to the value of the created column only has value '0000-00-00 00:00:00' on MySQL or '1970-01-01 00:00:00' on '1970-01-01 00:00:00'. Our PHP already sets the modified time to the created time when saving new records, i.e. modified = created means never modified.
Testers please report back the database kind (MySQL or PostgreSQL) on which you have tested.
If you have both MySQL and PostgreSQL, please test on both if possible.
Test 1: New installation
configuration.php and delete all Joomla database tables in PhpMyAdmin or PhpPgAdmin (depending on your database type).datetime/timestamp without timezone columns.Result: See section "Expected result" below.
Test 2: Update sql script
installation/sql/mysql/joomla.sql into the SQL command window but don't execute the commands yet:SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
This switches off strict mode to the SQL will run on MySQL 5.7 or later.
administrator/components/com_admin/sql/updates/mysql/4.0.0-2019-09-25.sql or administrator/components/com_admin/sql/updates/postgresql/4.0.0-2019-09-25.sql (depending on your database type) into the SQL command window, in case of MySQL below the previously pasted commands, but don't execute the commands yet.#__ by your database prefix in the SQL statements pasted before in the SQL input window.datetime/timestamp without timezone columns.Result: See section "Expected result" below.
New Installation
Fields work as well as without this PR. In a MySQL database there are no columns of data type datetime having value '0000-00-00 00:00:00' in tables #__fields and #__fields_groups, and there is no invalid default value anymore in MySQL >= 5.7 with strict mode on. On PostgreSQL there are no columns of data type timestamp without time zone having value '0000-00-00 00:00:00' in these tables.
There is one exception: When checking in a field or a field group using com_checkin, the checked_out_time is set to '0000-00-00 00:00:00' on MySQL and '1970-01-01 00:00:00' on PosgreSQL. This will be changed with a separate, future PR for com_checkin. Checking in an item with the lock icon in list display works, i.e. there checked_out_time is set to NULL.
Update sql script
The statements are processed without error. The expected result is the same as for a new installation.
New Installation
On MySQL same as expected, but the default value of database columns of data type datetime having value '0000-00-00 00:00:00' in tables #__fields and #__fields_groups is invalid in MySQL >= 5.7 with strict mode on, and there might be values '0000-00-00 00:00:00'. On postgreSQL same as expected, but there might be values '1970-01-01 00:00:00' in the datetime columns of tables #__fields and #__fields_groups.
Maybe core developer docs and extension developer docs should be updated to encourage them not to use '0000-00-00 00:00:00' on MySQL anymore but use real NULL and not abuse '1970-01-01 00:00:00' on PostgreSQL as a speudo null date anymore and use real NULL values also there.
| Status | New | ⇒ | Pending |
| Category | ⇒ | SQL Administration com_admin Postgresql com_fields Installation |
| Labels |
Added:
?
|
||
| Title |
|
||||||
| Title |
|
||||||
I have tested this item
| Status | Pending | ⇒ | Ready to Commit |
RTC
RTC
| Status | Ready to Commit | ⇒ | Fixed in Code Base |
| Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2019-10-16 19:21:04 |
| Closed_By | ⇒ | wilsonge | |
| Labels |
Added:
?
|
||
Thanks!
I have tested this item✅ successfully on 768b6a0
on linux
php 7.3.8-1 & pgsql 11.5 (Ubuntu 11.5-1)
This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/26460.