Moodle

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

Details

  • Type: Sub-task Sub-task
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: 2.0
  • Fix Version/s: 2.0
  • Component/s: Questions
  • Labels:
    None
  • Affected Branches:
    MOODLE_20_STABLE
  • Fixed Branches:
    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...

Activity

Hide
Tim Hunt added a comment -

Thanks for spotting this Pierre. Should be fixed now.

Show
Tim Hunt added a comment - Thanks for spotting this Pierre. Should be fixed now.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: