jenkins-bot has submitted this change and it was merged.

Change subject: Only update assessment data when talk pages are saved
......................................................................


Only update assessment data when talk pages are saved

Cherry pick of Iacd4c46429fd minus the parent (which has a core
dependency not in 1.28.0-wmf.22). Iacd4c46429fd is not dependent
on the parent change.

Bug: T147906
Change-Id: I095fa7b3264c9c4390ac24106e7153179825114e
---
M PageAssessments.hooks.php
1 file changed, 17 insertions(+), 13 deletions(-)

Approvals:
  Reedy: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/PageAssessments.hooks.php b/PageAssessments.hooks.php
index 644fe1c..b3a8d2a 100644
--- a/PageAssessments.hooks.php
+++ b/PageAssessments.hooks.php
@@ -31,23 +31,27 @@
        }
 
        /**
-        * Insert assessment records after page is saved
+        * Update assessment records after talk page is saved
         * @param LinksUpdate $linksUpdate
         */
        public static function onLinksUpdateComplete( &$linksUpdate ) {
-               $pOut = $linksUpdate->getParserOutput();
-               if ( $pOut->getExtensionData( 
'ext-pageassessment-assessmentdata' ) !== null ) {
-                       $assessmentData = $pOut->getExtensionData( 
'ext-pageassessment-assessmentdata' );
-               } else {
-                       // Even if there is no assessment data, we still need 
to run doUpdates
-                       // in case any assessment data was deleted from the 
page.
-                       $assessmentData = [];
-               }
                $title = $linksUpdate->getTitle();
-               // In most cases $title will be a talk page, but we want to 
associate the
-               // assessment data with the subject page.
-               $subjectTitle = $title->getSubjectPage();
-               PageAssessmentsBody::doUpdates( $subjectTitle, $assessmentData 
);
+               // This assumes that the assessment parser function is only 
used on talk pages.
+               // See T147906 for why assessments are not supported in either 
namespace.
+               if ( $title->getNamespace() === NS_TALK ) {
+                       $pOut = $linksUpdate->getParserOutput();
+                       if ( $pOut->getExtensionData( 
'ext-pageassessment-assessmentdata' ) !== null ) {
+                               $assessmentData = $pOut->getExtensionData( 
'ext-pageassessment-assessmentdata' );
+                       } else {
+                               // Even if there is no assessment data, we 
still need to run doUpdates
+                               // 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 );
+               }
        }
 
        /**

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I095fa7b3264c9c4390ac24106e7153179825114e
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/PageAssessments
Gerrit-Branch: wmf/1.28.0-wmf.22
Gerrit-Owner: Kaldari <rkald...@wikimedia.org>
Gerrit-Reviewer: Reedy <re...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to