EBernhardson (WMF) has uploaded a new change for review.

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


Change subject: Better error handling for memc and some comments
......................................................................

Better error handling for memc and some comments

Change-Id: Ibdd49677c7eac6b8d601ea1d317c0a4d61e42943
---
M includes/Data/ObjectManager.php
M includes/Model/AbstractRevision.php
M includes/Repository/MultiGetList.php
M includes/Repository/TreeRepository.php
4 files changed, 34 insertions(+), 8 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Flow 
refs/changes/30/83030/1

diff --git a/includes/Data/ObjectManager.php b/includes/Data/ObjectManager.php
index 04cd787..14c3e75 100644
--- a/includes/Data/ObjectManager.php
+++ b/includes/Data/ObjectManager.php
@@ -653,7 +653,7 @@
                foreach ( $res as $row ) {
                        $result[] = (array) $row;
                }
-               wfDebugLog( __CLASS__, __METHOD__ . ': ' . print_r( $result, 
true ) );
+               // wfDebugLog( __CLASS__, __METHOD__ . ': ' . print_r( $result, 
true ) );
                return $result;
        }
 
@@ -1292,6 +1292,11 @@
                }
                if ( $keys ) {
                        $flipped = array_flip( $keys );
+                       $res = parent::getMulti( $keys );
+                       if ( $res === false ) {
+                               wfDebugLog( __CLASS__, __FUNCTION__ . ': 
Failure requesting data from memcache : ' . implode( ',', $keys ) );
+                               return $found;
+                       }
                        foreach ( parent::getMulti( $keys ) as $key => $value ) 
{
                                $this->internal[$key] = $found[$key] = $value;
                                unset( $keys[$flipped[$key]] );
diff --git a/includes/Model/AbstractRevision.php 
b/includes/Model/AbstractRevision.php
index e11b677..9d24a77 100644
--- a/includes/Model/AbstractRevision.php
+++ b/includes/Model/AbstractRevision.php
@@ -12,11 +12,18 @@
 
        const MODERATED_CENSORED = 'censor';
 
+       /**
+        * Possible moderation states of a revision.  These must be ordered from
+        * least restrictive to most restrictive permission.
+        */
        static private $perms = array(
                self::MODERATED_NONE => array(
+                       // The name of the permission checked with 
User::isAllowed
                        'perm' => null,
-                       'usertext' => null,
-                       'content' => null
+                       // This is the bit of text rendered instead of the 
content
+                       'content' => null,
+                       // This is the revision comment stored when changing to 
this moderation state
+                       'comment' => 'flow-comment-restored',
                ),
                self::MODERATED_HIDDEN => array(
                        'perm' => 'flow-hide',
@@ -197,10 +204,11 @@
        }
 
        public function getUserText( $user = null ) {
-               if ( $this->isAllowed( $user ) ) {
-                       return $this->getUserTextRaw();
+               // The text of *this* revision is only stripped when fully 
moderated
+               if ( $this->isCensored() ) {
+                       return wfMessage( 'flow-comment-censored' );
                } else {
-                       return wfMessage( 
self::$perms[$this->moderationState]['usertext'] );
+                       return $this->getUserTextRaw();
                }
        }
 
diff --git a/includes/Repository/MultiGetList.php 
b/includes/Repository/MultiGetList.php
index 61b860c..6b3a563 100644
--- a/includes/Repository/MultiGetList.php
+++ b/includes/Repository/MultiGetList.php
@@ -32,7 +32,13 @@
                        return array();
                }
                $result = array();
-               foreach ( $this->cache->getMulti( array_keys( $cacheKeys ) ) as 
$key => $value ) {
+               $multiRes = $this->cache->getMulti( array_keys( $cacheKeys ) );
+               if ( $multiRes === false ) {
+                       wfDebugLog( __CLASS__, __FUNCTION__ . ': Failure 
querying memcache' );
+                       return false;
+               }
+
+               foreach ( $multiRes as $key => $value ) {
                        if ( $cacheKeys[$key] instanceof UUID ) {
                                $idx = $cacheKeys[$key]->getBinary();
                        } else {
diff --git a/includes/Repository/TreeRepository.php 
b/includes/Repository/TreeRepository.php
index 105233f..2d6e98a 100644
--- a/includes/Repository/TreeRepository.php
+++ b/includes/Repository/TreeRepository.php
@@ -215,7 +215,10 @@
                        $roots,
                        array( $this, 'fetchSubtreeNodeListFromDb' )
                );
-
+               if ( $res === false ) {
+                       wfDebugLog( __CLASS__, __FUNCTION__ . ': Failure 
fetching node list from cache' );
+                       return false;
+               }
                // $idx is a binary UUID
                $retval = array();
                foreach ( $res as $idx => $val ) {
@@ -233,6 +236,10 @@
                        ),
                        __METHOD__
                );
+               if ( $res === false ) {
+                       wfDebugLog( __CLASS__, __FUNCTION__ . ': Failure 
fetching node list from database' );
+                       return false;
+               }
                if ( !$res ) {
                        return array();
                }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ibdd49677c7eac6b8d601ea1d317c0a4d61e42943
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: EBernhardson (WMF) <ebernhard...@wikimedia.org>

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

Reply via email to