Fixed ChangeLoggable behavior broken with optIn = true

PaulB

Well-known member
Affected version
2.2.1
Setting a column definition's changeLog property to true results in the wrong code path being taken; it's interpreted as 'changeLog' => 'customFields'. This is problematic when optIn is enabled, since the intention is to set changeLog to true in that scenario.

Lines 58-65 of the ChangeLoggable behavior:
PHP:
if ($this->config['optIn'])
{
    // must explicitly list columns to log
    if (empty($definition['changeLog']))
    {
        continue;
    }
}

Lines 83-87 of the ChangeLoggable behavior:
PHP:
if (isset($definition['changeLog']) && $definition['changeLog'] == 'customFields')
{
    $changes += $this->getCustomFieldChanges($oldValue, $newValue, $column);
    continue;
}

If optIn is true, the changeLog column property becomes problematic: it can't be set to true because $definition['changeLog'] == 'customFields' will return true, since true == 'customFields'. Line 83 should be changed to:
PHP:
if (isset($definition['changeLog']) && $definition['changeLog'] === 'customFields')
 
Thank you for reporting this issue, it has now been resolved. We are aiming to include any changes that have been made in a future XF release (2.2.2).

Change log:
Fix opt-in functionality of the entity changelog behavior
There may be a delay before changes are rolled out to the XenForo Community.
 
Back
Top Bottom