Permalink
Browse files

MDL-37893 Allow elements with no final tags to form a grouped path

  • Loading branch information...
1 parent 98bba46 commit 2c06c715c7440148c6d866926536430940372635 @mudrd8mz mudrd8mz committed Feb 6, 2013
Showing with 12 additions and 1 deletion.
  1. +12 −1 backup/util/xml/parser/processors/grouped_parser_processor.class.php
View
13 backup/util/xml/parser/processors/grouped_parser_processor.class.php
@@ -76,6 +76,17 @@ public function add_path($path, $grouped = false) {
* @param string $path xml path which parsing has started
*/
public function before_path($path) {
+ if ($this->path_is_grouped($path) and !isset($this->currentdata[$path])) {
+ // If the grouped element itself does not contain any final tags,
+ // we would not get any chunk data for it. So we add an artificial
+ // empty data chunk here that will be eventually replaced with
+ // real data later in {@link self::postprocess_chunk()}.
+ $this->currentdata[$path] = array(
+ 'path' => $path,
+ 'level' => substr_count($path, '/') + 1,
+ 'tags' => array(),
+ );
+ }
if (!$this->grouped_parent_exists($path)) {
parent::before_path($path);
}
@@ -167,7 +178,7 @@ protected function grouped_child_exists($path) {
*/
protected function build_currentdata($grouped, $data) {
// Check the grouped already exists into currentdata
- if (!array_key_exists($grouped, $this->currentdata)) {
+ if (!is_array($this->currentdata) or !array_key_exists($grouped, $this->currentdata)) {
$a = new stdclass();
$a->grouped = $grouped;
$a->child = $data['path'];

0 comments on commit 2c06c71

Please sign in to comment.