Page Menu
Home
In-Portal Phabricator
Search
Configure Global Search
Log In
Files
F859975
D387.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Tue, Apr 29, 8:28 PM
Size
2 KB
Mime Type
text/x-diff
Expires
Wed, Apr 30, 8:28 PM (3 h, 38 m)
Engine
blob
Format
Raw Data
Handle
611689
Attached To
D387: INP-1789 - Teach "Changes Log" section to respect "kDBItem::Update" calls with limited field set
D387.diff
View Options
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
Log In to Comment