Skip to content

Commit

Permalink
MDL-61476 mod_glossary: Check XML arrays exist
Browse files Browse the repository at this point in the history
  • Loading branch information
dthies authored and stronk7 committed Apr 9, 2018
1 parent ff9019a commit f9c68b4
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions mod/glossary/import.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@
}

$xmlentries = $xml['GLOSSARY']['#']['INFO'][0]['#']['ENTRIES'][0]['#']['ENTRY'];
$sizeofxmlentries = sizeof($xmlentries);
$sizeofxmlentries = is_array($xmlentries) ? count($xmlentries) : 0;
for($i = 0; $i < $sizeofxmlentries; $i++) {
// Inserting the entries
$xmlentry = $xmlentries[$i];
Expand Down Expand Up @@ -230,7 +230,7 @@
$importedentries++;

$xmlaliases = @$xmlentry['#']['ALIASES'][0]['#']['ALIAS']; // ignore missing ALIASES
$sizeofxmlaliases = sizeof($xmlaliases);
$sizeofxmlaliases = is_array($xmlaliases) ? count($xmlaliases) : 0;
for($k = 0; $k < $sizeofxmlaliases; $k++) {
/// Importing aliases
$xmlalias = $xmlaliases[$k];
Expand All @@ -247,7 +247,7 @@
if (!empty($data->catsincl)) {
// If the categories must be imported...
$xmlcats = @$xmlentry['#']['CATEGORIES'][0]['#']['CATEGORY']; // ignore missing CATEGORIES
$sizeofxmlcats = sizeof($xmlcats);
$sizeofxmlcats = is_array($xmlcats) ? count($xmlcats) : 0;
for($k = 0; $k < $sizeofxmlcats; $k++) {
$xmlcat = $xmlcats[$k];

Expand Down Expand Up @@ -283,7 +283,7 @@
// Import tags associated with the entry.
if (core_tag_tag::is_enabled('mod_glossary', 'glossary_entries')) {
$xmltags = @$xmlentry['#']['TAGS'][0]['#']['TAG']; // Ignore missing TAGS.
$sizeofxmltags = count($xmltags);
$sizeofxmltags = is_array($xmltags) ? count($xmltags) : 0;
for ($k = 0; $k < $sizeofxmltags; $k++) {
// Importing tags.
$tag = $xmltags[$k]['#'];
Expand Down

0 comments on commit f9c68b4

Please sign in to comment.