Mattflaschen has uploaded a new change for review. https://gerrit.wikimedia.org/r/63984
Change subject: Exclude current article when you choose "Try another" ...................................................................... Exclude current article when you choose "Try another" * Bump maximum number of attempts to 20. Change-Id: Iaafce0c8ea50cb649dd9963bc906daa31f2f3ed6 --- M SpecialGettingStarted.php M resources/ext.gettingstarted.taskToolbar.js 2 files changed, 15 insertions(+), 6 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/GettingStarted refs/changes/84/63984/1 diff --git a/SpecialGettingStarted.php b/SpecialGettingStarted.php index e4597aa..b7db8c5 100644 --- a/SpecialGettingStarted.php +++ b/SpecialGettingStarted.php @@ -3,8 +3,8 @@ const MAX_ARTICLE_LENGTH = 10000; - // Completely arbitrary, based on * 4 in old version of code - const MAX_ATTEMPTS = 4; + // Arbitrary + const MAX_ATTEMPTS = 20; const NO_ARTICLE_SCHEMA_NAME = 'GettingStartedNavbarNoArticle'; const NO_ARTICLE_SCHEMA_REV_ID = 5483117; @@ -19,11 +19,16 @@ * * @param Title $title title of article * @param User $user user to check + * @param string|null $excludedPageName page name to be excluded, in in getPrefixedDBkey() format, + * or null for no exclusion */ - protected function isAllowedArticle( Title $title, User $user ) { + protected function isAllowedArticle( Title $title, User $user, $excludedPageName ) { $length = $title->getLength(); + $passesExclude = $excludedPageName === null || + $title->getPrefixedDBkey() !== $excludedPageName; return $length > 0 && $length <= self::MAX_ARTICLE_LENGTH + && $passesExclude && $title->userCan( 'edit', $user ) && !$this->inExcludedCategories( $title ); } @@ -32,7 +37,6 @@ * Check if the task is valid. If so, send them to a random article for the task. * * @param string $taskName task name - * @param string $source source, or null * @return bool whether they were redirected */ public function sendToTask( $taskName ) { @@ -41,6 +45,8 @@ $fullTaskName = "gettingstarted-$taskName"; $user = $this->getUser(); + $excludedPageName = $this->getRequest()->getVal( 'exclude' ); + if ( isset( $wgGettingStartedTasks[$taskName] ) ) { $task = $wgGettingStartedTasks[$taskName]; $roulette = new CategoryRoulette( Category::newFromName( $task['category'] ) ); @@ -48,7 +54,7 @@ do { $titles = $roulette->getRandomArticles( 1 ); $attempts++; - if ( count( $titles ) === 1 && $this->isAllowedArticle( $titles[0], $user ) ) { + if ( count( $titles ) === 1 && $this->isAllowedArticle( $titles[0], $user, $excludedPageName ) ) { $title = $titles[0]; $out = $this->getOutput(); $request = $out->getRequest(); diff --git a/resources/ext.gettingstarted.taskToolbar.js b/resources/ext.gettingstarted.taskToolbar.js index 4d57f1a..78742f6 100644 --- a/resources/ext.gettingstarted.taskToolbar.js +++ b/resources/ext.gettingstarted.taskToolbar.js @@ -57,7 +57,10 @@ tryAnotherUri = new mw.Uri( mw.util.wikiGetlink( 'Special:GettingStarted/task/' + toolbarInfo.taskName ) - ).extend( {source: 'navbar-next'} ); + ).extend( { + exclude: cfg.wgPageName, + source: 'navbar-next' + } ); $tryAnother = $( '<a>' ).attr( { href: tryAnotherUri.toString(), -- To view, visit https://gerrit.wikimedia.org/r/63984 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Iaafce0c8ea50cb649dd9963bc906daa31f2f3ed6 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/GettingStarted Gerrit-Branch: master Gerrit-Owner: Mattflaschen <mflasc...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits