Skip to content
This repository was archived by the owner on Mar 12, 2025. It is now read-only.
This repository was archived by the owner on Mar 12, 2025. It is now read-only.

XML parsing error with complex action node #5

Description

@bretrzaun

I think I found a bug when loading workflow definitions from XML with somewhat complex action nodes.

Here is an example taken from the unit tests - slightly modified - making the error reproducible:

<?xml version="1.0" encoding="UTF-8"?>
<workflow name="ServiceObjectWithArguments3" version="1">
  <node id="1" type="Start">
    <outNode id="2"/>
  </node>
  <node id="2" type="Action" serviceObjectClass="ServiceObjectWithConstructor">
    <arguments>
      <array>
        <element key="first">
          <object class="ServiceObjectWithConstructor">
            <arguments>
              <array>
                <element>
                  <string>Sebastian</string>
                </element>
              </array>
            </arguments>
          </object>
        </element>
      </array>
    </arguments>
    <outNode id="3"/>
  </node>
  <node id="3" type="End"/>
</workflow>

I believe the source to this problem is in ezcWorkflowDefinitionStorageXml:xmlToVariable():
https://github.com/zetacomponents/Workflow/blob/master/src/definition_storage/xml.php#L592

                foreach ( $element->getElementsByTagName( 'element' ) as $element )
                {

When using getElementsByTagName() the outer loop also sees the inner array elements, which leeds to the failure.

I replaced it locally with:

                $elements = ezcWorkflowUtil::getChildNodes($element );
                foreach ($elements as $element)
                {
                    if ($element->tagName != 'element') continue;

which brings the expected result.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions