diff --git a/ChangeLog b/ChangeLog index dec04b785a..663bc6d682 100644 --- a/ChangeLog +++ b/ChangeLog @@ -23,6 +23,7 @@ phpMyAdmin - ChangeLog - bug #4318 Default connection collation and sorting - bug #4683 Relational data is not properly updated on table rename - bug #4655 Undefined index: collation_connection (second patch) +- bug #4682 4.3.3 & 4.3.4 Import sql created by mysqldump fails on foreign keys --- Older ChangeLogs can be found on our project website --- http://www.phpmyadmin.net/old-stuff/ChangeLogs/ diff --git a/libraries/plugins/import/ImportSql.class.php b/libraries/plugins/import/ImportSql.class.php index 8fa36a9d59..05727d65a3 100644 --- a/libraries/plugins/import/ImportSql.class.php +++ b/libraries/plugins/import/ImportSql.class.php @@ -40,11 +40,6 @@ class ImportSql extends ImportPlugin */ private $_delimiterPosition = false; - /** - * @var string Query to execute - */ - private $_query = null; - /** * @var int Query start position */ @@ -217,10 +212,7 @@ class ImportSql extends ImportPlugin { //Search for closing quote $posClosingString = $this->_stringFctToUse['strpos']( - $this->_data, $this->_quote, - $this->_delimiterPosition + $this->_stringFctToUse['strlen']( - $this->_quote - ) + $this->_data, $this->_quote, $this->_delimiterPosition ); if (false === $posClosingString) { @@ -276,53 +268,45 @@ class ImportSql extends ImportPlugin $posClosingComment = $this->_stringFctToUse['strpos']( $this->_data, "\n", - $this->_delimiterPosition + $this->_stringFctToUse['strlen']( - $this->_openingComment - ) + $this->_delimiterPosition ); if (false === $posClosingComment) { return false; } //Move after the end of the line. $this->_delimiterPosition = $posClosingComment + 1; + $this->_isInComment = false; + $this->_openingComment = null; } elseif ('/*' === $this->_openingComment) { //Search for closing comment $posClosingComment = $this->_stringFctToUse['strpos']( $this->_data, '*/', - $this->_delimiterPosition + $this->_stringFctToUse['strlen']( - $this->_openingComment - ) + $this->_delimiterPosition ); if (false === $posClosingComment) { return false; } //Move after closing comment. $this->_delimiterPosition = $posClosingComment + 2; + $this->_isInComment = false; + $this->_openingComment = null; } else { //We shouldn't be able to come here. //throw new Exception('Unknown case.'); break; } - $this->_queryBeginPosition = $this->_delimiterPosition; - $this->_isInComment = false; - $this->_openingComment = null; - continue; } if ($this->_isInDelimiter) { - $posAfterKeyword = $this->_delimiterPosition - + $this->_stringFctToUse['strlen']( - $this->_delimiterKeyword - ); //Search for new line. if (!preg_match( "/^(.*)\n/", $this->_stringFctToUse['substr']( $this->_data, - $posAfterKeyword + $this->_delimiterPosition ), $matches, PREG_OFFSET_CAPTURE @@ -332,8 +316,8 @@ class ImportSql extends ImportPlugin $this->_setDelimiter($matches[1][0]); //Start after delimiter and new line. - $this->_queryBeginPosition = $posAfterKeyword + $matches[1][1] - + $this->_delimiterLength + 1; + $this->_queryBeginPosition = $this->_delimiterPosition + + $matches[1][1] + $this->_delimiterLength + 1; $this->_delimiterPosition = $this->_queryBeginPosition; $this->_isInDelimiter = false; $firstSqlDelimiter = null; @@ -355,7 +339,6 @@ class ImportSql extends ImportPlugin && $firstSqlDelimiter < $this->_firstSearchChar) ) { $this->_delimiterPosition = $firstSqlDelimiter; - $this->_fillQuery(); return true; } @@ -367,8 +350,8 @@ class ImportSql extends ImportPlugin if (in_array($specialChars, array('\'', '"', '`'))) { $this->_isInString = true; $this->_quote = $specialChars; - //Move after quote. - $this->_delimiterPosition = $this->_firstSearchChar; + //Move before quote. + $this->_delimiterPosition = $this->_firstSearchChar + 1; continue; } @@ -376,16 +359,17 @@ class ImportSql extends ImportPlugin if (in_array($specialChars, array('#', '-- ', '/*'))) { $this->_isInComment = true; $this->_openingComment = $specialChars; - //Move after comment opening. - $this->_delimiterPosition = $this->_firstSearchChar; - $this->_fillQuery(); + //Move before comment opening. + $this->_delimiterPosition = $this->_firstSearchChar + + $this->_stringFctToUse['strlen']($specialChars); continue; } //If DELIMITER is found. if ($specialChars === $this->_delimiterKeyword) { $this->_isInDelimiter = true; - $this->_delimiterPosition = $this->_firstSearchChar; + $this->_delimiterPosition = $this->_firstSearchChar + + $this->_stringFctToUse['strlen']($specialChars); continue; } } @@ -459,7 +443,11 @@ class ImportSql extends ImportPlugin } PMA_importRunQuery( - $this->_query, //Query to execute + $this->_stringFctToUse['substr']( + $this->_data, + $this->_queryBeginPosition, + $this->_delimiterPosition - $this->_queryBeginPosition + ), //Query to execute $this->_stringFctToUse['substr']( $this->_data, 0, @@ -468,7 +456,6 @@ class ImportSql extends ImportPlugin false, $sql_data ); - $this->_query = null; $this->_setData( $this->_stringFctToUse['substr']( @@ -625,20 +612,4 @@ class ImportSql extends ImportPlugin return $this->_dataLength; } - - /** - * Fill current query from indexes - * - * @return string Current query - */ - private function _fillQuery() - { - $this->_query .= $this->_stringFctToUse['substr']( - $this->_data, - $this->_queryBeginPosition, - $this->_delimiterPosition - $this->_queryBeginPosition - ); - - return $this->_query; - } }