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

This commit is contained in:
skodak 2008-07-13 10:52:45 +00:00
parent 28a40b5ca2
commit 8e768c6d64
2 changed files with 3 additions and 1 deletions

View File

@ -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;
}

View File

@ -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);