/** * Looks if the specified table exists and if not create it with the key- * field (uid). Then it syncs the DB-fields with the fields found in the form * with help of template parser */ protected function createTable() { $fields = $this->getFormFields(); if ($this->settings['excludeFields']) { $excludes = t3lib_div::trimExplode(',', $this->settings['excludeFields']); foreach ($excludes as $exclude) { unset($fields[$exclude]); } } if (Tx_Formhandler_Globals::$settings['debug']) { $this->db->debugOutput = 1; } $res = $this->db->sql_query("SHOW TABLES LIKE '" . $this->table . "'"); if (!$this->db->sql_num_rows($res)) { $query = "CREATE TABLE `" . $this->table . "` (\n\t\t\t\t`" . $this->key . "` INT( 11 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY\n\t\t\t)"; $this->db->sql_query($query); Tx_Formhandler_StaticFuncs::debugMessage('sql_request', array($query)); $dbFields = array($this->key); } else { $dbFields = array_keys($this->db->admin_get_fields($this->table)); } $createFields = array_diff($fields, $dbFields); if (count($createFields)) { $sql = 'ALTER TABLE ' . $this->table . ' ADD `'; $sql .= implode('` ' . $this->newFieldsSqlAttribs . ', ADD `', $createFields); $sql .= '` ' . $this->newFieldsSqlAttribs . ''; $this->db->sql_query($sql); Tx_Formhandler_StaticFuncs::debugMessage('sql_request', array($sql)); if ($this->db->sql_error()) { Tx_Formhandler_StaticFuncs::debugMessage('error', array($this->db->sql_error()), 3); } } }
/** * Clear the TYPO3 page cache for the given record. * If the record lies on a page, then we clear the cache of this page. * If the record has no PID column, we clear the cache of the current page as best-effort. * * Much of this functionality is taken from t3lib_tcemain::clear_cache() which unfortunately only works with logged-in BE user. * * @param $tableName Table name of the record * @param $uid UID of the record * @return void */ protected function clearPageCache($tableName, $uid) { $extbaseSettings = Tx_Extbase_Dispatcher::getExtbaseFrameworkConfiguration(); if (isset($extbaseSettings['persistence']['enableAutomaticCacheClearing']) && $extbaseSettings['persistence']['enableAutomaticCacheClearing'] === '1') { } else { // if disabled, return return; } $pageIdsToClear = array(); $storagePage = NULL; $columns = $this->databaseHandle->admin_get_fields($tableName); if (array_key_exists('pid', $columns)) { $result = $this->databaseHandle->exec_SELECTquery('pid', $tableName, 'uid=' . intval($uid)); if ($row = $this->databaseHandle->sql_fetch_assoc($result)) { $storagePage = $row['pid']; $pageIdsToClear[] = $storagePage; } } elseif (isset($GLOBALS['TSFE'])) { // No PID column - we can do a best-effort to clear the cache of the current page if in FE $storagePage = $GLOBALS['TSFE']->id; $pageIdsToClear[] = $storagePage; } if ($storagePage === NULL) { return; } if (!isset($this->pageTSConfigCache[$storagePage])) { $this->pageTSConfigCache[$storagePage] = t3lib_BEfunc::getPagesTSconfig($storagePage); } if (isset($this->pageTSConfigCache[$storagePage]['TCEMAIN.']['clearCacheCmd'])) { $clearCacheCommands = t3lib_div::trimExplode(',', strtolower($this->pageTSConfigCache[$storagePage]['TCEMAIN.']['clearCacheCmd']), 1); $clearCacheCommands = array_unique($clearCacheCommands); foreach ($clearCacheCommands as $clearCacheCommand) { if (t3lib_div::testInt($clearCacheCommand)) { $pageIdsToClear[] = $clearCacheCommand; } } } // TODO check if we can hand this over to the Dispatcher to clear the page only once, this will save around 10% time while inserting and updating Tx_Extbase_Utility_Cache::clearPageCache($pageIdsToClear); }