Index: trunk/phase3/includes/api/ApiEditPage.php |
— | — | @@ -58,6 +58,9 @@ |
59 | 59 | $titleObj = Title::newFromText($params['title']); |
60 | 60 | if(!$titleObj) |
61 | 61 | $this->dieUsageMsg(array('invalidtitle', $params['title'])); |
| 62 | + // Some functions depend on $wgTitle == $ep->mTitle |
| 63 | + global $wgTitle; |
| 64 | + $titleObj = $wgTitle; |
62 | 65 | |
63 | 66 | if($params['createonly'] && $titleObj->exists()) |
64 | 67 | $this->dieUsageMsg(array('createonly-exists')); |
— | — | @@ -197,10 +200,6 @@ |
198 | 201 | # Do the actual save |
199 | 202 | $oldRevId = $articleObj->getRevIdFetched(); |
200 | 203 | $result = null; |
201 | | - # *Something* is setting $wgTitle to a title corresponding to "Msg", |
202 | | - # but that breaks API mode detection through is_null($wgTitle) |
203 | | - global $wgTitle; |
204 | | - $wgTitle = null; |
205 | 204 | # Fake $wgRequest for some hooks inside EditPage |
206 | 205 | # FIXME: This interface SUCKS |
207 | 206 | $oldRequest = $wgRequest; |
Index: trunk/phase3/api.php |
— | — | @@ -69,6 +69,13 @@ |
70 | 70 | die(1); |
71 | 71 | } |
72 | 72 | |
| 73 | +// So extensions can check whether they're running in API mode |
| 74 | +define('API', true); |
| 75 | + |
| 76 | +// Set a dummy $wgTitle, because $wgTitle == null breaks various things |
| 77 | +// In a perfect world this wouldn't be necessary |
| 78 | +$wgTitle = Title::newFromTitle('API'); |
| 79 | + |
73 | 80 | /* Construct an ApiMain with the arguments passed via the URL. What we get back |
74 | 81 | * is some form of an ApiMain, possibly even one that produces an error message, |
75 | 82 | * but we don't care here, as that is handled by the ctor. |