User tests: Successful: Unsuccessful:
Pull Request for Issue #30546 .
Related to Pull Request #31450 .
Beginning with version 4, Joomla will stop to use the old fashioned pseudo null dates and support real null values for datetime columns in core database tables.
But some datetime columns shall not allow null values. These are mainly the created and modified dates of core content and the registration date and last visit date of users.
For the created time and the registration date we assumed that valid values are set in database, and for modified dates and last visit time we decided to do it like files systems do and set the modified and last visit dates equal to the created and registration dates. (You may like it or not, that's another discussion).
But on installations with a long update history it can happen that come old core content or some old users don't have a valid created or registration date, i.e. they have an old pseudo null date, i.e. our assumption was wrong.
If such an installation is updated to Joomla 4 and uses a MySQL or MariaDB database, you might get an SQL error or not when editing some content or user with such invalid created or registration dates and trying to save, depending on your database server settings. See issue #30546 for details.
In addition, with any kind of database it may happen that such content or users are sorted wrong when ordering by the created or the registration date, and so you may not find it when sorting by that date. That's why this PR changes stuff for PostgreSQL, too.
This pull request (PR) fixes the issue by updating the critical values to a fix default value 1980-01-01 00:00:00
when updating to Joomla 4.
Therefore it
The PR handles only those database columns where due to the software history of the core the problem really can happen. These are (table.colum
):
#__banners.created
#__categories.created_time
#__contact_details.created
#__content.created
#__newsfeeds.created
#__redirect_links.created_date
#__users.registerDate
The PR does not handle all possible datetime columns where bad null values could make a problem caused by come 3rd party extension not writing data in the right way.
In addition to this PR, another PR for 3.10-dev will be made, which informs the backend user in some way if critical datetime values have been found and helps to identify the affected tables and records, so the user can chose a different value than the default, e.g. the date when the site was created, and fix the bad created dates or registration dates before updating to Joomla 4. Currently I'm working on this with PR #31450 , but I might replace that PR by another, better one, instead of just rebase to 3.10-dev.
This pull request (PR) should be tested with different database types (MySQL or MariaDB and PostgreSQL).
Testers please report back which kind of database you have used for testing. If you have both types, test with both. Thanks in advance.
It needs a Joomla 3.10 installation (current 3.10-dev branch or last nightly build) which contains at least one example for each kind of database content handled with this PR.
The easiest way to get that is to install the 3.10 and at the end of the installation's "Finalisation" step chose to install testing sample data, then after installation enable the "System - Redirect" plugin and create a few redirect links and then create a few users.
Set some bad created or registration date for each kind of content by running the following sequence of SQL commands in an SQL client like e.g. phpMyAdmin or phpPgAdmin, depending on your database type.
But before executing the SQL, replace the #__
by your actual table prefix and the values for id
by appropriate values which exist in your database.
The values in the examples below are suitable for testing sample data except of the user id, this has to be adjusted to the id of the user created in the preparation step.
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
UPDATE `#__banners` SET `created` = '0000-00-00 00:00:00' WHERE `id` = 2;
UPDATE `#__categories` SET `created_time` = '0000-00-00 00:00:00' WHERE `id` = 14;
UPDATE `#__contact_details` SET `created` = '0000-00-00 00:00:00' WHERE `id` = 1;
UPDATE `#__content` SET `created` = '0000-00-00 00:00:00' WHERE `id` = 1;
UPDATE `#__newsfeeds` SET `created` = '0000-00-00 00:00:00' WHERE `id` = 1;
UPDATE `#__redirect_links` SET `created_date` = '0000-00-00 00:00:00' WHERE `id` = 1;
UPDATE `#__users` SET `registerDate` = '0000-00-00 00:00:00' WHERE `id` = 355;
The SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
is needed in order not to get an SQL error when the NO_ZERO_DATE
mode is set together with strict mode by default in an SQL session due to server settings.
UPDATE "#__banners" SET "created" = '1970-01-01 00:00:00' WHERE "id" = 2;
UPDATE "#__categories" SET "created_time" = '1970-01-01 00:00:00' WHERE "id" = 14;
UPDATE "#__contact_details" SET "created" = '1970-01-01 00:00:00' WHERE "id" = 1;
UPDATE "#__content" SET "created" = '1970-01-01 00:00:00' WHERE "id" = 1;
UPDATE "#__newsfeeds" SET "created" = '1970-01-01 00:00:00' WHERE "id" = 1;
UPDATE "#__redirect_links" SET "created_date" = '1970-01-01 00:00:00' WHERE "id" = 1;
UPDATE "#__users" SET "registerDate" = '1970-01-01 00:00:00' WHERE "id" = 355;
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SELECT 'Articles' AS `content_type`, `id` FROM `#__content` WHERE `created` = '0000-00-00 00:00:00'
UNION ALL
SELECT 'Banners' AS `content_type`, `id` FROM `#__banners` WHERE `created` = '0000-00-00 00:00:00'
UNION ALL
SELECT 'Categories' AS `content_type`, `id` FROM `#__categories` WHERE `created_time` = '0000-00-00 00:00:00'
UNION ALL
SELECT 'Contacts' AS `content_type`, `id` FROM `#__contact_details` WHERE `created` = '0000-00-00 00:00:00'
UNION ALL
SELECT 'News Feeds' AS `content_type`, `id` FROM `#__newsfeeds` WHERE `created` = '0000-00-00 00:00:00'
UNION ALL
SELECT 'Redirect Links' AS `content_type`, `id` FROM `#__redirect_links` WHERE `created_date` = '0000-00-00 00:00:00'
UNION ALL
SELECT 'Users' AS `content_type`, `id` FROM `#__users` WHERE `registerDate` = '0000-00-00 00:00:00'
ORDER BY `content_type`, `id`;
SELECT 'Articles' AS "content_type", "id" FROM "#__content" WHERE "created" = '1970-01-01 00:00:00'
UNION ALL
SELECT 'Banners' AS "content_type", "id" FROM "#__banners" WHERE "created" = '1970-01-01 00:00:00'
UNION ALL
SELECT 'Categories' AS "content_type", "id" FROM "#__categories" WHERE "created_time" = '1970-01-01 00:00:00'
UNION ALL
SELECT 'Contacts' AS "content_type", "id" FROM "#__contact_details" WHERE "created" = '1970-01-01 00:00:00'
UNION ALL
SELECT 'News Feeds' AS "content_type", "id" FROM "#__newsfeeds" WHERE "created" = '1970-01-01 00:00:00'
UNION ALL
SELECT 'Redirect Links' AS "content_type", "id" FROM "#__redirect_links" WHERE "created_date" = '1970-01-01 00:00:00'
UNION ALL
SELECT 'Users' AS "content_type", "id" FROM "#__users" WHERE "registerDate" = '1970-01-01 00:00:00'
ORDER BY "content_type", "id";
Result: The records which have been modified in step 2 are found.
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SELECT 'Articles' AS `content_type`, `id` FROM `#__content` WHERE `modified` = '0000-00-00 00:00:00'
UNION ALL
SELECT 'Banners' AS `content_type`, `id` FROM `#__banners` WHERE `modified` = '0000-00-00 00:00:00'
UNION ALL
SELECT 'Categories' AS `content_type`, `id` FROM `#__categories` WHERE `modified_time` = '0000-00-00 00:00:00'
UNION ALL
SELECT 'Contacts' AS `content_type`, `id` FROM `#__contact_details` WHERE `modified` = '0000-00-00 00:00:00'
UNION ALL
SELECT 'News Feeds' AS `content_type`, `id` FROM `#__newsfeeds` WHERE `modified` = '0000-00-00 00:00:00'
UNION ALL
SELECT 'Redirect Links' AS `content_type`, `id` FROM `#__redirect_links` WHERE `modified_date` = '0000-00-00 00:00:00'
ORDER BY `content_type`, `id`;
SELECT 'Articles' AS "content_type", "id" FROM "#__content" WHERE "modified" = '1970-01-01 00:00:00'
UNION ALL
SELECT 'Banners' AS "content_type", "id" FROM "#__banners" WHERE "modified" = '1970-01-01 00:00:00'
UNION ALL
SELECT 'Categories' AS "content_type", "id" FROM "#__categories" WHERE "modified_time" = '1970-01-01 00:00:00'
UNION ALL
SELECT 'Contacts' AS "content_type", "id" FROM "#__contact_details" WHERE "modified" = '1970-01-01 00:00:00'
UNION ALL
SELECT 'News Feeds' AS "content_type", "id" FROM "#__newsfeeds" WHERE "modified" = '1970-01-01 00:00:00'
UNION ALL
SELECT 'Redirect Links' AS "content_type", "id" FROM "#__redirect_links" WHERE "modified_date" = '1970-01-01 00:00:00'
ORDER BY "content_type", "id";
Result: The same records as in the previous step 2 are found except of the user record.
1980-01-01 00:00:00 (UTC)
, other previously valid values have not been touched.1980-01-01 00:00:00 (UTC)
, other previously valid values have not been touched.If a Joomla 3.10 installation contains old pseudo null dates for created and modified dates of the core database tables listed below and for the registration time of users, it will still have these values after the update to Joomla 4.
If a Joomla 3.10 installation contains old pseudo null dates for created and modified dates of the core database tables listed below and for the registration time of users, these values are changed to 1980-01-01 00:00:00 (UTC)
when updating to Joomla 4.
If the other PR for 3.10-dev will only implement a way to show that there is a problem with datetimes, e.g. a postinstall message or just a flag in the pre-update check, but will not provide display of all information necessary to identify where in particular the problems have been found, it will need some documentation telling the necessary steps (SQL statements), and the implementation of that 3.10-dev PR will have to link to that documentation.
Status | New | ⇒ | Pending |
Category | ⇒ | SQL Administration com_admin Postgresql |
https://github.com/gdimi/Joomla1.5.X/blob/master/libraries/joomla/database/table/category.php Just a note you can see in the old 1.5 trunk at that there was no concept of 1.5.x created dates in JTable. Looks like it was a 1.6 feature a286df0#diff-ed9c673a7fae33fb5a94c3085fb9b0fec6258a5da630a62d8710dda521244f2aR229
Labels |
Added:
?
?
|
Title |
|
It seems GitHub has a problem and so the ci jobs (appveyour, drone) are not started yet. See https://www.githubstatus.com/incidents/w5mwfprfbzzy . So it might take a while until packages for testing will be built.
Update: Problem seems to be solved.
I have tested this item
Very time consuming, but very clear instructions. So finally done.
PHP Built On Windows NT DESKTOP-1SB0O8R 10.0 build 18363 (Windows 10) AMD64
Database Type mysql
Database Version 10.4.11-MariaDB
Database Collation utf8_general_ci
Database Connection Collation utf8mb4_general_ci
Database Connection Encryption None
Database Server Supports Connection Encryption No
PHP Version 7.4.6
Status | Pending | ⇒ | Fixed in Code Base |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2021-01-03 20:06:39 |
Closed_By | ⇒ | HLeithner |
Thanks
Welcome. I've still gotta do the PR(s) for 3.10-dev with a postinstall message and some pre-update check. That may take a bit time.
Added the "Release Blocker" label as inherited from the issue.