Yoskaldyr
Well-known member
Datawriter get() method returns existing data if new data setted to null.
Example:
Possible fix for this, replace XenForo_DataWriter::get() with code:
Example:
PHP:
$dw = XenForo_DataWriter::create('Some_DataWriter_Class');
$dw->setExistingData($someId);
$a = $dw->get('somekey'); //$a = 'somedata';
$dw->set('somekey', 'newdata');
$a = $dw->get('somekey'); //$a = 'newdata';
$dw->set('somekey', null);
$a = $dw->get('somekey'); //$a = 'somedata'; not null as expected
$dw->save(); //in db somekey field saved as null
PHP:
public function get($field, $tableName = '')
{
$tables = $this->_getTableList($tableName);
foreach ($tables AS $tableName)
{
if (
isset($this->_newData[$tableName])
&& is_array($this->_newData[$tableName])
&& array_key_exists($field, $this->_newData[$tableName])
)
{
return $this->_newData[$tableName][$field];
}
else if (
isset($this->_existingData[$tableName])
&& is_array($this->_existingData[$tableName])
&& array_key_exists($field, $this->_existingData[$tableName])
)
{
return $this->_existingData[$tableName][$field];
}
}
return null;
}