Merge branch 'MDL-27594' of git://github.com/stronk7/moodle

This commit is contained in:
Eloy Lafuente (stronk7) 2011-05-25 10:16:10 +02:00
commit 28e2b08582
2 changed files with 18 additions and 16 deletions

View File

@ -174,12 +174,12 @@ abstract class simplified_parser_processor extends progressive_parser_processor
*/
public function after_path($path) {
$toprocess = false;
// If the path being closed matches (same or parent) the last path in the stack
// If the path being closed matches (same or parent) the first path in the stack
// we process pending startend notifications until one matching end is found
if ($element = reset($this->startendinfo)) {
$elepath = $element['path'];
$eleaction = $element['action'];
if ($eleaction = 'end' && strpos($elepath, $path) === 0) {
if (strpos($elepath, $path) === 0) {
$toprocess = true;
}

View File

@ -652,43 +652,45 @@ class progressive_parser_test extends UnitTestCase {
function helper_check_notifications_order_integrity($notifications) {
$numerrors = 0;
$notifpile = array('pilebase' => 'start');
$lastpile = 'start:pilebase';
$lastnotif = 'start:pilebase';
foreach ($notifications as $notif) {
$lastpilelevel = strlen(preg_replace('/[^\/]/', '', $lastpile));
$lastpiletype = preg_replace('/:.*/', '', $lastpile);
$lastpilepath = preg_replace('/.*:/', '', $lastpile);
$notiflevel = strlen(preg_replace('/[^\/]/', '', $notif));
$lastpiletype = end($notifpile);
$lastpilepath = key($notifpile);
$lastpilelevel = strlen(preg_replace('/[^\/]/', '', $lastpilepath));
$lastnotiftype = preg_replace('/:.*/', '', $lastnotif);
$lastnotifpath = preg_replace('/.*:/', '', $lastnotif);
$lastnotiflevel = strlen(preg_replace('/[^\/]/', '', $lastnotifpath));
$notiftype = preg_replace('/:.*/', '', $notif);
$notifpath = preg_replace('/.*:/', '', $notif);
$notiflevel = strlen(preg_replace('/[^\/]/', '', $notifpath));
switch ($notiftype) {
case 'process':
if ($lastpilepath != $notifpath or $lastpiletype != 'start') {
$numerrors++; // Only start for same path is allowed before process
if ($lastnotifpath != $notifpath or $lastnotiftype != 'start') {
$numerrors++; // Only start for same path from last notification is allowed before process
}
$notifpile[$notifpath] = 'process'; // Update the status in the pile
break;
case 'end':
if ($lastpilepath != $notifpath or ($lastpiletype != 'process' and $lastpiletype != 'start')) {
$numerrors++; // Only process for same path is allowed before end
$numerrors++; // Only process and start for same path from last pile is allowed before end
}
unset($notifpile[$notifpath]); // Delete from the pile
break;
case 'start':
if (array_key_exists($notifpath, $notifpile) or $notiflevel <= $lastpilelevel) {
$numerrors++; // If same path exists or the level is < than the last one
$numerrors++; // Only non existing in pile and with level > last pile is allowed on start
}
$notifpile[$notifpath] = 'start'; // Add to the pile
break;
default:
$numerrors++; // Incorrect type of notification => error
}
// Update lastpile
end($notifpile);
$path = key($notifpile);
$type = $notifpile[$path];
$lastpile = $type. ':' . $path;
// Update lastnotif
$lastnotif = $notif;
}
return $numerrors;
}