From 8e768c6d64edc227ca3d57a9f7dd8d5a077d4557 Mon Sep 17 00:00:00 2001 From: skodak Date: Sun, 13 Jul 2008 10:52:45 +0000 Subject: [PATCH] MDL-15071 Fixes a regular expression in xmldb_object which breaks sentences with empty strings, it is possible to specify record id in statement (needed for database moving) - by Andrei Bautu --- lib/xmldb/xmldb_object.php | 2 +- lib/xmldb/xmldb_statement.php | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/xmldb/xmldb_object.php b/lib/xmldb/xmldb_object.php index ae4a3919a4..a780415bb8 100644 --- a/lib/xmldb/xmldb_object.php +++ b/lib/xmldb/xmldb_object.php @@ -414,7 +414,7 @@ class xmldb_object { /// Extract all the quoted elements from the string (skipping /// backslashed quotes that are part of the content. - preg_match_all("/('.*?[^\\\]')/is", $string, $matches); + preg_match_all("/(''|'.*?[^\\\\]')/is", $string, $matches); foreach (array_unique($matches[0]) as $key=>$value) { $foundquotes['<%'.$key.'%>'] = $value; } diff --git a/lib/xmldb/xmldb_statement.php b/lib/xmldb/xmldb_statement.php index dea35a86e6..c78bb269fd 100644 --- a/lib/xmldb/xmldb_statement.php +++ b/lib/xmldb/xmldb_statement.php @@ -153,11 +153,13 @@ class xmldb_statement extends xmldb_object { $fields = $this->getFieldsFromInsertSentence($sentence); $values = $this->getValuesFromInsertSentence($sentence); /// Check that we aren't inserting the id field +/* //ids should be the same when moving database if (in_array('id', $fields)) { $this->errormsg = 'Cannot insert the "id" field. It is an autonumeric column'; $this->debug($this->errormsg); $result = false; } +*/ if ($result && count($fields) == 0) { $this->errormsg = 'Missing fields in sentence "' . $sentence . '"'; $this->debug($this->errormsg); -- 2.39.5