Skip to content

Commit 7f12966

Browse files
authored
Fix default value for modManagerLog.occurred column (#16527)
### What does it do? Adds a default value for the datetime column in the modx_manager_log table that is compatible with strict modes, which may be enabled in some environments. Re-up of #15736 with migration ### Why is it needed? Beginning with MySQL > 5.7.8 added strict modes ERROR_FOR_DIVISION_BY_ZERO, NO_ZERO_DATE, NO_ZERO_IN_DATE. With these strict modes enabled, a datetime default value cannot be NULL and must be > '0000-00-00'. ### How to test Install/update on MySQL 5.7.8 ### Related issue(s)/PR(s) Re-up of #15736 Backport of #16526
1 parent a6fc2d9 commit 7f12966

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

core/model/modx/mysql/modmanagerlog.map.inc.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
'fields' =>
1616
array (
1717
'user' => 0,
18-
'occurred' => NULL,
18+
'occurred' => 'CURRENT_TIMESTAMP',
1919
'action' => '',
2020
'classKey' => '',
2121
'item' => '0',
@@ -35,8 +35,8 @@
3535
array (
3636
'dbtype' => 'datetime',
3737
'phptype' => 'datetime',
38-
'null' => true,
39-
'default' => NULL,
38+
'null' => false,
39+
'default' => 'CURRENT_TIMESTAMP',
4040
),
4141
'action' =>
4242
array (

core/model/schema/modx.mysql.schema.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,7 @@
679679

680680
<object class="modManagerLog" table="manager_log" extends="xPDOSimpleObject">
681681
<field key="user" dbtype="int" precision="10" attributes="unsigned" phptype="integer" null="false" default="0" />
682-
<field key="occurred" dbtype="datetime" phptype="datetime" null="true" default="NULL" />
682+
<field key="occurred" dbtype="datetime" phptype="datetime" null="false" default="CURRENT_TIMESTAMP" />
683683
<field key="action" dbtype="varchar" precision="100" phptype="string" null="false" default="" />
684684
<field key="classKey" dbtype="varchar" precision="100" phptype="string" null="false" default="" />
685685
<field key="item" dbtype="varchar" precision="191" phptype="string" null="false" default="0" />
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
/**
3+
* MySQL upgrade script for 2.8.7
4+
*
5+
* @var modX $modx
6+
* @package setup
7+
*/
8+
9+
$class = 'modManagerLog';
10+
$table = $modx->getTableName($class);
11+
12+
$description = $this->install->lexicon('alter_column', array('column' => 'occurred', 'table' => $table));
13+
$this->processResults($class, $description, array($modx->manager, 'alterField'), array($class, 'occurred'));

0 commit comments

Comments
 (0)