Index: branches/5.2.x/core/units/helpers/backup_helper.php =================================================================== diff -u -N -r14707 -r14870 --- branches/5.2.x/core/units/helpers/backup_helper.php (.../backup_helper.php) (revision 14707) +++ branches/5.2.x/core/units/helpers/backup_helper.php (.../backup_helper.php) (revision 14870) @@ -357,13 +357,13 @@ } /** - * Run given schema sqls and return error, if any + * Adds table prefix to given sql set * - * @param $sql - * @return string + * @param string $sql + * @return void * @access protected */ - protected function runSchemaText($sql) + protected function addTablePrefix(&$sql) { $table_prefix = 'restore' . TABLE_PREFIX; @@ -377,7 +377,19 @@ $sql = str_replace('CREATE TABLE ', 'CREATE TABLE IF NOT EXISTS ' . $table_prefix, $sql); $sql = str_replace('DROP TABLE ', 'DROP TABLE IF EXISTS ' . $table_prefix, $sql); + } + /** + * Run given schema sqls and return error, if any + * + * @param $sql + * @return string + * @access protected + */ + protected function runSchemaText($sql) + { + $this->addTablePrefix($sql); + $commands = explode("# --------------------------------------------------------", $sql); if ( count($commands) > 0 ) { @@ -412,18 +424,7 @@ $sql = $all_sqls[$line]; if ( strlen(trim($sql)) > 0 && substr($sql, 0, 1) != "#" ) { - $table_prefix = 'restore' . TABLE_PREFIX; - - if ( strlen($table_prefix) > 0 ) { - $replacements = Array ('INSERT INTO ', 'UPDATE ', 'ALTER TABLE ', 'DELETE FROM ', 'REPLACE INTO '); - - foreach ($replacements as $replacement) { - $sql = str_replace($replacement, $replacement . $table_prefix, $sql); - } - } - - $sql = str_replace('CREATE TABLE ', 'CREATE TABLE IF NOT EXISTS ' . $table_prefix, $sql); - $sql = str_replace('DROP TABLE ', 'DROP TABLE IF EXISTS ' . $table_prefix, $sql); + $this->addTablePrefix($sql); $sql = trim($sql); if ( strlen($sql) > 0 ) {