Page MenuHomeIn-Portal Phabricator

D387.diff
No OneTemporary

File Metadata

Created
Tue, Apr 29, 8:28 PM

D387.diff

Index: branches/5.2.x/core/kernel/db/dbitem.php
===================================================================
--- branches/5.2.x/core/kernel/db/dbitem.php
+++ branches/5.2.x/core/kernel/db/dbitem.php
@@ -769,7 +769,7 @@
$affected_rows = $this->Conn->getAffectedRows();
if ( !$system_update && ($affected_rows > 0) ) {
- $this->setModifiedFlag(ChangeLog::UPDATE);
+ $this->setModifiedFlag(ChangeLog::UPDATE, $update_fields);
}
$this->saveCustomFields();
@@ -1185,16 +1185,18 @@
/**
* Set's modification flag for main prefix of current prefix to true
*
- * @param int $mode
- * @access private
+ * @param integer $mode Mode.
+ * @param array $update_fields Update fields.
+ *
+ * @return void
*/
- public function setModifiedFlag($mode = null)
+ public function setModifiedFlag($mode = null, array $update_fields = null)
{
$main_prefix = $this->Application->GetTopmostPrefix($this->Prefix);
$this->Application->StoreVar($main_prefix . '_modified', '1', true); // true for optional
- if ($this->ShouldLogChanges(true)) {
- $this->LogChanges($main_prefix, $mode);
+ if ( $this->ShouldLogChanges(true) ) {
+ $this->LogChanges($main_prefix, $mode, $update_fields);
if (!$this->IsTempTable()) {
/** @var kDBEventHandler $handler */
@@ -1222,7 +1224,7 @@
return $log_changes && !$this->Application->getUnitOption($this->Prefix, 'ForceDontLogChanges');
}
- protected function LogChanges($main_prefix, $mode)
+ protected function LogChanges($main_prefix, $mode, $update_fields = null)
{
if ( !$mode ) {
return ;
@@ -1282,7 +1284,16 @@
switch ( $mode ) {
case ChangeLog::UPDATE:
- $to_save = array_merge($this->GetTitleField(), $this->GetChangedFields());
+ $changed_fields = $this->GetChangedFields();
+
+ if ( $update_fields ) {
+ $changed_fields = array_intersect_key(
+ $changed_fields,
+ array_combine($update_fields, $update_fields)
+ );
+ }
+
+ $to_save = array_merge($this->GetTitleField(), $changed_fields);
break;
case ChangeLog::CREATE:

Event Timeline