xfrocks
Well-known member
Steps:
Actual result: 0 records found.
I have tracked this down and it turned out XenResource_DataWriter_Resource::updateCustomFields ran twice.
Stack trace #1
Stack trace #2
The bug exists because of these snippets of code within XenResource_DataWriter_Resource
$this->_updateCustomFields is an array from the beginning and in the second run of updateCustomFields, it clears all records before adding... nothing.
- Create new resource with 1 custom field inputed
- Save
- SELECT * FROM `xf_resource_field_value` WHERE `resource_id` = <new resource ID>
Actual result: 0 records found.
I have tracked this down and it turned out XenResource_DataWriter_Resource::updateCustomFields ran twice.
Stack trace #1
Code:
#0 XenResource_DataWriter_Resource->updateCustomFields() called at [/xf/library/XenResource/DataWriter/Resource.php:385]
#1 XenResource_DataWriter_Resource->_postSave() called at [/xf/library/XenForo/DataWriter.php:1397]
#2 XenForo_DataWriter->save() called at [/xf/library/xxx.php:164]
#3 xxx
#4 xxx
#5 XenForo_FrontController->dispatch(XenForo_RouteMatch Object ([_modifiedRoutePath] => ,[] => html,[] => XenForo_ControllerAdmin_Import,[] => resources/from-tsv,[] => importExternalData,[] => )) called at [/xf/library/XenForo/FrontController.php:134]
#6 XenForo_FrontController->run() called at [/xf/admin.php:13]
Stack trace #2
Code:
#0 XenResource_DataWriter_Resource->updateCustomFields() called at [/xf/library/XenResource/DataWriter/Resource.php:385]
#1 XenResource_DataWriter_Resource->_postSave() called at [/xf/library/XenForo/DataWriter.php:1397]
#2 XenForo_DataWriter->save() called at [/xf/library/XenResource/DataWriter/Version.php:224]
#3 XenResource_DataWriter_Version->_postSave() called at [/xf/library/XenForo/DataWriter.php:1397]
#4 XenForo_DataWriter->save() called at [/xf/library/XenResource/DataWriter/Resource.php:477]
#5 XenResource_DataWriter_Resource->_postSave() called at [/xf/library/XenForo/DataWriter.php:1397]
#6 XenForo_DataWriter->save() called at [/xf/library/xxx.php:164]
#7 xxx
#8 xxx
#9 XenForo_FrontController->dispatch(XenForo_RouteMatch Object ([_modifiedRoutePath] => ,[] => html,[] => XenForo_ControllerAdmin_Import,[] => resources/from-tsv,[] => importExternalData,[] => )) called at [/xf/library/XenForo/FrontController.php:134]
#10 XenForo_FrontController->run() called at [/xf/admin.php:13]
The bug exists because of these snippets of code within XenResource_DataWriter_Resource
PHP:
protected $_updateCustomFields = array();
...
public function updateCustomFields()
{
if (is_array($this->_updateCustomFields))
{
...
$this->_db->query('DELETE FROM xf_resource_field_value WHERE resource_id = ?', $resourceId);
...
}
}
$this->_updateCustomFields is an array from the beginning and in the second run of updateCustomFields, it clears all records before adding... nothing.