mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
MDL-24381 backup - avoid infinite iteration under windows caused by platform-dependent dirname()
This commit is contained in:
parent
a9c16bab26
commit
e521039d22
3 changed files with 16 additions and 8 deletions
|
@ -117,12 +117,12 @@ abstract class grouped_parser_processor extends simplified_parser_processor {
|
||||||
* false if not
|
* false if not
|
||||||
*/
|
*/
|
||||||
protected function processed_parent_exists($path) {
|
protected function processed_parent_exists($path) {
|
||||||
$parentpath = dirname($path);
|
$parentpath = progressive_parser::dirname($path);
|
||||||
while ($parentpath != '/') {
|
while ($parentpath != '/') {
|
||||||
if ($this->path_is_selected($parentpath)) {
|
if ($this->path_is_selected($parentpath)) {
|
||||||
return $parentpath;
|
return $parentpath;
|
||||||
}
|
}
|
||||||
$parentpath = dirname($parentpath);
|
$parentpath = progressive_parser::dirname($parentpath);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -134,12 +134,12 @@ abstract class grouped_parser_processor extends simplified_parser_processor {
|
||||||
* false if not
|
* false if not
|
||||||
*/
|
*/
|
||||||
protected function grouped_parent_exists($path) {
|
protected function grouped_parent_exists($path) {
|
||||||
$parentpath = dirname($path);
|
$parentpath = progressive_parser::dirname($path);
|
||||||
while ($parentpath != '/') {
|
while ($parentpath != '/') {
|
||||||
if ($this->path_is_grouped($parentpath)) {
|
if ($this->path_is_grouped($parentpath)) {
|
||||||
return $parentpath;
|
return $parentpath;
|
||||||
}
|
}
|
||||||
$parentpath = dirname($parentpath);
|
$parentpath = progressive_parser::dirname($parentpath);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,7 @@ abstract class simplified_parser_processor extends progressive_parser_processor
|
||||||
|
|
||||||
public function add_path($path) {
|
public function add_path($path) {
|
||||||
$this->paths[] = $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) {
|
public function process_chunk($data) {
|
||||||
// Precalculate some vars for readability
|
// Precalculate some vars for readability
|
||||||
$path = $data['path'];
|
$path = $data['path'];
|
||||||
$parentpath = dirname($path);
|
$parentpath = progressive_parser::dirname($path);
|
||||||
$tag = basename($path);
|
$tag = basename($path);
|
||||||
|
|
||||||
// If the path is a registered parent one, store all its tags
|
// If the path is a registered parent one, store all its tags
|
||||||
|
|
|
@ -144,6 +144,14 @@ class progressive_parser {
|
||||||
$this->xml_parser = null;
|
$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 API starts here
|
||||||
|
|
||||||
protected function parse($data, $eof) {
|
protected function parse($data, $eof) {
|
||||||
|
@ -204,7 +212,7 @@ class progressive_parser {
|
||||||
|
|
||||||
// If not set, build to push common header
|
// If not set, build to push common header
|
||||||
if (empty($this->topush)) {
|
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['level'] = $this->level;
|
||||||
$this->topush['tags'] = array();
|
$this->topush['tags'] = array();
|
||||||
}
|
}
|
||||||
|
@ -246,7 +254,7 @@ class progressive_parser {
|
||||||
|
|
||||||
// Normal update of parser internals
|
// Normal update of parser internals
|
||||||
$this->level--;
|
$this->level--;
|
||||||
$this->path = dirname($this->path);
|
$this->path = progressive_parser::dirname($this->path);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function char_data($parser, $data) {
|
protected function char_data($parser, $data) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue