Browse Source

Merge branch 'xml-view-fix' into master

Refs #7073
Mark Story 10 years ago
parent
commit
05fa5e3960
2 changed files with 4 additions and 2 deletions
  1. 3 1
      src/View/XmlView.php
  2. 1 1
      tests/TestCase/View/XmlViewTest.php

+ 3 - 1
src/View/XmlView.php

@@ -148,7 +148,9 @@ class XmlView extends View
                 if (is_numeric($alias)) {
                     $alias = $key;
                 }
-                $data[$rootNode][$alias] = $this->viewVars[$key];
+                if (array_key_exists($key, $this->viewVars)) {
+                    $data[$rootNode][$alias] = $this->viewVars[$key];
+                }
             }
         } else {
             $data = isset($this->viewVars[$serialize]) ? $this->viewVars[$serialize] : null;

+ 1 - 1
tests/TestCase/View/XmlViewTest.php

@@ -118,7 +118,7 @@ class XmlViewTest extends TestCase
         $Response = new Response();
         $Controller = new Controller($Request, $Response);
         $data = [
-            '_serialize' => ['tags'],
+            '_serialize' => ['tags', 'nope'],
             '_xmlOptions' => ['format' => 'attributes'],
             'tags' => [
                     'tag' => [