Author: sb
Date: Fri Aug 3 16:52:05 2007
New Revision: 5814
Log:
- Implement issue #10918: Error messages when loading invalid XML.
Added:
trunk/Workflow/tests/data/NotWellFormed_1.xml
Modified:
trunk/Workflow/ChangeLog
trunk/Workflow/src/definition_storage/xml.php
trunk/Workflow/tests/definition_xml_test.php
Modified: trunk/Workflow/ChangeLog
==============================================================================
--- trunk/Workflow/ChangeLog [iso-8859-1] (original)
+++ trunk/Workflow/ChangeLog [iso-8859-1] Fri Aug 3 16:52:05 2007
@@ -4,6 +4,7 @@
- The marshalling of the node configuration is now handled in the individual
node classes. This makes it possible to have custom node classes handled by
the XML definition storage.
+- Implemented issue #10918: Error messages when loading invalid XML.
- Fixed issue #11068: Implement ezcWorkflowExecution::hasVariable().
1.0.1 - Monday 30 July 2007
Modified: trunk/Workflow/src/definition_storage/xml.php
==============================================================================
--- trunk/Workflow/src/definition_storage/xml.php [iso-8859-1] (original)
+++ trunk/Workflow/src/definition_storage/xml.php [iso-8859-1] Fri Aug 3
16:52:05 2007
@@ -62,15 +62,39 @@
// Load the document.
$document = new DOMDocument;
- $loaded = @$document->load( $filename );
-
- if ( $loaded === false )
+
+ if ( is_readable( $filename ) )
+ {
+ libxml_use_internal_errors( true );
+
+ $loaded = @$document->load( $filename );
+
+ if ( $loaded === false )
+ {
+ $message = '';
+
+ foreach ( libxml_get_errors() as $error )
+ {
+ $message .= $error->message;
+ }
+
+ throw new ezcWorkflowDefinitionStorageException(
+ sprintf(
+ 'Could not load workflow "%s" (version %d) from "%s".%s',
+
+ $workflowName,
+ $workflowVersion,
+ $filename,
+ $message != '' ? "\n" . $message : ''
+ )
+ );
+ }
+ }
+ else
{
throw new ezcWorkflowDefinitionStorageException(
sprintf(
- 'Could not load workflow "%s" (version %d) from "%s"',
- $workflowName,
- $workflowVersion,
+ 'Could not read file "%s".',
$filename
)
);
Added: trunk/Workflow/tests/data/NotWellFormed_1.xml
==============================================================================
--- trunk/Workflow/tests/data/NotWellFormed_1.xml (added)
+++ trunk/Workflow/tests/data/NotWellFormed_1.xml [iso-8859-1] Fri Aug 3
16:52:05 2007
@@ -1,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<workflow name="NotWellFormed" version="1">
+ <node><node></node>
+</workflow>
Modified: trunk/Workflow/tests/definition_xml_test.php
==============================================================================
--- trunk/Workflow/tests/definition_xml_test.php [iso-8859-1] (original)
+++ trunk/Workflow/tests/definition_xml_test.php [iso-8859-1] Fri Aug 3
16:52:05 2007
@@ -461,6 +461,20 @@
$this->fail();
}
+ public function testExceptionWhenLoadingNotWellFormedWorkflow()
+ {
+ try
+ {
+ $this->definition->loadByName( 'NotWellFormed' );
+ }
+ catch ( ezcWorkflowDefinitionStorageException $e )
+ {
+ return;
+ }
+
+ $this->fail();
+ }
+
protected function readActual( $name )
{
$actual = str_replace(
--
svn-components mailing list
[email protected]
http://lists.ez.no/mailman/listinfo/svn-components