• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

As designed  XenForo_DataWriter::ERROR_SILENT... doesn't work...

Jaxel

Well-known member
#1
My code:
PHP:
public function buildModuleCache($module, $settings)
{
    $dw = XenForo_DataWriter::create('EWRporta_DataWriter_Cache', XenForo_DataWriter::ERROR_SILENT);
    if ($cache = $this->getCacheByName($module['module_name']))
    {
        $dw->setExistingData($cache);
    }
    else
    {
        $dw->set('module_name', $module['module_name']);
    }
    $dw->set('module_settings', $settings);
    $dw->save(); // this is line 38

    return true;
}
Yet I just got this error:
An exception occurred: Mysqli statement execute error : Duplicate entry 'StatusUpdates' for key 'module_name' in /library/Zend/Db/Statement/Mysqli.php on line 214
  1. Zend_Db_Statement_Mysqli->_execute() in Zend/Db/Statement.php at line 317
  2. Zend_Db_Statement->execute() in Zend/Db/Adapter/Abstract.php at line 479
  3. Zend_Db_Adapter_Abstract->query() in Zend/Db/Adapter/Abstract.php at line 574
  4. Zend_Db_Adapter_Abstract->insert() in XenForo/DataWriter.php at line 1500
  5. XenForo_DataWriter->_insert() in XenForo/DataWriter.php at line 1489
  6. XenForo_DataWriter->_save() in XenForo/DataWriter.php at line 1291
  7. XenForo_DataWriter->save() in EWRporta/Model/Cache.php at line 38
  8. EWRporta_Model_Cache->buildModuleCache() in EWRporta/ViewPublic/Portal.php at line 105
  9. EWRporta_ViewPublic_Portal->getModuleParams() in EWRporta/ViewPublic/Portal.php at line 46
  10. EWRporta_ViewPublic_Portal->renderHtml() in XenForo/ViewRenderer/Abstract.php at line 222
  11. XenForo_ViewRenderer_Abstract->renderViewObject() in XenForo/ViewRenderer/HtmlPublic.php at line 67
  12. XenForo_ViewRenderer_HtmlPublic->renderView() in XenForo/FrontController.php at line 533
  13. XenForo_FrontController->renderView() in XenForo/FrontController.php at line 156
  14. XenForo_FrontController->run() in /index.php at line 17
 

Mike

XenForo developer
Staff member
#2
That's sort of debatable. ERROR_SILENT silences errors triggered; we assume that you are checking for things like unique key limits yourself. If we suppress errors like this, there are various other types that could come up - I'm not sure whether we suppress them, though I could be persuaded either way I think.