mirror of
https://github.com/moodle/moodle.git
synced 2025-01-17 21:49:15 +01:00
MDL-24381 backup - avoid infinite iteration under windows caused by platform-dependent dirname()
This commit is contained in:
parent
a9c16bab26
commit
e521039d22
@ -117,12 +117,12 @@ abstract class grouped_parser_processor extends simplified_parser_processor {
|
||||
* false if not
|
||||
*/
|
||||
protected function processed_parent_exists($path) {
|
||||
$parentpath = dirname($path);
|
||||
$parentpath = progressive_parser::dirname($path);
|
||||
while ($parentpath != '/') {
|
||||
if ($this->path_is_selected($parentpath)) {
|
||||
return $parentpath;
|
||||
}
|
||||
$parentpath = dirname($parentpath);
|
||||
$parentpath = progressive_parser::dirname($parentpath);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -134,12 +134,12 @@ abstract class grouped_parser_processor extends simplified_parser_processor {
|
||||
* false if not
|
||||
*/
|
||||
protected function grouped_parent_exists($path) {
|
||||
$parentpath = dirname($path);
|
||||
$parentpath = progressive_parser::dirname($path);
|
||||
while ($parentpath != '/') {
|
||||
if ($this->path_is_grouped($parentpath)) {
|
||||
return $parentpath;
|
||||
}
|
||||
$parentpath = dirname($parentpath);
|
||||
$parentpath = progressive_parser::dirname($parentpath);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ abstract class simplified_parser_processor extends progressive_parser_processor
|
||||
|
||||
public function add_path($path) {
|
||||
$this->paths[] = $path;
|
||||
$this->parentpaths[] = dirname($path);
|
||||
$this->parentpaths[] = progressive_parser::dirname($path);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -71,7 +71,7 @@ abstract class simplified_parser_processor extends progressive_parser_processor
|
||||
public function process_chunk($data) {
|
||||
// Precalculate some vars for readability
|
||||
$path = $data['path'];
|
||||
$parentpath = dirname($path);
|
||||
$parentpath = progressive_parser::dirname($path);
|
||||
$tag = basename($path);
|
||||
|
||||
// If the path is a registered parent one, store all its tags
|
||||
|
@ -144,6 +144,14 @@ class progressive_parser {
|
||||
$this->xml_parser = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides one cross-platform dirname function for
|
||||
* handling parser paths, see MDL-24381
|
||||
*/
|
||||
public static function dirname($path) {
|
||||
return str_replace('\\', '/', dirname($path));
|
||||
}
|
||||
|
||||
// Protected API starts here
|
||||
|
||||
protected function parse($data, $eof) {
|
||||
@ -204,7 +212,7 @@ class progressive_parser {
|
||||
|
||||
// If not set, build to push common header
|
||||
if (empty($this->topush)) {
|
||||
$this->topush['path'] = dirname($this->path);
|
||||
$this->topush['path'] = progressive_parser::dirname($this->path);
|
||||
$this->topush['level'] = $this->level;
|
||||
$this->topush['tags'] = array();
|
||||
}
|
||||
@ -246,7 +254,7 @@ class progressive_parser {
|
||||
|
||||
// Normal update of parser internals
|
||||
$this->level--;
|
||||
$this->path = dirname($this->path);
|
||||
$this->path = progressive_parser::dirname($this->path);
|
||||
}
|
||||
|
||||
protected function char_data($parser, $data) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user