Don't assume, that IContextSource::getWikiPage() always returns a WikiPage object

It could be possible, that the EditFilterMergedContent hook is called from a context,
where no WikiPage is possible (e.g. in Special NS). Check for this situation and
abort with a debug message, if no WikiPage is available.

Bug: T48342
Change-Id: I5305b89817f4c25eb7c3cbb6ee65a4a1f77205b8
This commit is contained in:
Florian 2015-05-07 23:24:02 +02:00
parent f7f4a915aa
commit c878fb875e

View file

@ -598,6 +598,21 @@ class SimpleCaptcha {
# The CAPTCHA was already checked and approved
return true;
}
if ( !$context->canUseWikiPage() ) {
// we check WikiPage only
// try to get an appropriate title for this page
$title = $context->getTitle();
if ( $title instanceof Title ) {
$title = $title->getFullText();
} else {
// otherwise it's an unknown page where this function is called from
$title = 'unknown';
}
// log this error, it could be a problem in another extension, edits should always have a WikiPage if
// they go through EditFilterMergedContent.
wfDebug( __METHOD__ . ': Skipped ConfirmEdit check: No WikiPage for title ' . $title );
return true;
}
$page = $context->getWikiPage();
if ( !$this->doConfirmEdit( $page, $content, false, true ) ) {
if ( $legacyMode ) {