Index: trunk/extensions/CodeReview/api/ApiCodeTestUpload.php |
— | — | @@ -9,7 +9,7 @@ |
10 | 10 | $this->dieUsage( 'You don\'t have permission to upload test results', 'permissiondenied' ); |
11 | 11 | } |
12 | 12 | $params = $this->extractRequestParams(); |
13 | | - |
| 13 | + |
14 | 14 | $this->validateParams( $params ); |
15 | 15 | $this->validateHmac( $params ); |
16 | 16 | |
— | — | @@ -17,16 +17,16 @@ |
18 | 18 | if ( !$repo ) { |
19 | 19 | $this->dieUsage( "Invalid repo ``{$params['repo']}''", 'invalidrepo' ); |
20 | 20 | } |
21 | | - |
| 21 | + |
22 | 22 | $suite = $repo->getTestSuite( $params['suite'] ); |
23 | 23 | if ( !$suite ) { |
24 | 24 | $this->dieUsage( "Invalid test suite ``{$params['suite']}''", 'invalidsuite' ); |
25 | 25 | } |
26 | | - |
| 26 | + |
27 | 27 | // Note that we might be testing a revision that hasn't gotten slurped in yet, |
28 | 28 | // so we won't reject data for revisions we don't know about yet. |
29 | 29 | $revId = intval( $params['rev'] ); |
30 | | - |
| 30 | + |
31 | 31 | $status = $params['status']; |
32 | 32 | if ( $status == 'running' || $status == 'aborted' ) { |
33 | 33 | // Set the 'tests running' flag so we can mark it... |
— | — | @@ -35,12 +35,12 @@ |
36 | 36 | // Save data and mark running test as completed. |
37 | 37 | $results = json_decode( $params['results'], true ); |
38 | 38 | if ( !is_array( $results ) ) { |
39 | | - $this->dieUsage( "Invalid test result data", 'invalidresults' ); |
| 39 | + $this->dieUsage( 'Invalid test result data', 'invalidresults' ); |
40 | 40 | } |
41 | 41 | $suite->saveResults( $revId, $results ); |
42 | 42 | } |
43 | 43 | } |
44 | | - |
| 44 | + |
45 | 45 | protected function validateParams( $params ) { |
46 | 46 | $required = array( 'repo', 'suite', 'rev', 'status', 'hmac' ); |
47 | 47 | if ( isset( $params['status'] ) && $params['status'] == 'complete' ) { |
— | — | @@ -52,10 +52,10 @@ |
53 | 53 | } |
54 | 54 | } |
55 | 55 | } |
56 | | - |
| 56 | + |
57 | 57 | protected function validateHmac( $params ) { |
58 | 58 | global $wgCodeReviewSharedSecret; |
59 | | - |
| 59 | + |
60 | 60 | // Generate a hash MAC to validate our credentials |
61 | 61 | $message = array( |
62 | 62 | $params['repo'], |
— | — | @@ -63,10 +63,10 @@ |
64 | 64 | $params['rev'], |
65 | 65 | $params['status'], |
66 | 66 | ); |
67 | | - if ( $params['status'] == "complete" ) { |
| 67 | + if ( $params['status'] == 'complete' ) { |
68 | 68 | $message[] = $params['results']; |
69 | 69 | } |
70 | | - $hmac = hash_hmac( "sha1", implode( "|", $message ), $wgCodeReviewSharedSecret ); |
| 70 | + $hmac = hash_hmac( 'sha1', implode( '|', $message ), $wgCodeReviewSharedSecret ); |
71 | 71 | if ( $hmac != $params['hmac'] ) { |
72 | 72 | $this->dieUsageMsg( array( 'invalidhmac', $params['hmac'] ) ); |
73 | 73 | } |
— | — | @@ -76,7 +76,7 @@ |
77 | 77 | // Discourage casual browsing :) |
78 | 78 | return true; |
79 | 79 | } |
80 | | - |
| 80 | + |
81 | 81 | public function isWriteMode() { |
82 | 82 | return true; |
83 | 83 | } |
— | — | @@ -107,7 +107,7 @@ |
108 | 108 | 'results' => 'JSON-encoded map of test names to success results, for status "complete"', |
109 | 109 | ); |
110 | 110 | } |
111 | | - |
| 111 | + |
112 | 112 | public function getPossibleErrors() { |
113 | 113 | return array_merge( parent::getPossibleErrors(), array( |
114 | 114 | array( 'code' => 'permissiondenied', 'info' => 'You don\'t have permission to upload test results' ), |
Index: trunk/extensions/CodeReview/api/ApiCodeComments.php |
— | — | @@ -1,11 +1,11 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | | -/* |
| 4 | +/** |
5 | 5 | * Created on Oct 29, 2008 |
6 | 6 | * |
7 | 7 | * API for MediaWiki 1.8+ |
8 | 8 | * |
9 | | - * Copyright (C) 2008 Bryan Tong Minh <Bryan.TongMinh@Gmail.com> |
| 9 | + * Copyright © 2008 Bryan Tong Minh <Bryan.TongMinh@Gmail.com> |
10 | 10 | * |
11 | 11 | * This program is free software; you can redistribute it and/or modify |
12 | 12 | * it under the terms of the GNU General Public License as published by |
— | — | @@ -35,19 +35,23 @@ |
36 | 36 | $this->dieUsage( 'You don\'t have permission to view code comments', 'permissiondenied' ); |
37 | 37 | } |
38 | 38 | $params = $this->extractRequestParams(); |
39 | | - if ( is_null( $params['repo'] ) ) |
| 39 | + if ( is_null( $params['repo'] ) ) { |
40 | 40 | $this->dieUsageMsg( array( 'missingparam', 'repo' ) ); |
| 41 | + } |
41 | 42 | $this->props = array_flip( $params['prop'] ); |
42 | | - if ( isset( $this->props['revision'] ) ) |
| 43 | + if ( isset( $this->props['revision'] ) ) { |
43 | 44 | $this->setWarning( 'ccprop=revision has been deprecated in favor of ccprop=status' ); |
| 45 | + } |
44 | 46 | |
45 | 47 | $listview = new CodeCommentsListView( $params['repo'] ); |
46 | | - if ( is_null( $listview->getRepo() ) ) |
| 48 | + if ( is_null( $listview->getRepo() ) ) { |
47 | 49 | $this->dieUsage( "Invalid repo ``{$params['repo']}''", 'invalidrepo' ); |
| 50 | + } |
48 | 51 | $pager = $listview->getPager(); |
49 | 52 | |
50 | | - if ( !is_null( $params['start'] ) ) |
| 53 | + if ( !is_null( $params['start'] ) ) { |
51 | 54 | $pager->setOffset( $this->getDB()->timestamp( $params['start'] ) ); |
| 55 | + } |
52 | 56 | $limit = $params['limit']; |
53 | 57 | $pager->setLimit( $limit ); |
54 | 58 | |
— | — | @@ -78,36 +82,41 @@ |
79 | 83 | |
80 | 84 | private function formatRow( $row ) { |
81 | 85 | $item = array(); |
82 | | - if ( isset( $this->props['revid'] ) ) |
| 86 | + if ( isset( $this->props['revid'] ) ) { |
83 | 87 | $item['revid'] = $row->cc_rev_id; |
84 | | - if ( isset( $this->props['timestamp'] ) ) |
| 88 | + } |
| 89 | + if ( isset( $this->props['timestamp'] ) ) { |
85 | 90 | $item['timestamp'] = wfTimestamp( TS_ISO_8601, $row->cc_timestamp ); |
86 | | - if ( isset( $this->props['user'] ) ) |
| 91 | + } |
| 92 | + if ( isset( $this->props['user'] ) ) { |
87 | 93 | $item['user'] = $row->cc_user_text; |
88 | | - if ( isset( $this->props['revision'] ) || isset( $this->props['status'] ) ) |
| 94 | + } |
| 95 | + if ( isset( $this->props['revision'] ) || isset( $this->props['status'] ) ) { |
89 | 96 | $item['status'] = $row->cr_status; |
90 | | - if ( isset( $this->props['text'] ) ) |
| 97 | + } |
| 98 | + if ( isset( $this->props['text'] ) ) { |
91 | 99 | ApiResult::setContent( $item, $row->cc_text ); |
| 100 | + } |
92 | 101 | return $item; |
93 | 102 | } |
94 | 103 | |
95 | 104 | public function getAllowedParams() { |
96 | | - return array ( |
| 105 | + return array( |
97 | 106 | 'repo' => null, |
98 | | - 'limit' => array ( |
99 | | - ApiBase :: PARAM_DFLT => 10, |
100 | | - ApiBase :: PARAM_TYPE => 'limit', |
101 | | - ApiBase :: PARAM_MIN => 1, |
102 | | - ApiBase :: PARAM_MAX => ApiBase :: LIMIT_BIG1, |
103 | | - ApiBase :: PARAM_MAX2 => ApiBase :: LIMIT_BIG2 |
| 107 | + 'limit' => array( |
| 108 | + ApiBase::PARAM_DFLT => 10, |
| 109 | + ApiBase::PARAM_TYPE => 'limit', |
| 110 | + ApiBase::PARAM_MIN => 1, |
| 111 | + ApiBase::PARAM_MAX => ApiBase::LIMIT_BIG1, |
| 112 | + ApiBase::PARAM_MAX2 => ApiBase::LIMIT_BIG2 |
104 | 113 | ), |
105 | 114 | 'start' => array( |
106 | | - ApiBase :: PARAM_TYPE => 'timestamp' |
| 115 | + ApiBase::PARAM_TYPE => 'timestamp' |
107 | 116 | ), |
108 | | - 'prop' => array ( |
109 | | - ApiBase :: PARAM_ISMULTI => true, |
110 | | - ApiBase :: PARAM_DFLT => 'timestamp|user|status|revid', |
111 | | - ApiBase :: PARAM_TYPE => array ( |
| 117 | + 'prop' => array( |
| 118 | + ApiBase::PARAM_ISMULTI => true, |
| 119 | + ApiBase::PARAM_DFLT => 'timestamp|user|status|revid', |
| 120 | + ApiBase::PARAM_TYPE => array( |
112 | 121 | 'timestamp', |
113 | 122 | 'user', |
114 | 123 | 'status', |
— | — | @@ -131,7 +140,7 @@ |
132 | 141 | public function getDescription() { |
133 | 142 | return 'List comments on revisions in CodeReview'; |
134 | 143 | } |
135 | | - |
| 144 | + |
136 | 145 | public function getPossibleErrors() { |
137 | 146 | return array_merge( parent::getPossibleErrors(), array( |
138 | 147 | array( 'missingparam', 'repo' ), |
Index: trunk/extensions/CodeReview/api/ApiCodeDiff.php |
— | — | @@ -69,7 +69,7 @@ |
70 | 70 | return array( |
71 | 71 | 'Fetch formatted diff from CodeReview\'s backing revision control system.' ); |
72 | 72 | } |
73 | | - |
| 73 | + |
74 | 74 | public function getPossibleErrors() { |
75 | 75 | return array_merge( parent::getPossibleErrors(), array( |
76 | 76 | array( 'code' => 'permissiondenied', 'info' => 'You don\'t have permission to view code diffs' ), |
Index: trunk/extensions/CodeReview/api/ApiCodeUpdate.php |
— | — | @@ -37,7 +37,7 @@ |
38 | 38 | if ( !$log ) { |
39 | 39 | // FIXME: When and how often does this happen? |
40 | 40 | // Should we use dieUsage() here instead? |
41 | | - ApiBase::dieDebug( __METHOD__, "Something awry..." ); |
| 41 | + ApiBase::dieDebug( __METHOD__, 'Something awry...' ); |
42 | 42 | } |
43 | 43 | |
44 | 44 | $result = array(); |
— | — | @@ -68,7 +68,7 @@ |
69 | 69 | // Discourage casual browsing :) |
70 | 70 | return true; |
71 | 71 | } |
72 | | - |
| 72 | + |
73 | 73 | public function isWriteMode() { |
74 | 74 | return true; |
75 | 75 | } |
— | — | @@ -93,7 +93,7 @@ |
94 | 94 | return array( |
95 | 95 | 'Update CodeReview repository data from master revision control system.' ); |
96 | 96 | } |
97 | | - |
| 97 | + |
98 | 98 | public function getPossibleErrors() { |
99 | 99 | return array_merge( parent::getPossibleErrors(), array( |
100 | 100 | array( 'code' => 'permissiondenied', 'info' => 'You don\'t have permission update code' ), |