Kaldari has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/315895

Change subject: Make the assessment namespace configurable
......................................................................

Make the assessment namespace configurable

This is a better fix for bug T147906, as it will allow us to support
wikis where assessments are recorded on talk pages (like English
Wikipedia) as well as wikis where assessments are recorded on
subject pages (like English Wikivoyage).

Bug: T147906
Change-Id: Ifcbe347f1259a0a26456c0eaa52541d6e2c83386
---
M PageAssessments.hooks.php
M extension.json
2 files changed, 14 insertions(+), 7 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/PageAssessments 
refs/changes/95/315895/1

diff --git a/PageAssessments.hooks.php b/PageAssessments.hooks.php
index 8129e1a..5c86259 100644
--- a/PageAssessments.hooks.php
+++ b/PageAssessments.hooks.php
@@ -36,10 +36,12 @@
         * @param mixed $ticket
         */
        public static function onLinksUpdateComplete( &$linksUpdate, $ticket = 
null ) {
+               $assessmentsOnTalkPages = 
RequestContext::getMain()->getConfig()->get( 'PageAssessmentsOnTalkPages' );
                $title = $linksUpdate->getTitle();
-               // This assumes that the assessment parser function is only 
used on talk pages.
-               // See T147906 for why assessments are not supported on subject 
pages.
-               if ( $title->isTalkPage() ) {
+               // Only check for assessment data where assessments are 
actually made.
+               if ( ( $assessmentsOnTalkPages && $title->isTalkPage() ) ||
+                       ( !$assessmentsOnTalkPages && !$title->isTalkPage() )
+               ) {
                        $pOut = $linksUpdate->getParserOutput();
                        if ( $pOut->getExtensionData( 
'ext-pageassessment-assessmentdata' ) !== null ) {
                                $assessmentData = $pOut->getExtensionData( 
'ext-pageassessment-assessmentdata' );
@@ -48,10 +50,12 @@
                                // in case any assessment data was deleted from 
the page.
                                $assessmentData = [];
                        }
-                       // The title is a talk page, but we want to associate 
the assessment data
-                       // with the subject page.
-                       $subjectTitle = $title->getSubjectPage();
-                       PageAssessmentsBody::doUpdates( $subjectTitle, 
$assessmentData, $ticket );
+                       // Assessment data should only be associated with 
subject pages regardless
+                       // of whether it is recorded on talk pages or subject 
pages.
+                       if ( $title->isTalkPage() ) {
+                               $title = $title->getSubjectPage();
+                       }
+                       PageAssessmentsBody::doUpdates( $title, 
$assessmentData, $ticket );
                }
        }
 
diff --git a/extension.json b/extension.json
index d634614..49a9529 100644
--- a/extension.json
+++ b/extension.json
@@ -47,5 +47,8 @@
                "localBasePath": "",
                "remoteExtPath": "examples/PageAssessments"
        },
+       "config": {
+               "PageAssessmentsOnTalkPages": true
+       },
        "manifest_version": 1
 }

-- 
To view, visit https://gerrit.wikimedia.org/r/315895
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ifcbe347f1259a0a26456c0eaa52541d6e2c83386
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/PageAssessments
Gerrit-Branch: master
Gerrit-Owner: Kaldari <rkald...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to