phpList / phplist3

Fully functional Open Source email marketing manager for creating, sending, integrating, and analysing email campaigns and newsletters.
https://www.phplist.org
GNU Affero General Public License v3.0
734 stars 268 forks source link

Define timestamp columns explicitly #1019

Closed bramley closed 3 months ago

bramley commented 5 months ago

Description

As explained in #1015 prior to MySQL 8 when a phplist database was created timestamp columns were implicitly given a default of current_timestamp and on update current_timestamp. This was due to the default value for explicit_defaults_for_timestamp being OFF.

In MySQL 8 the default changed to ON, which means any databases created with MySQL 8, or MariaDB 10.5, have had timestamp columns created incorrectly leading to null values in those columns.

This PR changes the definitions of timestamp columns to be explicit so that new databases will be created correctly.

For existing databases, any affected columns that have null values are updated to have a valid value. The choices here only seem to be to copy a "created" value if one exists or to use the time of applying the update. The timestamp columns are then changed to have the required definition.

For clarity any places in the code that explicitly set a timestamp column to now() have been removed. There is one place, in processbounces.php that sets a timestamp to a different value, the date/time of a bounce. This has been untouched. The linktrack table has not been changed as it is now read-only.

Related Issue

1015

Screenshots (if appropriate):

michield commented 5 months ago

Haven't tested it, but looking at the code looks fine.

phpListDockerBot commented 3 months ago

This pull request has been mentioned on phpList Discuss. There might be relevant details there:

https://discuss.phplist.org/t/3-6-15-release-candidate-is-available-for-testing/9473/1

phpListDockerBot commented 3 months ago

This pull request has been mentioned on phpList Discuss. There might be relevant details there:

https://discuss.phplist.org/t/phplist-3-6-15-has-been-released/9495/1