/** * Updates the database according to extension requirements * DBAL compliant (based on Install Tool code) * * @param string Extension key * @param array Extension information array * @return void */ function forceDBupdates($extKey, $extInfo) { $instObj = new t3lib_install(); // Updating tables and fields? if (is_array($extInfo['files']) && in_array('ext_tables.sql', $extInfo['files'])) { $fileContent = t3lib_div::getUrl($this->getExtPath($extKey, $extInfo['type']) . 'ext_tables.sql'); $FDfile = $instObj->getFieldDefinitions_fileContent($fileContent); if (count($FDfile)) { $FDdb = $instObj->getFieldDefinitions_database(TYPO3_db); $diff = $instObj->getDatabaseExtra($FDfile, $FDdb); $update_statements = $instObj->getUpdateSuggestions($diff); foreach ((array) $update_statements['add'] as $string) { $GLOBALS['TYPO3_DB']->admin_query($string); } foreach ((array) $update_statements['change'] as $string) { $GLOBALS['TYPO3_DB']->admin_query($string); } foreach ((array) $update_statements['create_table'] as $string) { $GLOBALS['TYPO3_DB']->admin_query($string); } } } // Importing static tables? if (is_array($extInfo['files']) && in_array('ext_tables_static+adt.sql', $extInfo['files'])) { $fileContent = t3lib_div::getUrl($this->getExtPath($extKey, $extInfo['type']) . 'ext_tables_static+adt.sql'); $statements = $instObj->getStatementArray($fileContent, 1); list($statements_table, $insertCount) = $instObj->getCreateTables($statements, 1); // Traverse the tables foreach ($statements_table as $table => $query) { $GLOBALS['TYPO3_DB']->admin_query('DROP TABLE IF EXISTS ' . $table); $GLOBALS['TYPO3_DB']->admin_query($query); if ($insertCount[$table]) { $statements_insert = $instObj->getTableInsertStatements($statements, $table); foreach ($statements_insert as $v) { $GLOBALS['TYPO3_DB']->admin_query($v); } } } } }
/** * Caches the field information. * * @return void */ public function cacheFieldInfo() { $extSQL = ''; $parsedExtSQL = array(); // try to fetch cached file first // file is removed when admin_query() is called if (file_exists(PATH_typo3conf . 'temp_fieldInfo.php')) { $fdata = unserialize(t3lib_div::getUrl(PATH_typo3conf . 'temp_fieldInfo.php')); $this->cache_autoIncFields = $fdata['incFields']; $this->cache_fieldType = $fdata['fieldTypes']; $this->cache_primaryKeys = $fdata['primaryKeys']; } else { // handle stddb.sql, parse and analyze $extSQL = t3lib_div::getUrl(PATH_site . 't3lib/stddb/tables.sql'); $parsedExtSQL = $this->Installer->getFieldDefinitions_fileContent($extSQL); $this->analyzeFields($parsedExtSQL); // loop over all installed extensions foreach ($GLOBALS['TYPO3_LOADED_EXT'] as $ext => $v) { if (!is_array($v) || !isset($v['ext_tables.sql'])) { continue; } // fetch db dump (if any) and parse it, then analyze $extSQL = t3lib_div::getUrl($v['ext_tables.sql']); $parsedExtSQL = $this->Installer->getFieldDefinitions_fileContent($extSQL); $this->analyzeFields($parsedExtSQL); } $cachedFieldInfo = array('incFields' => $this->cache_autoIncFields, 'fieldTypes' => $this->cache_fieldType, 'primaryKeys' => $this->cache_primaryKeys); $cachedFieldInfo = serialize($this->mapCachedFieldInfo($cachedFieldInfo)); // write serialized content to file t3lib_div::writeFile(PATH_typo3conf . 'temp_fieldInfo.php', $cachedFieldInfo); if (strcmp(t3lib_div::getUrl(PATH_typo3conf . 'temp_fieldInfo.php'), $cachedFieldInfo)) { die('typo3conf/temp_fieldInfo.php was NOT updated properly (written content didn\'t match file content) - maybe write access problem?'); } } }