From: stronk7 <stronk7>
Date: Sat, 24 Feb 2007 00:05:05 +0000 (+0000)
Subject: Only validate against schema if we have a schema. ;-)
X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=11548d9bf93dbfe18a99ce1a444f35770ac4a733;p=moodle.git

Only validate against schema if we have a schema. ;-)

Merged from MOODLE_18_STABLE
---

diff --git a/lib/xmldb/classes/XMLDBFile.class.php b/lib/xmldb/classes/XMLDBFile.class.php
index b39c8c7fbd..6e5dfdc5db 100644
--- a/lib/xmldb/classes/XMLDBFile.class.php
+++ b/lib/xmldb/classes/XMLDBFile.class.php
@@ -80,10 +80,14 @@ class XMLDBFile extends XMLDBObject {
         /// Create and load XML file
             $parser = new DOMDocument();
             $parser->load($this->path);
-        /// Validate XML file against schema
-            if (!$parser->schemaValidate($this->schema)) {
-            /// Get errors
-                $errors = libxml_get_errors();
+        /// Only validate if we have a schema
+            if (!empty($this->schema) && file_exists($this->schema)) {
+                $parser->schemaValidate($this->schema);
+            }
+        /// Check for errors
+            $errors = libxml_get_errors();
+        /// Prepare errors
+            if (!empty($errors)) {
             /// Create one structure to store errors
                 $structure = new XMLDBStructure($this->path);
             /// Add errors to structure