cvs: pear /MDB/MDB Manager.php Parser.php

From: Date: Mon, 13 Jan 2003 14:26:23 +0000
Subject: cvs: pear /MDB/MDB Manager.php Parser.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-8221@lists.php.net to get a copy of this message
lsmith Mon Jan 13 09:26:23 2003 EDT Modified files: /pear/MDB/MDB Parser.php Manager.php Log: fixed error handling when parsing xml schema files (this may need some further attention) Index: pear/MDB/MDB/Parser.php diff -u pear/MDB/MDB/Parser.php:1.27 pear/MDB/MDB/Parser.php:1.28 --- pear/MDB/MDB/Parser.php:1.27 Tue Nov 12 18:53:36 2002 +++ pear/MDB/MDB/Parser.php Mon Jan 13 09:26:23 2003 @@ -42,7 +42,7 @@ // | Author: Christian Dickmann <dickmann@php.net> | // +----------------------------------------------------------------------+ // -// $Id: Parser.php,v 1.27 2002/11/12 23:53:36 lsmith Exp $ +// $Id: Parser.php,v 1.28 2003/01/13 14:26:23 lsmith Exp $ // require_once 'XML/Parser.php'; @@ -98,7 +98,7 @@ function MDB_Parser($variables, $fail_on_invalid_names = 1) { $this->XML_Parser(); - $this->variables = $variables; + $this->variables = $variables; $this->fail_on_invalid_names = $fail_on_invalid_names; } @@ -323,12 +323,12 @@ if (isset($this->database_definition['create']) && !$this->is_boolean($this->database_definition['create'])) { - $this->raiseError('field "create" has to be 1 or 0', $xp); + $this->raiseError('field "create" has to be 1 or 0', $xp); }; if (isset($this->database_definition['override']) && !$this->is_boolean($this->database_definition['override'])) { - $this->raiseError('field "override" has to be 1 or 0', $xp); + $this->raiseError('field "override" has to be 1 or 0', $xp); }; if (!isset($this->database_definition['name']) || !$this->database_definition['name']) { $this->raiseError('database needs a name', $xp); @@ -342,7 +342,6 @@ }; }; }; - if (MDB::isError($this->error)) { $this->database_definition = $this->error; }; @@ -419,18 +418,22 @@ function raiseError($msg, $xp = NULL) { - if ($this->error !== NULL) { - return FALSE; + if ($this->error === NULL) { + if(is_resource($msg)) { + $error = "Parser error: "; + $xp = $msg; + } else { + $error = "Parser error: \"".$msg."\"\n"; + } + if($xp != NULL) { + $byte = @xml_get_current_byte_index($xp); + $line = @xml_get_current_line_number($xp); + $column = @xml_get_current_column_number($xp); + $error .= "Byte: $byte; Line: $line; Col: $column\n"; + } + $this->error = PEAR::raiseError(NULL, MDB_ERROR_MANAGER_PARSE, NULL, NULL, + $error, 'MDB_Error', TRUE); }; - $error = "Parser error: \"".$msg."\"\n"; - if($xp != NULL) { - $byte = @xml_get_current_byte_index($xp); - $line = @xml_get_current_line_number($xp); - $column = @xml_get_current_column_number($xp); - $error .= "Byte: $byte; Line: $line; Col: $column\n"; - } - $this->error = PEAR::raiseError(NULL, MDB_ERROR_MANAGER_PARSE, NULL, NULL, - $error, 'MDB_Error', TRUE); return FALSE; } Index: pear/MDB/MDB/Manager.php diff -u pear/MDB/MDB/Manager.php:1.67 pear/MDB/MDB/Manager.php:1.68 --- pear/MDB/MDB/Manager.php:1.67 Sat Nov 23 18:51:25 2002 +++ pear/MDB/MDB/Manager.php Mon Jan 13 09:26:23 2003 @@ -42,7 +42,7 @@ // | Author: Lukas Smith <smith@backendmedia.com> | // +----------------------------------------------------------------------+ // -// $Id: Manager.php,v 1.67 2002/11/23 23:51:25 lsmith Exp $ +// $Id: Manager.php,v 1.68 2003/01/13 14:26:23 lsmith Exp $ // require_once 'MDB/Parser.php'; @@ -1445,15 +1445,17 @@ function parseDatabaseDefinitionFile($input_file, $variables, $fail_on_invalid_names = 1) { $parser =& new MDB_Parser($variables, $fail_on_invalid_names); - $res = $parser->setInputFile($input_file); - if (MDB::isError($res)) { - return $res; + $result = $parser->setInputFile($input_file); + if (MDB::isError($result)) { + return $result; }; - $res = $parser->parse(); - if (MDB::isError($res)) { - return $res; + $result = $parser->parse(); + if (MDB::isError($result)) { + return $result; }; - + if (MDB::isError($parser->error)) { + return $parser->error; + } return $parser->database_definition; }

« previous php.pear.cvs (#8221) next »