Skip to content
Snippets Groups Projects
Commit 39d9384c authored by Daniel Schultz's avatar Daniel Schultz :tm:
Browse files

Handle invalid titles

Picksome had logic which would result in an error if the list of titles
included any invalid characters (or otherwise violated the list of rules
for wiki page titles as described in
https://en.wikipedia.org/wiki/Wikipedia:Page_name#Technical_restrictions_and_limitations)

By separating the title generation we are able to check for a null
result (null is returned in the event of an invalid title) and skip that
result instead of triggering the error.

Issue #135
parent c1ab118a
No related branches found
No related tags found
No related merge requests found
......@@ -30,7 +30,8 @@ $wgPickSomePage = function($title) {
$valid_pages = [];
preg_match_all("/\\[\\[([^\\]]*)\\]\\]/", $page->getContent()->getText(), $valid_pages);
foreach($valid_pages[1] as $valid_page) {
if($title->equals(Title::newFromText($valid_page))) {
$valid_page_title = Title::newFromText($valid_page);
if($valid_page_title && $title->equals($valid_page_title)) {
return true;
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment