Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-14072

backuplib.php performance improvement for the function full_tag()

XMLWordPrintable

    • Icon: Improvement Improvement
    • Resolution: Fixed
    • Icon: Major Major
    • 1.8.6, 1.9.1
    • 1.5, 1.5.1, 1.5.2, 1.5.3, 1.5.4, 1.6.6, 1.7.4, 1.8.5, 1.9
    • Backup
    • None
    • MOODLE_15_STABLE, MOODLE_16_STABLE, MOODLE_17_STABLE, MOODLE_18_STABLE, MOODLE_19_STABLE
    • MOODLE_18_STABLE, MOODLE_19_STABLE

      OK I noticed that this got improved in 1.9, but not 1.5.x - 1.8.x. Maybe we should consider backport this back to 1.5 - 1.8 (I could help with this).

      Basically the problem is that if you have really BIG course (e.g. for our case, a course with 1300+ students with lots of quizzes and unlimited quiz attempts for practice quizzes..etc.). In this case for moodle 1.5. - 1.8 the backup process would stop when the system is "Writing categories and questions." We tried to narrow down the problem and one thing that we came up with is to improve the function full_tag a little bit.

      Currently in the backuplib.php in moodle 1.5.x to 1.8.x, it looks like this:

      function full_tag($tag,$level=0,$endline=true,$content,$attributes=null)

      { global $CFG; //Here we encode absolute links $content = backup_encode_absolute_links($content); $st = start_tag($tag,$level,$endline,$attributes); $co = xml_tag_safe_content($content); $et = end_tag($tag,0,true); return $st.$co.$et; }

      This is not efficient as no matter what the backup_encode_absolute_links will be called. We rewrote it a little bit to add a if condition before the $content = backup_encode_absolute_links($content); See below:

      439 //Here we encode absolute links
      440 //Only run backup_encode_absolute_links when necessary...
      441 //Running backup_encode_absolute_links on every tag adds a lot of overhead
      442 //Looking at backup_encode_absolute_links, it appears to only operate on
      443 if (strpos($content, "file.php") !== false || strpos($content, "index.php") !== false || strpos($content, "discuss.php"))
      444

      { 445 $content = backup_encode_absolute_links($content); 446 }

      The solution that moodle 1.9 came up with is: (see MDL-10770 for more details):

      function full_tag($tag,$level=0,$endline=true,$content,$attributes=null) {

      global $CFG;
      //Here we encode absolute links
      // MDL-10770
      if (is_null($content))

      { $content = '$@NULL@$'; }

      else

      { $content = backup_encode_absolute_links($content); }

      $st = start_tag($tag,$level,$endline,$attributes);

      $co = xml_tag_safe_content($content);

      $et = end_tag($tag,0,true);

      return $st.$co.$et;
      }

      Which one would be a better solution? Just thought that I would throw it out here for discussion. I could help with backporting by the way once we reach some kind of agreement. thanks!

            stronk7 Eloy Lafuente (stronk7)
            chuang Wen Hao Chuang
            Petr Skoda Petr Skoda
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.