r111114 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r111113‎ | r111114 | r111115 >
Date:22:32, 9 February 2012
Author:werdna
Status:ok (Comments)
Tags:
Comment:
Reimplement bucketing using the new PHPBucket interface. Sadly, it works better.
Modified paths:
  • /trunk/extensions/ArticleCreationWorkflow/ArticleCreationWorkflow.hooks.php (modified) (history)
  • /trunk/extensions/ArticleCreationWorkflow/includes/ArticleCreationUtil.php (modified) (history)
  • /trunk/extensions/ArticleCreationWorkflow/modules/ext.articleCreation.init/ext.articleCreation.init.js (modified) (history)

Diff [purge]

Index: trunk/extensions/ArticleCreationWorkflow/includes/ArticleCreationUtil.php
@@ -6,6 +6,37 @@
77 class ArticleCreationUtil {
88
99 /**
 10+ * Is ArticleCreation enabled for the current user?
 11+ *
 12+ *
 13+ * @return bool whether or not it is.
 14+ */
 15+ public static function isEnabled() {
 16+ return true;
 17+ global $wgUser, $wgArticleCreationRegistrationCutoff;
 18+
 19+ $userRegistration = wfTimestamp( TS_MW, $wgUser->getRegistration() );
 20+
 21+ $bucketConfig = array(
 22+ 'buckets' => array(
 23+ 'on' => 1,
 24+ 'off' => 99,
 25+ ),
 26+ 'version' => 1,
 27+ );
 28+
 29+ if ( !$userRegistration ||
 30+ $userRegistration > $wgArticleCreationRegistrationCutoff
 31+ ) {
 32+ $bucket = PHPBucket::getBucket( 'ac-enabled', $bucketConfig );
 33+
 34+ return $bucket === 'on';
 35+ } else {
 36+ return false;
 37+ }
 38+ }
 39+
 40+ /**
1041 * Check if tracking is enabled, in this case - ClickTracking
1142 * @return bool
1243 */
Index: trunk/extensions/ArticleCreationWorkflow/modules/ext.articleCreation.init/ext.articleCreation.init.js
@@ -1,17 +1,9 @@
2 -(function($,mw) {
3 - var bucket = mw.user.bucket( 'ACWInterstitialTest', {
4 - 'buckets': { 'control': 99, 'test': 1 },
5 - 'version': 1,
6 - } );
7 -
8 - if( bucket === 'test' ) {
9 - // extract the path, article title, and query string as separate components.
10 - var locationParts = location.href.match(/(.+)\/([^\/]+?)((\?.*)|$)/);
11 -
12 - // change the link to point to the new special page
13 - $("div.noarticletext").find('a[href*="action=edit"]').attr(
14 - 'href',
15 - locationParts[1] + '/' + 'Special:ArticleCreationLanding' + '/' + locationParts[2]
16 - );
17 - }
 2+(function($,mw) {
 3+ var newTitle = 'Special:ArticleCreationLanding' + '/' +
 4+ encodeURIComponent(wgPageName);
 5+ var landingURL = mw.config.get('wgArticlePath').replace( '$1', newTitle );
 6+ // change the link to point to the new special page
 7+ $("div.noarticletext")
 8+ .find('a[href*="action=edit"]')
 9+ .attr( 'href', landingURL );
1810 })( jQuery, window.mediaWiki );
Index: trunk/extensions/ArticleCreationWorkflow/ArticleCreationWorkflow.hooks.php
@@ -52,14 +52,10 @@
5353 // $text = ArticleCreationTemplates::showMissingPage( $article );
5454 // $wikiText = false;
5555 // }
56 -
5756 // return false;
 57+ global $wgOut;
5858
59 - global $wgOut, $wgUser, $wgArticleCreationRegistrationCutoff;
60 -
61 - $userRegistration = wfTimestamp( TS_MW, $wgUser->getRegistration() );
62 -
63 - if ( !$userRegistration || $userRegistration > $wgArticleCreationRegistrationCutoff ) {
 59+ if ( ArticleCreationUtil::isEnabled() ) {
6460 $wgOut->addModules( array( 'ext.articleCreation.init' ) );
6561 }
6662

Follow-up revisions

RevisionCommit summaryAuthorDate
r111115Require that the user is in the correct bucket for redlink behaviour, kill de...werdna22:33, 9 February 2012
r111121Roll back to 111060 since the dependancy is no longer neededbsitu23:25, 9 February 2012
r111133Include user ID in bucket cookie namewerdna00:42, 10 February 2012

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r110993bucketing code changes the create link on the 404 page for 1% of usersraindrift00:27, 9 February 2012
r111096Revert r111086 and try something else. Set a cutoff, and only send the init s...werdna21:19, 9 February 2012

Comments

#Comment by Bsitu (talk | contribs)   00:40, 10 February 2012

We probably should add user_id (maybe 0 for anonymous user) to the bucket key since the bucket is saved in cookie, the cookie will be shared by different accounts

#Comment by Werdna (talk | contribs)   00:42, 10 February 2012

Done in r111133.

Status & tagging log