From 7d85ed44dd25047bfba1cbd43cf23f2cafbde31d Mon Sep 17 00:00:00 2001 From: Madhura Jayaratne Date: Tue, 2 Jun 2015 17:27:33 +0530 Subject: [PATCH] Simplify the logic Signed-off-by: Madhura Jayaratne --- libraries/plugins/export/ExportSql.class.php | 30 +++++++++----------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/libraries/plugins/export/ExportSql.class.php b/libraries/plugins/export/ExportSql.class.php index 88b4399533..cccd7cee4e 100644 --- a/libraries/plugins/export/ExportSql.class.php +++ b/libraries/plugins/export/ExportSql.class.php @@ -1619,25 +1619,21 @@ class ExportSql extends ExportPlugin ); $tmp_str = $sql_lines[$j]; if (! $sql_backquotes) { - $matches = array(); - $matched = preg_match( + $tmp_str = preg_replace_callback( '/REFERENCES[\s]([\S]*)[\s]\(([\S]*)\)/', - $tmp_str, - $matches + function ($matches) { + global $compat, $sql_backquotes; + + $refTable = PMA_Util::backquoteCompat( + $matches[1], $compat, $sql_backquotes + ); + $refColumn = PMA_Util::backquoteCompat( + $matches[2], $compat, $sql_backquotes + ); + return 'REFERENCES ' . $refTable . ' (' . $refColumn . ')'; + }, + $tmp_str ); - if ($matched) { - $refTable = PMA_Util::backquoteCompat( - $matches[1], $compat, $sql_backquotes - ); - $refColumn = PMA_Util::backquoteCompat( - $matches[2], $compat, $sql_backquotes - ); - $tmp_str = preg_replace( - '/REFERENCES[\s]([\S]*)[\s]\(([\S]*)\)/', - 'REFERENCES ' . $refTable . ' (' . $refColumn . ')', - $tmp_str - ); - } } if ($posConstraint === false) { $tmp_str = preg_replace(