[MediaWiki-commits] [Gerrit] mediawiki...ApprovedRevs[master]: Error when displaying a blank page

2018-01-15 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/404167 )

Change subject: Error when displaying a blank page
..


Error when displaying a blank page

When the content is set to blank for unapproved revisions, an error
was displayed instead since MediaWiki 1.31-alpha.

Bug: T184877
Change-Id: Idb16ca46f3a1ee7dd32c3925d9a985d0ba8193a3
---
M ApprovedRevs.hooks.php
1 file changed, 12 insertions(+), 9 deletions(-)

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



diff --git a/ApprovedRevs.hooks.php b/ApprovedRevs.hooks.php
index 6d35378..d0f5c50 100644
--- a/ApprovedRevs.hooks.php
+++ b/ApprovedRevs.hooks.php
@@ -203,7 +203,14 @@
return true;
}
 
-   public static function showBlankIfUnapproved( &$article, &$content ) {
+   /**
+* Hook: ArticleAfterFetchContentObject
+*
+* @param Article $article
+* @param Content $content
+* @return true
+*/
+   public static function showBlankIfUnapproved( &$article, Content 
&$content ) {
global $egApprovedRevsBlankIfUnapproved;
if ( ! $egApprovedRevsBlankIfUnapproved ) {
return true;
@@ -236,13 +243,9 @@
ApprovedRevs::addCSS();
 
// Set the content to blank.
-   // There's possibly a bug in MW 1.28, where the second argument
-   // (called from the hook 'ArticleAfterFetchContentObject') is
-   // sometimes (or always?) a string, instead of a Content object.
-   // We'll just get around it here with a check. (In theory, 
$content
-   // could also be null, so this check is a good idea anyway.)
-   if ( is_object( $content ) ) {
-   $content->mText = '';
+   if( $content instanceof TextContent ) {
+   $contentClass = get_class( $content );
+   $content = new $contentClass( '' );
} else {
$content = '';
}
@@ -950,4 +953,4 @@
$qp['SpecialApprovedRevsPage'] = 'ApprovedRevs';
return true;
}
-}
\ No newline at end of file
+}

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Idb16ca46f3a1ee7dd32c3925d9a985d0ba8193a3
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/extensions/ApprovedRevs
Gerrit-Branch: master
Gerrit-Owner: Seb35 
Gerrit-Reviewer: Seb35 
Gerrit-Reviewer: Yaron Koren 
Gerrit-Reviewer: jenkins-bot <>

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


[MediaWiki-commits] [Gerrit] mediawiki...ApprovedRevs[master]: Error when displaying a blank page

2018-01-14 Thread Seb35 (Code Review)
Seb35 has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/404167 )

Change subject: Error when displaying a blank page
..

Error when displaying a blank page

When the content is set to blank for unapproved revisions, an error
was displayed instead since MediaWiki 1.31-alpha.

Bug: T18487
Change-Id: Idb16ca46f3a1ee7dd32c3925d9a985d0ba8193a3
---
M ApprovedRevs.hooks.php
1 file changed, 3 insertions(+), 12 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ApprovedRevs 
refs/changes/67/404167/1

diff --git a/ApprovedRevs.hooks.php b/ApprovedRevs.hooks.php
index 6d35378..4f6097f 100644
--- a/ApprovedRevs.hooks.php
+++ b/ApprovedRevs.hooks.php
@@ -203,7 +203,7 @@
return true;
}
 
-   public static function showBlankIfUnapproved( &$article, &$content ) {
+   public static function showBlankIfUnapproved( &$article, Content 
&$content ) {
global $egApprovedRevsBlankIfUnapproved;
if ( ! $egApprovedRevsBlankIfUnapproved ) {
return true;
@@ -236,16 +236,7 @@
ApprovedRevs::addCSS();
 
// Set the content to blank.
-   // There's possibly a bug in MW 1.28, where the second argument
-   // (called from the hook 'ArticleAfterFetchContentObject') is
-   // sometimes (or always?) a string, instead of a Content object.
-   // We'll just get around it here with a check. (In theory, 
$content
-   // could also be null, so this check is a good idea anyway.)
-   if ( is_object( $content ) ) {
-   $content->mText = '';
-   } else {
-   $content = '';
-   }
+   $content = new WikitextContent( '' );
 
return true;
}
@@ -950,4 +941,4 @@
$qp['SpecialApprovedRevsPage'] = 'ApprovedRevs';
return true;
}
-}
\ No newline at end of file
+}

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Idb16ca46f3a1ee7dd32c3925d9a985d0ba8193a3
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ApprovedRevs
Gerrit-Branch: master
Gerrit-Owner: Seb35 

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