jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/343977 )

Change subject: Be more defensive about checking revision is present
......................................................................


Be more defensive about checking revision is present

This will make race conditions be handled gracefully at
least.

Bug: T160937
Change-Id: Ibc2ed46691781ccdba68545ce838ef6a6bb48aaf
---
M includes/content/CollaborationHubContent.php
1 file changed, 27 insertions(+), 16 deletions(-)

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

Objections:
  Reedy: There's a problem with this change, please improve



diff --git a/includes/content/CollaborationHubContent.php 
b/includes/content/CollaborationHubContent.php
index c17b0f2..d28dcf2 100644
--- a/includes/content/CollaborationHubContent.php
+++ b/includes/content/CollaborationHubContent.php
@@ -431,26 +431,37 @@
                        );
 
                        if ( $membersContent === null ) {
-                               $membersContent = Revision::newFromTitle(
+                               $membersRevision = Revision::newFromTitle(
                                        $membersTitle,
                                        0,
                                        Revision::READ_LATEST
-                               )->getContent();
+                               );
+                               if ( $membersRevision ) {
+                                       $membersContent = 
$membersRevision->getContent();
+                               }
                        }
-                       $activeCol = wfMessage( 
'collaborationkit-column-active' )
-                               ->inContentLanguage()
-                               ->plain();
-                       $wikitext = $membersContent->convertToWikitext(
-                               $lang,
-                               [
-                                       'includeDesc' => false,
-                                       'maxItems' => 3,
-                                       'defaultSort' => 'random',
-                                       'columns' => [ $activeCol ],
-                                       'showColumnHeaders' => false,
-                                       'iconWidth' => 32
-                               ]
-                       );
+                       if ( $membersContent && $membersContent instanceof 
CollaborationListContent ) {
+                               $activeCol = wfMessage( 
'collaborationkit-column-active' )
+                                       ->inContentLanguage()
+                                       ->plain();
+                               $wikitext = $membersContent->convertToWikitext(
+                                       $lang,
+                                       [
+                                               'includeDesc' => false,
+                                               'maxItems' => 3,
+                                               'defaultSort' => 'random',
+                                               'columns' => [ $activeCol ],
+                                               'showColumnHeaders' => false,
+                                               'iconWidth' => 32
+                                       ]
+                               );
+                       } else {
+                               // Some sort of error occured. Probably
+                               // a race condition.
+                               // No i18n for this error message, since
+                               // it should never happen.
+                               $wikitext = '<span class="error">Cannot include 
member list</span>';
+                       }
 
                        $html .= $wgParser
                                ->parse( $wikitext, $membersTitle, $options )

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ibc2ed46691781ccdba68545ce838ef6a6bb48aaf
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/CollaborationKit
Gerrit-Branch: master
Gerrit-Owner: Brian Wolff <bawolff...@gmail.com>
Gerrit-Reviewer: Harej <jamesmh...@gmail.com>
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