DokuWiki 中的特殊搜索错误
从 DokuWiki 论坛交叉发布此内容:
所以,我做了一些修改,以便允许三件事:页面名称大写、侧边栏目录中的自然大小写排序以及不区分大小写的搜索。
请耐心等待,因为我知道这看起来像是文件权限错误。我不相信是这样。
在搜索“nul”及其任何变体(nUl、Nul、nuL 等)时,我收到以下错误消息:
Warning: Cannot unset offset in a non-array variable in C:\Websites\dokuwiki\inc\parserutils.php on line 365
Warning: Cannot unset offset in a non-array variable in C:\Websites\dokuwiki\inc\parserutils.php on line 366
Warning: Cannot unset offset in a non-array variable in C:\Websites\dokuwiki\inc\parserutils.php on line 367
Warning: Cannot unset offset in a non-array variable in C:\Websites\dokuwiki\inc\parserutils.php on line 368
Warning: Cannot unset offset in a non-array variable in C:\Websites\dokuwiki\inc\parserutils.php on line 369
Warning: filesize() [function.filesize]: stat failed for C:/Websites/dokuwiki/data/meta/nul.changes in C:\Websites\dokuwiki\inc\changelog.php on line 305
不存在也从来没有名为“nul”的页面。搜索完成后,它会在 \dokuwiki\data\index\page.idx 中添加一个新行,其内容与我搜索的内容相同(nul、NuL、nUl 等)。一旦该行被添加到 page.idx 中,任何对字母“n”、“u”或“l”的搜索也将导致错误:
Warning: Cannot unset offset in a non-array variable in C:\Websites\dokuwiki\inc\parserutils.php on line 365
Warning: Cannot unset offset in a non-array variable in C:\Websites\dokuwiki\inc\parserutils.php on line 366
Warning: Cannot unset offset in a non-array variable in C:\Websites\dokuwiki\inc\parserutils.php on line 367
Warning: Cannot unset offset in a non-array variable in C:\Websites\dokuwiki\inc\parserutils.php on line 368
Warning: Cannot unset offset in a non-array variable in C:\Websites\dokuwiki\inc\parserutils.php on line 369
Warning: filectime() [function.filectime]: stat failed for C:/Websites/dokuwiki/data/pages/nul.txt in C:\Websites\dokuwiki\inc\parser\metadata.php on line 46
Warning: filemtime() [function.filemtime]: stat failed for C:/Websites/dokuwiki/data/pages/nul.txt in C:\Websites\dokuwiki\inc\parser\metadata.php on line 72
再一次,页面“nul”在 wiki 上从未存在过,并且是搜索时写入 page.idx。
以下是我为实现我在帖子开头提到的三件事所做的修改:
/inc/fulltext.php,第 255 和 263 行:我将“strpos”替换为“stripos”。
if ($id !== '' && $cleaned !== '') {
foreach ($pages as $p_id => $p_title) {
if ((stripos($in_ns ? $p_id : noNSorNS($p_id), $cleaned) === false) &&
(!$in_title || (stripos($p_title, $id) === false)) ) {
unset($pages[$p_id]);
}
}
}
if (isset($ns)) {
foreach (array_keys($pages) as $p_id) {
if (stripos($p_id, $ns) !== 0) {
unset($pages[$p_id]);
}
}
}
/inc/pageutils.php,第 114 行已删除:
//$id = utf8_strtolower($id);
/inc/search.php,第 40 行和第 41 行:我将“sort”替换为“natcasesort”
natcasesort($files);
natcasesort($dirs);
据我所知,这些都是细微的更改,但我没有看到任何显而易见的因素都会导致此问题。
有什么想法吗?
更新 -
我恢复了所有更改,但错误仍然存在。
然后我在一个完全独立的目录中安装了一个新的 DokuWiki(发布 2010-11-07a“Anteater”),错误仍然存在。
然后我从 splitbrain.org 安装了夜间快照,但错误仍然存在。
有人有什么想法吗?
Cross-posting this from the DokuWiki forums:
So, I was making some modifications in order to allow for three things: Capitalization in page names, natural case sorting in the sidebar ToC, and case insensitive search.
Bear with me, because I know this looks like a file permissions error. I do not believe it is.
Upon searching for "nul" and any variation of that(nUl, Nul, nuL, etc), I receive the following error message:
Warning: Cannot unset offset in a non-array variable in C:\Websites\dokuwiki\inc\parserutils.php on line 365
Warning: Cannot unset offset in a non-array variable in C:\Websites\dokuwiki\inc\parserutils.php on line 366
Warning: Cannot unset offset in a non-array variable in C:\Websites\dokuwiki\inc\parserutils.php on line 367
Warning: Cannot unset offset in a non-array variable in C:\Websites\dokuwiki\inc\parserutils.php on line 368
Warning: Cannot unset offset in a non-array variable in C:\Websites\dokuwiki\inc\parserutils.php on line 369
Warning: filesize() [function.filesize]: stat failed for C:/Websites/dokuwiki/data/meta/nul.changes in C:\Websites\dokuwiki\inc\changelog.php on line 305
There is not and never has been a page named "nul." Once the search has completed, it adds a new line to \dokuwiki\data\index\page.idx with the same content as what I searched for(nul, NuL, nUl, etc, etc). Once that line has been added to page.idx, any search for the letters "n" "u" or "l" will also result in an error:
Warning: Cannot unset offset in a non-array variable in C:\Websites\dokuwiki\inc\parserutils.php on line 365
Warning: Cannot unset offset in a non-array variable in C:\Websites\dokuwiki\inc\parserutils.php on line 366
Warning: Cannot unset offset in a non-array variable in C:\Websites\dokuwiki\inc\parserutils.php on line 367
Warning: Cannot unset offset in a non-array variable in C:\Websites\dokuwiki\inc\parserutils.php on line 368
Warning: Cannot unset offset in a non-array variable in C:\Websites\dokuwiki\inc\parserutils.php on line 369
Warning: filectime() [function.filectime]: stat failed for C:/Websites/dokuwiki/data/pages/nul.txt in C:\Websites\dokuwiki\inc\parser\metadata.php on line 46
Warning: filemtime() [function.filemtime]: stat failed for C:/Websites/dokuwiki/data/pages/nul.txt in C:\Websites\dokuwiki\inc\parser\metadata.php on line 72
Once again, the page "nul" has not ever existed on the wiki and is being written to page.idx upon searching.
Here are the modifications I made to achieve the three things I noted in the beginning of my post:
/inc/fulltext.php, lines 255 and 263: I replaced "strpos" with "stripos."
if ($id !== '' && $cleaned !== '') {
foreach ($pages as $p_id => $p_title) {
if ((stripos($in_ns ? $p_id : noNSorNS($p_id), $cleaned) === false) &&
(!$in_title || (stripos($p_title, $id) === false)) ) {
unset($pages[$p_id]);
}
}
}
if (isset($ns)) {
foreach (array_keys($pages) as $p_id) {
if (stripos($p_id, $ns) !== 0) {
unset($pages[$p_id]);
}
}
}
/inc/pageutils.php, line 114 removed:
//$id = utf8_strtolower($id);
/inc/search.php, lines 40 and 41: I replaced "sort" with "natcasesort"
natcasesort($files);
natcasesort($dirs);
These are all minor changes as far as I can tell, and I don't see anything immediately apparent that would be causing this issue.
Any ideas?
Update -
I reverted all my changes and the error persists.
I then installed a fresh DokuWiki(Release 2010-11-07a "Anteater") in a completely separate directory, the error persists.
I then installed the nightly snapshot from splitbrain.org, and the error persists.
Anyone have any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
事实证明,这是由于“NUL”被保留而导致的 Windows 特定错误。根据查尔斯的建议,我将在此处以及我原始评论中链接的论坛帖子中发布答案。我觉得这是一个笨拙的修复,但我需要让它发挥作用。我只是将单词“nul”重写为其 ASCII 字符,然后将其翻译回来以显示在页面和标题中:
\inc\pageutils.php,第 137 行(ish):
\inc\template.php,行876:
It turns out that this is a Windows specific error due to "NUL" being reserved. Per Charles suggestion, I will post the answer here as well as in the forum post linked in my original comment. I feel like it's a kludgey fix, but I needed to get it working. I'm just rewriting the word "nul" into its ASCII characters and then translating it back for display on the page and in the title:
\inc\pageutils.php, line 137(ish):
\inc\template.php, line 876: