Index: install/upgrades.php =================================================================== --- install/upgrades.php (revision 14719) +++ install/upgrades.php (working copy) @@ -614,7 +614,7 @@ function _moveDatabaseFolders() { // Tables: PageContent, Images - if ($this->Conn->TableFound('PageContent')) { + if ($this->Conn->TableFound('PageContent', true)) { // 1. replaces "/kernel/user_files/" references in content blocks $ml_helper =& $this->Application->recallObject('kMultiLanguageHelper'); /* @var $ml_helper kMultiLanguageHelper */ @@ -993,7 +993,7 @@ } // 2. process "PageContent" table - if ($this->Conn->TableFound(TABLE_PREFIX . 'PageContent')) { + if ($this->Conn->TableFound(TABLE_PREFIX . 'PageContent', true)) { $structure = $this->Conn->Query('DESCRIBE ' . TABLE_PREFIX . 'PageContent', 'Field'); if (!array_key_exists('l1_Translated', $structure)) { $sql = "ALTER TABLE " . TABLE_PREFIX . "PageContent @@ -1007,7 +1007,7 @@ } // 3. process "FormFields" table - if ($this->Conn->TableFound(TABLE_PREFIX . 'FormFields')) { + if ($this->Conn->TableFound(TABLE_PREFIX . 'FormFields', true)) { $structure = $this->Conn->Query('DESCRIBE ' . TABLE_PREFIX . 'FormFields', 'Field'); if (!$structure['FormId']['Key']) { $sql = "ALTER TABLE " . TABLE_PREFIX . "FormFields @@ -1027,7 +1027,7 @@ } // 4. process "FormSubmissions" table - if ($this->Conn->TableFound(TABLE_PREFIX . 'FormSubmissions')) { + if ($this->Conn->TableFound(TABLE_PREFIX . 'FormSubmissions', true)) { $structure = $this->Conn->Query('DESCRIBE ' . TABLE_PREFIX . 'FormSubmissions', 'Field'); if (!$structure['SubmissionTime']['Key']) { $sql = "ALTER TABLE " . TABLE_PREFIX . "FormSubmissions @@ -1444,7 +1444,7 @@ $ml_helper->createFields('emailevents'); $languages = $ml_helper->getLanguages(); - if ($this->Conn->TableFound(TABLE_PREFIX . 'EmailMessage')) { + if ($this->Conn->TableFound(TABLE_PREFIX . 'EmailMessage', true)) { $email_message_helper =& $this->Application->recallObject('EmailMessageHelper'); /* @var $email_message_helper EmailMessageHelper */ Index: kernel/application.php =================================================================== --- kernel/application.php (revision 14719) +++ kernel/application.php (working copy) @@ -445,7 +445,7 @@ */ public function refreshModuleInfo() { - if (defined('IS_INSTALL') && IS_INSTALL && !$this->TableFound('Modules')) { + if (defined('IS_INSTALL') && IS_INSTALL && !$this->TableFound('Modules', true)) { $this->registerModuleConstants(); return ; } @@ -2630,11 +2630,12 @@ * Allows to detect table's presense in database * * @param string $table_name + * @param bool $force * @return bool */ - function TableFound($table_name) + function TableFound($table_name, $force = false) { - return $this->Conn->TableFound($table_name); + return $this->Conn->TableFound($table_name, $force); } /** Index: kernel/db/db_connection.php =================================================================== --- kernel/db/db_connection.php (revision 14719) +++ kernel/db/db_connection.php (working copy) @@ -920,22 +920,30 @@ * Allows to detect table's presence in database * * @param string $table_name + * @param bool $force * @return bool * @access public */ - public function TableFound($table_name) + public function TableFound($table_name, $force = false) { - static $table_found = Array(); + static $table_found = false; + if ($table_found === false) { + $table_found = array_flip($this->GetCol('SHOW TABLES')); + } + if (!preg_match('/^'.preg_quote(TABLE_PREFIX, '/').'(.*)/', $table_name)) { $table_name = TABLE_PREFIX.$table_name; } - if (!isset($table_found[$table_name])) { - $table_found[$table_name] = $this->Query('SHOW TABLES LIKE "'.$table_name.'"'); + if ($force) { + if ($this->Query('SHOW TABLES LIKE '.$this->qstr($table_name))) { + $table_found[$table_name] = 1; + } else { + unset($table_found[$table_name]); + } } - - return $table_found[$table_name]; + return isset($table_found[$table_name]); } /** Index: kernel/managers/cache_manager.php =================================================================== --- kernel/managers/cache_manager.php (revision 14719) +++ kernel/managers/cache_manager.php (working copy) @@ -173,7 +173,7 @@ return $this->configVariables[$name]; } - if ( defined('IS_INSTALL') && IS_INSTALL && !$this->Application->TableFound('ConfigurationValues') ) { + if ( defined('IS_INSTALL') && IS_INSTALL && !$this->Application->TableFound('ConfigurationValues', true) ) { return false; } Index: kernel/session/session_storage.php =================================================================== --- kernel/session/session_storage.php (revision 14719) +++ kernel/session/session_storage.php (working copy) @@ -120,7 +120,7 @@ */ public function StoreSession($to_database = true) { - if ( defined('IS_INSTALL') && IS_INSTALL && $to_database && !$this->Application->TableFound($this->TableName) ) { + if ( defined('IS_INSTALL') && IS_INSTALL && $to_database && !$this->Application->TableFound($this->TableName, true) ) { return; } Index: units/custom_data/custom_data_event_handler.php =================================================================== --- units/custom_data/custom_data_event_handler.php (revision 14719) +++ units/custom_data/custom_data_event_handler.php (working copy) @@ -40,7 +40,7 @@ * Returns list of custom fields for a given $prefix * * @param $prefix - * + * * @return Array|bool * @access protected */ @@ -48,7 +48,7 @@ { static $custom_fields = Array (); - if (defined('IS_INSTALL') && IS_INSTALL && !$this->Application->TableFound('CustomField')) { + if (defined('IS_INSTALL') && IS_INSTALL && !$this->Application->TableFound('CustomField', true)) { return false; } @@ -141,7 +141,7 @@ $fields['cust_' . $custom_id] = $field_options; $fields['cust_' . $custom_id]['force_primary'] = !$custom_params['MultiLingual']; } - + $this->Application->setUnitOption($event->Prefix, 'Fields', $fields); } Index: units/helpers/multilanguage_helper.php =================================================================== --- units/helpers/multilanguage_helper.php (revision 14719) +++ units/helpers/multilanguage_helper.php (working copy) @@ -172,7 +172,9 @@ $table_name = $this->Application->getUnitOption($prefix, 'TableName'); $this->curFields = $this->Application->getUnitOption($prefix, 'Fields'); - if ( !($table_name && $this->curFields) || ($table_name && !$this->Conn->TableFound($table_name)) ) { + $need_forced_table_check = kUtil::constOn('IS_INSTALL'); + + if ( !($table_name && $this->curFields) || ($table_name && !$this->Conn->TableFound($table_name, $need_forced_table_check)) ) { // invalid config found or prefix not found return ; } @@ -245,7 +247,9 @@ $table_name = $this->Application->getUnitOption($prefix, 'TableName'); $this->curFields = $this->Application->getUnitOption($prefix, 'Fields'); - if ( !($table_name && $this->curFields) || ($table_name && !$this->Conn->TableFound($table_name)) ) { + $need_forced_table_check = kUtil::constOn('IS_INSTALL'); + + if ( !($table_name && $this->curFields) || ($table_name && !$this->Conn->TableFound($table_name, $need_forced_table_check)) ) { // invalid config found or prefix not found return ; }