[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

@@ -292,14 +292,16 @@ class Profile_tag extends Managed_DataObject
public static function moveTag($orig, $new)
{
$tags = new Profile_tag();
$qry = "UPDATE profile_tag SET tag = '%s', tagger = '%s' " .
"WHERE tag = '%s' AND tagger = '%s'";
$result = $tags->query(sprintf(
$qry,
$tags->escape($new->tag),
$tags->escape($new->tagger),
$tags->escape($orig->tag),
$tags->escape($orig->tagger)
<<<'END'
UPDATE profile_tag
SET tag = %1$s, tagger = %2$s, modified = CURRENT_TIMESTAMP
WHERE tag = %3$s AND tagger = %4$s
END,
$tags->_quote($new->tag),
$tags->_quote($new->tagger),
$tags->_quote($orig->tag),
$tags->_quote($orig->tagger)
));
if ($result === false) {