Index: trunk/extensions/WikiLove/ApiWikiLove.php |
— | — | @@ -1,12 +1,9 @@ |
2 | 2 | <?php |
3 | 3 | class ApiWikiLove extends ApiBase { |
4 | 4 | public function execute() { |
5 | | - global $wgRequest, $wgWikiLoveLogging, $wgParser, $wgVersion; |
| 5 | + global $wgRequest, $wgWikiLoveLogging, $wgParser; |
6 | 6 | |
7 | 7 | $params = $this->extractRequestParams(); |
8 | | - |
9 | | - // In some cases we need the wiki mark-up stripped from the subject |
10 | | - $strippedSubject = $wgParser->stripSectionName( $params['subject'] ); |
11 | 8 | |
12 | 9 | $title = Title::newFromText( $params['title'] ); |
13 | 10 | if ( is_null( $title ) ) { |
— | — | @@ -22,37 +19,22 @@ |
23 | 20 | $this->saveInDb( $talk, $params['subject'], $params['message'], $params['type'], isset( $params['email'] ) ? 1 : 0 ); |
24 | 21 | } |
25 | 22 | |
26 | | - // MediaWiki did not allow specifying separate edit summaries and section titles until 1.19 |
27 | | - $oldVersion = version_compare( $wgVersion, '1.18', '<=' ); |
28 | | - if ( $oldVersion ) { |
29 | | - $apiParamArray = array( |
30 | | - 'action' => 'edit', |
31 | | - 'title' => $talk->getFullText(), |
32 | | - // need to do this, as Article::replaceSection fails for non-existing pages |
33 | | - 'appendtext' => ( $talk->exists() ? "\n\n" : '' ) . |
34 | | - wfMsgForContent( 'newsectionheaderdefaultlevel', $params['subject'] ) |
35 | | - . "\n\n" . $params['text'], |
36 | | - 'token' => $params['token'], |
37 | | - 'summary' => wfMsgForContent( 'wikilove-summary', $strippedSubject ), |
38 | | - 'notminor' => true |
39 | | - ); |
40 | | - } else { |
41 | | - $apiParamArray = array( |
42 | | - 'action' => 'edit', |
43 | | - 'title' => $talk->getFullText(), |
44 | | - 'section' => 'new', |
45 | | - 'sectiontitle' => $params['subject'], |
46 | | - 'text' => $params['text'], |
47 | | - 'token' => $params['token'], |
48 | | - 'summary' => wfMsgForContent( 'wikilove-summary', $strippedSubject ), |
49 | | - 'notminor' => true |
50 | | - ); |
51 | | - } |
52 | | - |
| 23 | + // not using section => 'new' here, as we like to give our own edit summary |
53 | 24 | $api = new ApiMain( |
54 | 25 | new DerivativeRequest( |
55 | 26 | $wgRequest, |
56 | | - $apiParamArray, |
| 27 | + array( |
| 28 | + 'action' => 'edit', |
| 29 | + 'title' => $talk->getFullText(), |
| 30 | + // need to do this, as Article::replaceSection fails for non-existing pages |
| 31 | + 'appendtext' => ( $talk->exists() ? "\n\n" : '' ) . |
| 32 | + wfMsgForContent( 'newsectionheaderdefaultlevel', $params['subject'] ) |
| 33 | + . "\n\n" . $params['text'], |
| 34 | + 'token' => $params['token'], |
| 35 | + 'summary' => wfMsgForContent( 'wikilove-summary', |
| 36 | + $wgParser->stripSectionName( $params['subject'] ) ), |
| 37 | + 'notminor' => true |
| 38 | + ), |
57 | 39 | false // was posted? |
58 | 40 | ), |
59 | 41 | true // enable write? |
— | — | @@ -61,11 +43,11 @@ |
62 | 44 | $api->execute(); |
63 | 45 | |
64 | 46 | if ( isset( $params['email'] ) ) { |
65 | | - $this->emailUser( $talk, $strippedSubject, $params['email'], $params['token'] ); |
| 47 | + $this->emailUser( $talk, $params['subject'], $params['email'], $params['token'] ); |
66 | 48 | } |
67 | 49 | |
68 | 50 | $this->getResult()->addValue( 'redirect', 'pageName', $talk->getPrefixedDBkey() ); |
69 | | - $this->getResult()->addValue( 'redirect', 'fragment', Title::escapeFragmentForURL( $strippedSubject ) ); |
| 51 | + $this->getResult()->addValue( 'redirect', 'fragment', Title::escapeFragmentForURL( $params['subject'] ) ); |
70 | 52 | // note that we cannot use Title::makeTitle here as it doesn't sanitize the fragment |
71 | 53 | } |
72 | 54 | |