Index: trunk/extensions/ArticleFeedback/modules/ext.articleFeedback/ext.articleFeedback.js |
— | — | @@ -278,7 +278,7 @@ |
279 | 279 | 'weight': 2, |
280 | 280 | 'condition': function() { |
281 | 281 | // An empty restrictions array means anyone can edit |
282 | | - var restrictions = mw.config.get( 'wgRestrictionEdit' ); |
| 282 | + var restrictions = mw.config.get( 'wgRestrictionEdit', [] ); |
283 | 283 | if ( restrictions.length ) { |
284 | 284 | var groups = mw.config.get( 'wgUserGroups' ); |
285 | 285 | // Verify that each restriction exists in the user's groups |
Index: trunk/extensions/ArticleFeedback/modules/ext.articleFeedback/ext.articleFeedback.startup.js |
— | — | @@ -3,8 +3,10 @@ |
4 | 4 | */ |
5 | 5 | |
6 | 6 | jQuery( function( $ ) { |
| 7 | + // Load check, is this page ArticleFeedback-enabled ? |
| 8 | + // Keep in sync with ApiArticleFeedback.php |
7 | 9 | if ( |
8 | | - // Main namespace articles |
| 10 | + // Only on pages in namespaces where it is enabled |
9 | 11 | $.inArray( mw.config.get( 'wgNamespaceNumber' ), mw.config.get( 'wgArticleFeedbackNamespaces', [] ) ) > -1 |
10 | 12 | // Existing pages |
11 | 13 | && mw.config.get( 'wgArticleId' ) > 0 |
Index: trunk/extensions/ArticleFeedback/api/ApiArticleFeedback.php |
— | — | @@ -5,9 +5,11 @@ |
6 | 6 | } |
7 | 7 | |
8 | 8 | public function execute() { |
9 | | - global $wgUser, $wgArticleFeedbackRatings, $wgArticleFeedbackSMaxage; |
| 9 | + global $wgUser, $wgArticleFeedbackRatings, $wgArticleFeedbackSMaxage, |
| 10 | + $wgArticleFeedbackNamespaces; |
10 | 11 | $params = $this->extractRequestParams(); |
11 | 12 | |
| 13 | + // Anon token check |
12 | 14 | if ( $wgUser->isAnon() ) { |
13 | 15 | if ( !isset( $params['anontoken'] ) ) { |
14 | 16 | $this->dieUsageMsg( array( 'missingparam', 'anontoken' ) ); |
— | — | @@ -20,6 +22,21 @@ |
21 | 23 | $token = ''; |
22 | 24 | } |
23 | 25 | |
| 26 | + // Load check, is this page ArticleFeedback-enabled ? |
| 27 | + // Keep in sync with ext.articleFeedback.startup.js |
| 28 | + $title = Title::newFromID( $params['pageid'] ); |
| 29 | + if ( |
| 30 | + // Inexisting page ? (newFromID returns null so we can't use $title->exists) |
| 31 | + is_null( $title ) |
| 32 | + // Namespace not a valid ArticleFeedback namespace ? |
| 33 | + || !in_array( $title->getNamespace(), $wgArticleFeedbackNamespaces ) |
| 34 | + // Page a redirect ? |
| 35 | + || $title->isRedirect() |
| 36 | + ) { |
| 37 | + // ...then error out |
| 38 | + $this->dieUsage( 'ArticleFeedback is not enabled on this page', 'invalidpage' ); |
| 39 | + } |
| 40 | + |
24 | 41 | $dbr = wfGetDB( DB_SLAVE ); |
25 | 42 | |
26 | 43 | // Query the latest ratings by this user for this page, |
— | — | @@ -424,6 +441,7 @@ |
425 | 442 | return array_merge( parent::getPossibleErrors(), array( |
426 | 443 | array( 'missingparam', 'anontoken' ), |
427 | 444 | array( 'code' => 'invalidtoken', 'info' => 'The anontoken is not 32 characters' ), |
| 445 | + array( 'code' => 'invalidpage', 'info' => 'ArticleFeedback is not enabled on this page' ), |
428 | 446 | ) ); |
429 | 447 | } |
430 | 448 | |