Index: trunk/phase3/includes/api/ApiFormatRaw.php |
— | — | @@ -46,10 +46,13 @@ |
47 | 47 | |
48 | 48 | public function getMimeType() { |
49 | 49 | $data = $this->getResultData(); |
| 50 | + |
50 | 51 | if ( isset( $data['error'] ) ) |
51 | 52 | return $this->mErrorFallback->getMimeType(); |
| 53 | + |
52 | 54 | if ( !isset( $data['mime'] ) ) |
53 | 55 | ApiBase::dieDebug( __METHOD__, "No MIME type set for raw formatter" ); |
| 56 | + |
54 | 57 | return $data['mime']; |
55 | 58 | } |
56 | 59 | |
— | — | @@ -60,6 +63,7 @@ |
61 | 64 | $this->mErrorFallback->execute(); |
62 | 65 | return; |
63 | 66 | } |
| 67 | + |
64 | 68 | if ( !isset( $data['text'] ) ) |
65 | 69 | ApiBase::dieDebug( __METHOD__, "No text given for raw formatter" ); |
66 | 70 | $this->printText( $data['text'] ); |
Index: trunk/phase3/includes/api/ApiQueryWatchlistRaw.php |
— | — | @@ -68,6 +68,7 @@ |
69 | 69 | $this->addWhereFld( 'wl_namespace', $params['namespace'] ); |
70 | 70 | $this->addWhereIf( 'wl_notificationtimestamp IS NOT NULL', isset( $show['changed'] ) ); |
71 | 71 | $this->addWhereIf( 'wl_notificationtimestamp IS NULL', isset( $show['!changed'] ) ); |
| 72 | + |
72 | 73 | if ( isset( $params['continue'] ) ) |
73 | 74 | { |
74 | 75 | $cont = explode( '|', $params['continue'] ); |
— | — | @@ -80,6 +81,7 @@ |
81 | 82 | "(wl_namespace = '$ns' AND " . |
82 | 83 | "wl_title >= '$title')" ); |
83 | 84 | } |
| 85 | + |
84 | 86 | // Don't ORDER BY wl_namespace if it's constant in the WHERE clause |
85 | 87 | if ( count( $params['namespace'] ) == 1 ) |
86 | 88 | $this->addOption( 'ORDER BY', 'wl_title' ); |
— | — | @@ -101,6 +103,7 @@ |
102 | 104 | break; |
103 | 105 | } |
104 | 106 | $t = Title::makeTitle( $row->wl_namespace, $row->wl_title ); |
| 107 | + |
105 | 108 | if ( is_null( $resultPageSet ) ) |
106 | 109 | { |
107 | 110 | $vals = array(); |
Index: trunk/phase3/includes/api/ApiQueryLangLinks.php |
— | — | @@ -63,6 +63,7 @@ |
64 | 64 | "(ll_from = $llfrom AND " . |
65 | 65 | "ll_lang >= '$lllang')" ); |
66 | 66 | } |
| 67 | + |
67 | 68 | # Don't order by ll_from if it's constant in the WHERE clause |
68 | 69 | if ( count( $this->getPageSet()->getGoodTitles() ) == 1 ) |
69 | 70 | $this->addOption( 'ORDER BY', 'll_lang' ); |
Index: trunk/phase3/includes/api/ApiFormatYaml_spyc.php |
— | — | @@ -159,7 +159,6 @@ |
160 | 160 | strpos( $value, "\n" ) || |
161 | 161 | preg_match( "/[#:]/", $value ) || |
162 | 162 | preg_match( "/^[-?,[\]{}!*&|>'\"%@`]/", $value ) ) ); |
163 | | - |
164 | 163 | } |
165 | 164 | |
166 | 165 | /** |
Index: trunk/phase3/includes/api/ApiQueryUserInfo.php |
— | — | @@ -62,24 +62,29 @@ |
63 | 63 | |
64 | 64 | if ( $wgUser->isAnon() ) |
65 | 65 | $vals['anon'] = ''; |
| 66 | + |
66 | 67 | if ( isset( $this->prop['blockinfo'] ) ) { |
67 | 68 | if ( $wgUser->isBlocked() ) { |
68 | 69 | $vals['blockedby'] = User::whoIs( $wgUser->blockedBy() ); |
69 | 70 | $vals['blockreason'] = $wgUser->blockedFor(); |
70 | 71 | } |
71 | 72 | } |
| 73 | + |
72 | 74 | if ( isset( $this->prop['hasmsg'] ) && $wgUser->getNewtalk() ) { |
73 | 75 | $vals['messages'] = ''; |
74 | 76 | } |
| 77 | + |
75 | 78 | if ( isset( $this->prop['groups'] ) ) { |
76 | 79 | $vals['groups'] = $wgUser->getGroups(); |
77 | 80 | $result->setIndexedTagName( $vals['groups'], 'g' ); // even if empty |
78 | 81 | } |
| 82 | + |
79 | 83 | if ( isset( $this->prop['rights'] ) ) { |
80 | 84 | // User::getRights() may return duplicate values, strip them |
81 | 85 | $vals['rights'] = array_values( array_unique( $wgUser->getRights() ) ); |
82 | 86 | $result->setIndexedTagName( $vals['rights'], 'r' ); // even if empty |
83 | 87 | } |
| 88 | + |
84 | 89 | if ( isset( $this->prop['changeablegroups'] ) ) { |
85 | 90 | $vals['changeablegroups'] = $wgUser->changeableGroups(); |
86 | 91 | $result->setIndexedTagName( $vals['changeablegroups']['add'], 'g' ); |
— | — | @@ -87,18 +92,23 @@ |
88 | 93 | $result->setIndexedTagName( $vals['changeablegroups']['add-self'], 'g' ); |
89 | 94 | $result->setIndexedTagName( $vals['changeablegroups']['remove-self'], 'g' ); |
90 | 95 | } |
| 96 | + |
91 | 97 | if ( isset( $this->prop['options'] ) ) { |
92 | 98 | $vals['options'] = $wgUser->getOptions(); |
93 | 99 | } |
| 100 | + |
94 | 101 | if ( isset( $this->prop['preferencestoken'] ) && is_null( $this->getMain()->getRequest()->getVal( 'callback' ) ) ) { |
95 | 102 | $vals['preferencestoken'] = $wgUser->editToken(); |
96 | 103 | } |
| 104 | + |
97 | 105 | if ( isset( $this->prop['editcount'] ) ) { |
98 | 106 | $vals['editcount'] = intval( $wgUser->getEditCount() ); |
99 | 107 | } |
| 108 | + |
100 | 109 | if ( isset( $this->prop['ratelimits'] ) ) { |
101 | 110 | $vals['ratelimits'] = $this->getRateLimits(); |
102 | 111 | } |
| 112 | + |
103 | 113 | if ( isset( $this->prop['email'] ) ) { |
104 | 114 | $vals['email'] = $wgUser->getEmail(); |
105 | 115 | $auth = $wgUser->getEmailAuthenticationTimestamp(); |
Index: trunk/phase3/includes/api/ApiEmailUser.php |
— | — | @@ -27,7 +27,6 @@ |
28 | 28 | require_once ( "ApiBase.php" ); |
29 | 29 | } |
30 | 30 | |
31 | | - |
32 | 31 | /** |
33 | 32 | * @ingroup API |
34 | 33 | */ |
— | — | @@ -61,8 +60,7 @@ |
62 | 61 | $error = EmailUserForm::getPermissionsError( $wgUser, $params['token'] ); |
63 | 62 | if ( $error ) |
64 | 63 | $this->dieUsageMsg( array( $error ) ); |
65 | | - |
66 | | - |
| 64 | + |
67 | 65 | $form = new EmailUserForm( $targetUser, $params['text'], $params['subject'], $params['ccme'] ); |
68 | 66 | $retval = $form->doSubmit(); |
69 | 67 | if ( is_null( $retval ) ) |
Index: trunk/phase3/includes/api/ApiUndelete.php |
— | — | @@ -48,8 +48,10 @@ |
49 | 49 | |
50 | 50 | if ( !$wgUser->isAllowed( 'undelete' ) ) |
51 | 51 | $this->dieUsageMsg( array( 'permdenied-undelete' ) ); |
| 52 | + |
52 | 53 | if ( $wgUser->isBlocked() ) |
53 | 54 | $this->dieUsageMsg( array( 'blockedtext' ) ); |
| 55 | + |
54 | 56 | if ( !$wgUser->matchEditToken( $params['token'] ) ) |
55 | 57 | $this->dieUsageMsg( array( 'sessionfailure' ) ); |
56 | 58 | |
Index: trunk/phase3/includes/api/ApiQueryExternalLinks.php |
— | — | @@ -51,9 +51,11 @@ |
52 | 52 | |
53 | 53 | $this->addTables( 'externallinks' ); |
54 | 54 | $this->addWhereFld( 'el_from', array_keys( $this->getPageSet()->getGoodTitles() ) ); |
| 55 | + |
55 | 56 | # Don't order by el_from if it's constant in the WHERE clause |
56 | 57 | if ( count( $this->getPageSet()->getGoodTitles() ) != 1 ) |
57 | 58 | $this->addOption( 'ORDER BY', 'el_from' ); |
| 59 | + |
58 | 60 | $this->addOption( 'LIMIT', $params['limit'] + 1 ); |
59 | 61 | if ( !is_null( $params['offset'] ) ) |
60 | 62 | $this->addOption( 'OFFSET', $params['offset'] ); |
Index: trunk/phase3/includes/api/ApiBase.php |
— | — | @@ -657,13 +657,16 @@ |
658 | 658 | return array(); |
659 | 659 | $sizeLimit = $this->mMainModule->canApiHighLimits() ? self::LIMIT_SML2 : self::LIMIT_SML1; |
660 | 660 | $valuesList = explode( '|', $value, $sizeLimit + 1 ); |
| 661 | + |
661 | 662 | if ( self::truncateArray( $valuesList, $sizeLimit ) ) { |
662 | 663 | $this->setWarning( "Too many values supplied for parameter '$valueName': the limit is $sizeLimit" ); |
663 | 664 | } |
| 665 | + |
664 | 666 | if ( !$allowMultiple && count( $valuesList ) != 1 ) { |
665 | 667 | $possibleValues = is_array( $allowedValues ) ? "of '" . implode( "', '", $allowedValues ) . "'" : ''; |
666 | 668 | $this->dieUsage( "Only one $possibleValues is allowed for parameter '$valueName'", "multival_$valueName" ); |
667 | 669 | } |
| 670 | + |
668 | 671 | if ( is_array( $allowedValues ) ) { |
669 | 672 | # Check for unknown values |
670 | 673 | $unknown = array_diff( $valuesList, $allowedValues ); |
Index: trunk/phase3/includes/api/ApiQueryCategories.php |
— | — | @@ -79,6 +79,7 @@ |
80 | 80 | } |
81 | 81 | $this->addWhereFld( 'cl_to', $cats ); |
82 | 82 | } |
| 83 | + |
83 | 84 | if ( !is_null( $params['continue'] ) ) { |
84 | 85 | $cont = explode( '|', $params['continue'] ); |
85 | 86 | if ( count( $cont ) != 2 ) |
— | — | @@ -90,6 +91,7 @@ |
91 | 92 | "(cl_from = $clfrom AND " . |
92 | 93 | "cl_to >= '$clto')" ); |
93 | 94 | } |
| 95 | + |
94 | 96 | if ( isset( $show['hidden'] ) && isset( $show['!hidden'] ) ) |
95 | 97 | $this->dieUsage( "Incorrect parameter - mutually exclusive values may not be supplied", 'show' ); |
96 | 98 | if ( isset( $show['hidden'] ) || isset( $show['!hidden'] ) || isset( $prop['hidden'] ) ) |
Index: trunk/phase3/includes/api/ApiQueryDuplicateFiles.php |
— | — | @@ -63,11 +63,13 @@ |
64 | 64 | 'i2.img_user_text AS dup_user_text', |
65 | 65 | 'i2.img_timestamp AS dup_timestamp' |
66 | 66 | ) ); |
| 67 | + |
67 | 68 | $this->addWhere( array( |
68 | 69 | 'i1.img_name' => array_keys( $images ), |
69 | 70 | 'i1.img_sha1 = i2.img_sha1', |
70 | 71 | 'i1.img_name != i2.img_name', |
71 | 72 | ) ); |
| 73 | + |
72 | 74 | if ( isset( $params['continue'] ) ) |
73 | 75 | { |
74 | 76 | $cont = explode( '|', $params['continue'] ); |
— | — | @@ -80,6 +82,7 @@ |
81 | 83 | "(i1.img_name = '$orig' AND " . |
82 | 84 | "i2.img_name >= '$dup')" ); |
83 | 85 | } |
| 86 | + |
84 | 87 | $this->addOption( 'ORDER BY', 'i1.img_name' ); |
85 | 88 | $this->addOption( 'LIMIT', $params['limit'] + 1 ); |
86 | 89 | |
Index: trunk/phase3/includes/api/ApiUpload.php |
— | — | @@ -50,7 +50,6 @@ |
51 | 51 | if ( !$wgUser->matchEditToken( $this->mParams['token'] ) ) |
52 | 52 | $this->dieUsageMsg( array( 'sessionfailure' ) ); |
53 | 53 | |
54 | | - |
55 | 54 | // Add the uploaded file to the params array |
56 | 55 | $this->mParams['file'] = $request->getFileName( 'file' ); |
57 | 56 | |
— | — | @@ -72,7 +71,7 @@ |
73 | 72 | |
74 | 73 | $this->mUpload = new UploadFromStash(); |
75 | 74 | $this->mUpload->initialize( $this->mParams['filename'], |
76 | | - $_SESSION['wsUploadData'][$this->mParams['sessionkey']] ); |
| 75 | + $_SESSION['wsUploadData'][$this->mParams['sessionkey']] ); |
77 | 76 | } else { |
78 | 77 | /** |
79 | 78 | * Upload from url, etc |
— | — | @@ -113,7 +112,6 @@ |
114 | 113 | if ( ! $wgUser->isAllowed( 'upload_by_url' ) ) |
115 | 114 | $this->dieUsageMsg( array( 'badaccess-groups' ) ); |
116 | 115 | |
117 | | - |
118 | 116 | $this->mUpload = new UploadFromUrl(); |
119 | 117 | $this->mUpload->initialize( $this->mParams['filename'], |
120 | 118 | $this->mParams['url'] ); |
Index: trunk/phase3/includes/api/ApiQueryUsers.php |
— | — | @@ -33,7 +33,6 @@ |
34 | 34 | * |
35 | 35 | * @ingroup API |
36 | 36 | */ |
37 | | - |
38 | 37 | class ApiQueryUsers extends ApiQueryBase { |
39 | 38 | |
40 | 39 | public function __construct( $query, $moduleName ) { |
— | — | @@ -104,6 +103,7 @@ |
105 | 104 | else |
106 | 105 | $goodNames[] = $n; |
107 | 106 | } |
| 107 | + |
108 | 108 | if ( count( $goodNames ) ) |
109 | 109 | { |
110 | 110 | $db = $this->getDb(); |
Index: trunk/phase3/includes/api/ApiQueryImages.php |
— | — | @@ -71,6 +71,7 @@ |
72 | 72 | "(il_from = $ilfrom AND " . |
73 | 73 | "il_to >= '$ilto')" ); |
74 | 74 | } |
| 75 | + |
75 | 76 | # Don't order by il_from if it's constant in the WHERE clause |
76 | 77 | if ( count( $this->getPageSet()->getGoodTitles() ) == 1 ) |
77 | 78 | $this->addOption( 'ORDER BY', 'il_to' ); |
Index: trunk/phase3/includes/api/ApiWatch.php |
— | — | @@ -43,12 +43,16 @@ |
44 | 44 | global $wgUser; |
45 | 45 | if ( !$wgUser->isLoggedIn() ) |
46 | 46 | $this->dieUsage( 'You must be logged-in to have a watchlist', 'notloggedin' ); |
| 47 | + |
47 | 48 | $params = $this->extractRequestParams(); |
48 | 49 | $title = Title::newFromText( $params['title'] ); |
| 50 | + |
49 | 51 | if ( !$title ) |
50 | 52 | $this->dieUsageMsg( array( 'invalidtitle', $params['title'] ) ); |
| 53 | + |
51 | 54 | $article = new Article( $title ); |
52 | 55 | $res = array( 'title' => $title->getPrefixedText() ); |
| 56 | + |
53 | 57 | if ( $params['unwatch'] ) |
54 | 58 | { |
55 | 59 | $res['unwatched'] = ''; |
Index: trunk/phase3/includes/api/ApiMove.php |
— | — | @@ -63,6 +63,7 @@ |
64 | 64 | if ( !$fromTitle ) |
65 | 65 | $this->dieUsageMsg( array( 'nosuchpageid', $params['fromid'] ) ); |
66 | 66 | } |
| 67 | + |
67 | 68 | if ( !$fromTitle->exists() ) |
68 | 69 | $this->dieUsageMsg( array( 'notanarticle' ) ); |
69 | 70 | $fromTalk = $fromTitle->getTalkPage(); |
Index: trunk/phase3/includes/api/ApiQueryAllpages.php |
— | — | @@ -137,8 +137,6 @@ |
138 | 138 | if ( $forceNameTitleIndex ) |
139 | 139 | $this->addOption( 'USE INDEX', 'name_title' ); |
140 | 140 | |
141 | | - |
142 | | - |
143 | 141 | $limit = $params['limit']; |
144 | 142 | $this->addOption( 'LIMIT', $limit + 1 ); |
145 | 143 | $res = $this->select( __METHOD__ ); |
Index: trunk/phase3/includes/api/ApiFormatWddx.php |
— | — | @@ -80,8 +80,7 @@ |
81 | 81 | if ( $cnt == 0 || array_keys( $elemValue ) === range( 0, $cnt - 1 ) ) { |
82 | 82 | // Regular array |
83 | 83 | $this->printText( $indstr . Xml::element( 'array', array( |
84 | | - 'length' => $cnt |
85 | | - ), null ) . $nl ); |
| 84 | + 'length' => $cnt ), null ) . $nl ); |
86 | 85 | foreach ( $elemValue as $subElemValue ) |
87 | 86 | $this->slowWddxPrinter( $subElemValue, $indent + 2 ); |
88 | 87 | $this->printText( "$indstr</array>$nl" ); |
Index: trunk/phase3/includes/api/ApiQueryDeletedrevs.php |
— | — | @@ -202,8 +202,7 @@ |
203 | 203 | $rev['user'] = $row->ar_user_text; |
204 | 204 | if ( $fld_comment ) |
205 | 205 | $rev['comment'] = $row->ar_comment; |
206 | | - if ( $fld_minor ) |
207 | | - if ( $row->ar_minor_edit == 1 ) |
| 206 | + if ( $fld_minor && $row->ar_minor_edit == 1) |
208 | 207 | $rev['minor'] = ''; |
209 | 208 | if ( $fld_len ) |
210 | 209 | $rev['len'] = $row->ar_len; |
Index: trunk/phase3/includes/api/ApiExpandTemplates.php |
— | — | @@ -55,6 +55,7 @@ |
56 | 56 | // Parse text |
57 | 57 | global $wgParser; |
58 | 58 | $options = new ParserOptions(); |
| 59 | + |
59 | 60 | if ( $params['generatexml'] ) |
60 | 61 | { |
61 | 62 | $wgParser->startExternalParse( $title_obj, $options, OT_PREPROCESS ); |
Index: trunk/phase3/includes/api/ApiUserrights.php |
— | — | @@ -27,7 +27,6 @@ |
28 | 28 | require_once ( "ApiBase.php" ); |
29 | 29 | } |
30 | 30 | |
31 | | - |
32 | 31 | /** |
33 | 32 | * @ingroup API |
34 | 33 | */ |
— | — | @@ -49,8 +48,8 @@ |
50 | 49 | $user = $form->fetchUser( $params['user'] ); |
51 | 50 | if ( $user instanceof WikiErrorMsg ) |
52 | 51 | $this->dieUsageMsg( array_merge( |
53 | | - (array)$user->getMessageKey(), |
54 | | - $user->getMessageArgs() ) ); |
| 52 | + (array)$user->getMessageKey(), $user->getMessageArgs() ) ); |
| 53 | + |
55 | 54 | if ( !$wgUser->matchEditToken( $params['token'], $user->getName() ) ) |
56 | 55 | $this->dieUsageMsg( array( 'sessionfailure' ) ); |
57 | 56 | |
Index: trunk/phase3/includes/api/ApiDelete.php |
— | — | @@ -27,7 +27,6 @@ |
28 | 28 | require_once ( "ApiBase.php" ); |
29 | 29 | } |
30 | 30 | |
31 | | - |
32 | 31 | /** |
33 | 32 | * API module that facilitates deleting pages. The API eqivalent of action=delete. |
34 | 33 | * Requires API write mode to be enabled. |
— | — | @@ -74,15 +73,13 @@ |
75 | 74 | if ( $titleObj->getNamespace() == NS_FILE ) { |
76 | 75 | $retval = self::deleteFile( $params['token'], $titleObj, $params['oldimage'], $reason, false ); |
77 | 76 | if ( count( $retval ) ) |
78 | | - // We don't care about multiple errors, just report one of them |
79 | | - $this->dieUsageMsg( reset( $retval ) ); |
| 77 | + $this->dieUsageMsg( reset( $retval ) ); // We don't care about multiple errors, just report one of them |
80 | 78 | } else { |
81 | 79 | $articleObj = new Article( $titleObj ); |
82 | 80 | $retval = self::delete( $articleObj, $params['token'], $reason ); |
83 | 81 | |
84 | 82 | if ( count( $retval ) ) |
85 | | - // We don't care about multiple errors, just report one of them |
86 | | - $this->dieUsageMsg( reset( $retval ) ); |
| 83 | + $this->dieUsageMsg( reset( $retval ) ); // We don't care about multiple errors, just report one of them |
87 | 84 | |
88 | 85 | if ( $params['watch'] || $wgUser->getOption( 'watchdeletion' ) ) |
89 | 86 | $articleObj->doWatch(); |
Index: trunk/phase3/includes/api/ApiDisabled.php |
— | — | @@ -27,7 +27,6 @@ |
28 | 28 | require_once ( "ApiBase.php" ); |
29 | 29 | } |
30 | 30 | |
31 | | - |
32 | 31 | /** |
33 | 32 | * API module that dies with an error immediately. |
34 | 33 | * |
Index: trunk/phase3/includes/api/ApiImport.php |
— | — | @@ -91,8 +91,8 @@ |
92 | 92 | $result->mByte . $result->mContext, |
93 | 93 | xml_error_string( $result->mXmlError ) ) ); |
94 | 94 | else if ( WikiError::isError( $result ) ) |
95 | | - // This shouldn't happen |
96 | | - $this->dieUsageMsg( array( 'import-unknownerror', $result->getMessage() ) ); |
| 95 | + $this->dieUsageMsg( array( 'import-unknownerror', $result->getMessage() ) ); // This shouldn't happen |
| 96 | + |
97 | 97 | $resultData = $reporter->getData(); |
98 | 98 | $this->getResult()->setIndexedTagName( $resultData, 'page' ); |
99 | 99 | $this->getResult()->addValue( null, $this->getModuleName(), $resultData ); |
Index: trunk/phase3/includes/api/ApiResult.php |
— | — | @@ -199,17 +199,16 @@ |
200 | 200 | * @param $arr array |
201 | 201 | * @param $tag string Tag name |
202 | 202 | */ |
203 | | - public function setIndexedTagName_recursive( &$arr, $tag ) |
204 | | - { |
205 | | - if ( !is_array( $arr ) ) |
206 | | - return; |
207 | | - foreach ( $arr as &$a ) |
208 | | - { |
209 | | - if ( !is_array( $a ) ) |
210 | | - continue; |
211 | | - $this->setIndexedTagName( $a, $tag ); |
212 | | - $this->setIndexedTagName_recursive( $a, $tag ); |
213 | | - } |
| 203 | + public function setIndexedTagName_recursive( &$arr, $tag ) { |
| 204 | + if ( !is_array( $arr ) ) |
| 205 | + return; |
| 206 | + foreach ( $arr as &$a ) |
| 207 | + { |
| 208 | + if ( !is_array( $a ) ) |
| 209 | + continue; |
| 210 | + $this->setIndexedTagName( $a, $tag ); |
| 211 | + $this->setIndexedTagName_recursive( $a, $tag ); |
| 212 | + } |
214 | 213 | } |
215 | 214 | |
216 | 215 | /** |
Index: trunk/phase3/includes/api/ApiQueryCategoryInfo.php |
— | — | @@ -65,8 +65,10 @@ |
66 | 66 | 'pp_page=page_id', |
67 | 67 | 'pp_propname' => 'hiddencat' ) ), |
68 | 68 | ) ); |
| 69 | + |
69 | 70 | $this->addFields( array( 'cat_title', 'cat_pages', 'cat_subcats', 'cat_files', 'pp_propname AS cat_hidden' ) ); |
70 | 71 | $this->addWhere( array( 'cat_title' => $cattitles ) ); |
| 72 | + |
71 | 73 | if ( !is_null( $params['continue'] ) ) |
72 | 74 | { |
73 | 75 | $title = $this->getDB()->addQuotes( $params['continue'] ); |
Index: trunk/phase3/includes/api/ApiEditPage.php |
— | — | @@ -44,14 +44,18 @@ |
45 | 45 | public function execute() { |
46 | 46 | global $wgUser; |
47 | 47 | $params = $this->extractRequestParams(); |
| 48 | + |
48 | 49 | if ( is_null( $params['title'] ) ) |
49 | 50 | $this->dieUsageMsg( array( 'missingparam', 'title' ) ); |
| 51 | + |
50 | 52 | if ( is_null( $params['text'] ) && is_null( $params['appendtext'] ) && |
51 | 53 | is_null( $params['prependtext'] ) && |
52 | 54 | $params['undo'] == 0 ) |
53 | 55 | $this->dieUsageMsg( array( 'missingtext' ) ); |
| 56 | + |
54 | 57 | if ( is_null( $params['token'] ) ) |
55 | 58 | $this->dieUsageMsg( array( 'missingparam', 'token' ) ); |
| 59 | + |
56 | 60 | if ( !$wgUser->matchEditToken( $params['token'] ) ) |
57 | 61 | $this->dieUsageMsg( array( 'sessionfailure' ) ); |
58 | 62 | |
— | — | @@ -113,14 +117,17 @@ |
114 | 118 | $undoRev = Revision::newFromID( $params['undo'] ); |
115 | 119 | if ( is_null( $undoRev ) || $undoRev->isDeleted( Revision::DELETED_TEXT ) ) |
116 | 120 | $this->dieUsageMsg( array( 'nosuchrevid', $params['undo'] ) ); |
| 121 | + |
117 | 122 | if ( $params['undoafter'] == 0 ) |
118 | 123 | $undoafterRev = $undoRev->getPrevious(); |
119 | 124 | if ( is_null( $undoafterRev ) || $undoafterRev->isDeleted( Revision::DELETED_TEXT ) ) |
120 | 125 | $this->dieUsageMsg( array( 'nosuchrevid', $params['undoafter'] ) ); |
| 126 | + |
121 | 127 | if ( $undoRev->getPage() != $articleObj->getID() ) |
122 | 128 | $this->dieUsageMsg( array( 'revwrongpage', $undoRev->getID(), $titleObj->getPrefixedText() ) ); |
123 | 129 | if ( $undoafterRev->getPage() != $articleObj->getID() ) |
124 | 130 | $this->dieUsageMsg( array( 'revwrongpage', $undoafterRev->getID(), $titleObj->getPrefixedText() ) ); |
| 131 | + |
125 | 132 | $newtext = $articleObj->getUndoText( $undoRev, $undoafterRev ); |
126 | 133 | if ( $newtext === false ) |
127 | 134 | $this->dieUsageMsg( array( 'undo-failure' ) ); |
— | — | @@ -132,9 +139,8 @@ |
133 | 140 | } |
134 | 141 | |
135 | 142 | # See if the MD5 hash checks out |
136 | | - if ( !is_null( $params['md5'] ) ) |
137 | | - if ( md5( $toMD5 ) !== $params['md5'] ) |
138 | | - $this->dieUsageMsg( array( 'hashcheckfailed' ) ); |
| 143 | + if ( !is_null( $params['md5'] ) && md5( $toMD5 ) !== $params['md5'] ) |
| 144 | + $this->dieUsageMsg( array( 'hashcheckfailed' ) ); |
139 | 145 | |
140 | 146 | $ep = new EditPage( $articleObj ); |
141 | 147 | // EditPage wants to parse its stuff from a WebRequest |
— | — | @@ -143,23 +149,28 @@ |
144 | 150 | 'wpEditToken' => $params['token'], |
145 | 151 | 'wpIgnoreBlankSummary' => '' |
146 | 152 | ); |
| 153 | + |
147 | 154 | if ( !is_null( $params['summary'] ) ) |
148 | 155 | $reqArr['wpSummary'] = $params['summary']; |
| 156 | + |
149 | 157 | # Watch out for basetimestamp == '' |
150 | 158 | # wfTimestamp() treats it as NOW, almost certainly causing an edit conflict |
151 | 159 | if ( !is_null( $params['basetimestamp'] ) && $params['basetimestamp'] != '' ) |
152 | 160 | $reqArr['wpEdittime'] = wfTimestamp( TS_MW, $params['basetimestamp'] ); |
153 | 161 | else |
154 | 162 | $reqArr['wpEdittime'] = $articleObj->getTimestamp(); |
| 163 | + |
155 | 164 | if ( !is_null( $params['starttimestamp'] ) && $params['starttimestamp'] != '' ) |
156 | 165 | $reqArr['wpStarttime'] = wfTimestamp( TS_MW, $params['starttimestamp'] ); |
157 | 166 | else |
158 | | - # Fake wpStartime |
159 | | - $reqArr['wpStarttime'] = $reqArr['wpEdittime']; |
| 167 | + $reqArr['wpStarttime'] = $reqArr['wpEdittime']; # Fake wpStartime |
| 168 | + |
160 | 169 | if ( $params['minor'] || ( !$params['notminor'] && $wgUser->getOption( 'minordefault' ) ) ) |
161 | 170 | $reqArr['wpMinoredit'] = ''; |
| 171 | + |
162 | 172 | if ( $params['recreate'] ) |
163 | 173 | $reqArr['wpRecreate'] = ''; |
| 174 | + |
164 | 175 | if ( !is_null( $params['section'] ) ) |
165 | 176 | { |
166 | 177 | $section = intval( $params['section'] ); |
— | — | @@ -208,6 +219,7 @@ |
209 | 220 | $wgRequest->setVal( 'wpCaptchaId', $params['captchaid'] ); |
210 | 221 | if ( !is_null( $params['captchaword'] ) ) |
211 | 222 | $wgRequest->setVal( 'wpCaptchaWord', $params['captchaword'] ); |
| 223 | + |
212 | 224 | $r = array(); |
213 | 225 | if ( !wfRunHooks( 'APIEditBeforeSave', array( $ep, $ep->textbox1, &$r ) ) ) |
214 | 226 | { |
— | — | @@ -236,39 +248,55 @@ |
237 | 249 | case EditPage::AS_HOOK_ERROR: |
238 | 250 | case EditPage::AS_HOOK_ERROR_EXPECTED: |
239 | 251 | $this->dieUsageMsg( array( 'hookaborted' ) ); |
| 252 | + |
240 | 253 | case EditPage::AS_IMAGE_REDIRECT_ANON: |
241 | 254 | $this->dieUsageMsg( array( 'noimageredirect-anon' ) ); |
| 255 | + |
242 | 256 | case EditPage::AS_IMAGE_REDIRECT_LOGGED: |
243 | 257 | $this->dieUsageMsg( array( 'noimageredirect-logged' ) ); |
| 258 | + |
244 | 259 | case EditPage::AS_SPAM_ERROR: |
245 | 260 | $this->dieUsageMsg( array( 'spamdetected', $result['spam'] ) ); |
| 261 | + |
246 | 262 | case EditPage::AS_FILTERING: |
247 | 263 | $this->dieUsageMsg( array( 'filtered' ) ); |
| 264 | + |
248 | 265 | case EditPage::AS_BLOCKED_PAGE_FOR_USER: |
249 | 266 | $this->dieUsageMsg( array( 'blockedtext' ) ); |
| 267 | + |
250 | 268 | case EditPage::AS_MAX_ARTICLE_SIZE_EXCEEDED: |
251 | 269 | case EditPage::AS_CONTENT_TOO_BIG: |
252 | 270 | global $wgMaxArticleSize; |
253 | 271 | $this->dieUsageMsg( array( 'contenttoobig', $wgMaxArticleSize ) ); |
| 272 | + |
254 | 273 | case EditPage::AS_READ_ONLY_PAGE_ANON: |
255 | 274 | $this->dieUsageMsg( array( 'noedit-anon' ) ); |
| 275 | + |
256 | 276 | case EditPage::AS_READ_ONLY_PAGE_LOGGED: |
257 | 277 | $this->dieUsageMsg( array( 'noedit' ) ); |
| 278 | + |
258 | 279 | case EditPage::AS_READ_ONLY_PAGE: |
259 | 280 | $this->dieReadOnly(); |
| 281 | + |
260 | 282 | case EditPage::AS_RATE_LIMITED: |
261 | 283 | $this->dieUsageMsg( array( 'actionthrottledtext' ) ); |
| 284 | + |
262 | 285 | case EditPage::AS_ARTICLE_WAS_DELETED: |
263 | 286 | $this->dieUsageMsg( array( 'wasdeleted' ) ); |
| 287 | + |
264 | 288 | case EditPage::AS_NO_CREATE_PERMISSION: |
265 | 289 | $this->dieUsageMsg( array( 'nocreate-loggedin' ) ); |
| 290 | + |
266 | 291 | case EditPage::AS_BLANK_ARTICLE: |
267 | 292 | $this->dieUsageMsg( array( 'blankpage' ) ); |
| 293 | + |
268 | 294 | case EditPage::AS_CONFLICT_DETECTED: |
269 | 295 | $this->dieUsageMsg( array( 'editconflict' ) ); |
| 296 | + |
270 | 297 | # case EditPage::AS_SUMMARY_NEEDED: Can't happen since we set wpIgnoreBlankSummary |
271 | 298 | case EditPage::AS_TEXTBOX_EMPTY: |
272 | 299 | $this->dieUsageMsg( array( 'emptynewsection' ) ); |
| 300 | + |
273 | 301 | case EditPage::AS_SUCCESS_NEW_ARTICLE: |
274 | 302 | $r['new'] = ''; |
275 | 303 | case EditPage::AS_SUCCESS_UPDATE: |
— | — | @@ -291,6 +319,7 @@ |
292 | 320 | $newArticle->getTimestamp() ); |
293 | 321 | } |
294 | 322 | break; |
| 323 | + |
295 | 324 | case EditPage::AS_END: |
296 | 325 | # This usually means some kind of race condition |
297 | 326 | # or DB weirdness occurred. Fall through to throw an unknown |