[4.0] Replace the zero datetime value '0000-00-00 00:00:00' by the real NULL value#21901
Conversation
|
I like the change. I was always wondering why we bloat the rows with such 0 dates instead of null. |
|
|
||
| -- Use 0 instead of '0000-00-00 00:00:00' to not get 'Invalid default value for ...' | ||
| UPDATE `#__modules` SET | ||
| `publish_up` = CASE WHEN `publish_up` IN (0, '1000-01-01 00:00:00') THEN NULL ELSE `publish_up` END, |
There was a problem hiding this comment.
shouldn't be IN (0, '1000-01-01 00:00:00', '0000-00-00 00:00:00')
There was a problem hiding this comment.
0 == '0000-00-00 00:00:00' in mysql. This is almost the same.
If we want to be strict then it should be IN ('0000-00-00 00:00:00', '1000-01-01 00:00:00') but then in phpmyadmin on mysql 5.7 I got error Invalid default value for ...
There was a problem hiding this comment.
yes cause phpmyadmin have a standard/default sql_mode for mysql > 5.7
but for mysql server < 5.7 is always true that 0 == '0000-00-00 00:00:00' ?
not sure depending on sql_mode settings
|
we should do this now in 4.0 or never more |
40f8046 to
4049165
Compare
|
Ready for core review and test:) |
|
By adding patch from |
libraries/src/Table/Module.php
Outdated
| // Set publish_up, publish_down and checked_out_time to null date if not set | ||
| if (!$this->publish_up) | ||
| // Pre-processing by observers | ||
| $event = AbstractEvent::create( |
There was a problem hiding this comment.
Can we do the events in a new pr, so we can focus here on the null issue?
|
In the "Files changed" tab it is probably not visible. I copy&paste I will change the order of methods in the file, and the diff view should be more readable. |
|
Would be good if we can do it without copy paste. Can you not expand the query with an "or is null" in Table.php? |
Read carefully, this is an update query ( - ->set($this->_db->quoteName($checkedOutTimeField) . ' = ' . $this->_db->quote($this->_db->getNullDate()));
+ ->set($this->_db->quoteName($checkedOutTimeField) . ' = NULL'); |
|
I changed the code and now should be more readable, without overloading |
|
@alikon @tonypartridge @ggppdk @Bakual I am asking you for a test, at least for a part, I know people are very busy. If this go then I can work on the rest of tables. |
|
I have tested this item ✅ successfully on b3e640c I have tested with MySQL also looked to see if there are more places to be updated with usage of This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/21901. |
|
on my to do list |
|
Can we get here some tests? Would be nice to get it in. |
|
I have tested this item ✅ successfully on a692e02 This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/21901. |
|
There is some conflicts so I have to resolve it. @wilsonge do you have time to review the code? |
a692e02 to
b9a01f7
Compare
|
I rebased PR. There were conflicts in sql files. Now there is need one more test. |
|
Would be good to get some more tests here and the conflicts fixed, so we can get it merged. |
|
I did what I could. Your turn. |
|
So what is the status with this PR ? |
|
Let's go for this. I think we still have other compatibility issues. But this seems like a positive starting point. |
|
@franz-wohlkoenig needs more. this rolls it out for modules. this will need rolling out everywhere that has a publish up/down column (com_content etc etc) |
|
Members may I help with further PRs ? |
|
Fine by me |
Where in are the further changes to be made? |
|
Tested that and works. |

Pull Request for Issue # .
Summary of Changes
This PR changes only datetimes in the module table.
No more zero dates like "0000-00-00 00:00:00" in the module table.
Method
checkIn()is only added (almost copy/paste) to set columncheck_out_timeto NULL.At method
store()the default value has been changed to$updateNulls = trueto be able to saveNULLvalues.TODO
missing changes for the install files (Mysql, PostgreSQL)missing changes in the update files for Postgresql versionChanges for other tables should be made in the next PRs
Testing Instructions
First way:
The
UPDATE ...query won't be applied by theFIXbutton. You can do it manually (in phpMyAdmin), but it is not required, the system will work anyway!Second way:
configuration.phpand install joomla 4.0 again (also you can test sample data).In both cases:
Test publish_up,
publish_downandcheck_out_timecolumns. Everything work as before.Expected result
You can create, edit and save modules.
Modules are loaded normally on backend and frontend.
How to revert changes in your test db