Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-16345 Moodle 2.0 question bank improvements
  3. MDL-19264

Testing that $this->_load_official_tags() contains at least 1 element

    XMLWordPrintable

Details

    • Sub-task
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 2.0
    • 2.0
    • Questions
    • None
    • MOODLE_20_STABLE
    • MOODLE_20_STABLE

    Description

      This happen when testing a new experimental site where there was no official tags

      Warning: array_combine() [function.array-combine]: Both parameters should have at least 1 element in C:\server\moodle\moodle_head\lib\form\tags.php on line 179

      if (!empty($value) && !(isset($value['officialtags']) || isset($value['othertags']))) {
      // Separate the official and unoffical tags, if necessary.
      $official = array();
      $other = array();
      if ($this->_options['display'] != MoodleQuickForm_tags::NOOFFICIAL) {
      $this->_load_official_tags();
      line 179 $officaltags = array_combine($this->_officialtags, $this->_officialtags);
      foreach ($value as $tag) {
      if (isset($officaltags[$tag]))

      { $official[] = $tag; }

      else

      { $other[] = $tag; }

      }
      } else

      { $other = $value; }

      $value = array('officialtags' => $official, 'othertags' => implode(', ', $other));
      }
      From PHP function array_combine()
      Throws E_WARNING if keys and values are either empty or the number of elements does not match.

      So the second case is not the problem and we should test for empty.

      However I am not sure where this test should done...

      Attachments

        Activity

          People

            timhunt Tim Hunt
            ppichet Pierre Pichet
            Safat Shahin, Tim Hunt, Andrew Lyons, Huong Nguyen, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze, Stevani Andolo
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              24/Nov/10