[DATABASE] Update "modified" in Managed_DataObject instead of a DBMS trigger

Instead of relying on the MariaDB's ON UPDATE CURRENT_TIMESTAMP trigger update
"modified" attributes in Managed_DataObject. Every raw query that needs
adjusting is adjusted, as they won't update "modified" automatically anymore.

The main goal behind this change is to fix "modified" updates on PostgreSQL.
This commit is contained in:
Alexei Sorokin
2020-07-27 19:10:33 +03:00
parent 341f3d0ea5
commit ec86de2bc4
17 changed files with 224 additions and 140 deletions

View File

@@ -104,10 +104,15 @@ if ($notice->N) {
// but we're going to have to decache them individually anyway and
// it doesn't hurt to make sure we don't hold up replication with
// what might be a very slow single UPDATE.
$query = sprintf('UPDATE notice ' .
'SET lat=NULL,lon=NULL,location_ns=NULL,location_id=NULL ' .
'WHERE id=%d', $notice->id);
$ok = $update->query($query);
$ok = $update->query(sprintf(
<<<'END'
UPDATE notice
SET lat = NULL, lon = NULL, location_ns = NULL, location_id = NULL
modified = CURRENT_TIMESTAMP
WHERE id = %d
END,
$notice->getID()
));
if ($ok) {
// And now we decache him manually, as query() doesn't know what we're doing...
$orig->decache();