(bug 45092) Better context for Article initialized by ApiEditPage
authorLiangent <liangent@gmail.com>
Sun, 17 Feb 2013 10:59:41 +0000 (18:59 +0800)
committerGerrit Code Review <gerrit@wikimedia.org>
Tue, 19 Feb 2013 08:56:40 +0000 (08:56 +0000)
After I99a19c93, the $context argument of EditFilterMergedContent hook
is just $editPage->mArticle->getContext() which has a title of [[API]]
when it's created in ApiEditPage called internally (like what WikiLove
does). Now a new context is created for it which simulates a real edit
(title is the title being edited, and request is the derivated one with
a few more fake parameters added).

Change-Id: I743942822eb5097d9d98c11088a91395d9e6d47f

includes/api/ApiEditPage.php

index f6e0679..1d6dc66 100644 (file)
@@ -304,6 +304,12 @@ class ApiEditPage extends ApiBase {
                $wgTitle = $titleObj;
 
                $articleObject = new Article( $titleObj );
+
+               $articleContext = new RequestContext;
+               $articleContext->setRequest( $req );
+               $articleContext->setTitle( $titleObj );
+               $articleObject->setContext( $articleContext );
+
                $ep = new EditPage( $articleObject );
 
                // allow editing of non-textual content.