Skip to content

Commit 9872396

Browse files
authored
Merge pull request dokuwiki#4278 from dregad/php-warnings
Fix PHP warnings
2 parents 850e662 + 186263b commit 9872396

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

inc/Ui/Recent.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ protected function checkCurrentRevision(array &$info)
162162
}
163163
if (!$changelog->isCurrentRevision($info['date'])) {
164164
$currentRevInfo = $changelog->getCurrentRevisionInfo();
165-
if ($currentRevInfo['type'] == DOKU_CHANGE_TYPE_DELETE) {
165+
if ($currentRevInfo && $currentRevInfo['type'] == DOKU_CHANGE_TYPE_DELETE) {
166166
// the page or media file was externally deleted, updated info because the link is already red
167167
// externally created and edited not updated because sorting by date is not worth so much changes
168168
$info = array_merge($info, $currentRevInfo);

inc/media.php

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1674,13 +1674,13 @@ function media_nstree($ns)
16741674
global $lang;
16751675

16761676
// currently selected namespace
1677-
$ns = cleanID($ns);
1677+
$ns = cleanID($ns);
16781678
if (empty($ns)) {
16791679
global $ID;
16801680
$ns = (string)getNS($ID);
16811681
}
16821682

1683-
$ns_dir = utf8_encodeFN(str_replace(':', '/', $ns));
1683+
$ns_dir = utf8_encodeFN(str_replace(':', '/', $ns));
16841684

16851685
$data = [];
16861686
search($data, $conf['mediadir'], 'search_index', ['ns' => $ns_dir, 'nofiles' => true]);
@@ -1692,21 +1692,29 @@ function media_nstree($ns)
16921692
$ns_parts = explode(':', $ns);
16931693
$tmp_ns = '';
16941694
$pos = 0;
1695+
$insert = false;
16951696
foreach ($ns_parts as $level => $part) {
1696-
if ($tmp_ns) $tmp_ns .= ':' . $part;
1697-
else $tmp_ns = $part;
1697+
if ($tmp_ns) {
1698+
$tmp_ns .= ':' . $part;
1699+
} else {
1700+
$tmp_ns = $part;
1701+
}
16981702

1699-
// find the namespace parts or insert them
1700-
while ($data[$pos]['id'] != $tmp_ns) {
1703+
// find the namespace parts
1704+
while (array_key_exists($pos, $data) && $data[$pos]['id'] != $tmp_ns) {
17011705
if (
17021706
$pos >= count($data) ||
17031707
($data[$pos]['level'] <= $level + 1 && Sort::strcmp($data[$pos]['id'], $tmp_ns) > 0)
17041708
) {
1705-
array_splice($data, $pos, 0, [['level' => $level + 1, 'id' => $tmp_ns, 'open' => 'true']]);
1709+
$insert = true;
17061710
break;
17071711
}
17081712
++$pos;
17091713
}
1714+
// insert namespace in hierarchy; if not found in above loop, append it to the end
1715+
if ($insert || $pos == count($data)) {
1716+
array_splice($data, $pos, 0, [['level' => $level + 1, 'id' => $tmp_ns, 'open' => 'true']]);
1717+
}
17101718
}
17111719

17121720
echo html_buildlist($data, 'idx', 'media_nstree_item', 'media_nstree_li');

0 commit comments

Comments
 (0)