Thiemo Mättig (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/398231 )

Change subject: Remove unused access to (Special)CheckUser object
......................................................................

Remove unused access to (Special)CheckUser object

This is an alternative for the workaround presented in Id2634a5. I
followed all code paths and could not find any usage of the
CheckUserRow::checkUser property I'm removing in this patch. Nor could
I find any usage of the CheckUserRow class.

The more general question is: Why does a FormatterRow need access to
the entirety of this specific special page?

Id2634a5 might still be valueable as it is easier to backport.

Bug: T182834
Change-Id: Ibe814999870ba621232049c3ec209d953754d80f
---
M Hooks.php
M includes/Formatter/CheckUserQuery.php
2 files changed, 6 insertions(+), 16 deletions(-)


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

diff --git a/Hooks.php b/Hooks.php
index 0034c0b..218ea98 100644
--- a/Hooks.php
+++ b/Hooks.php
@@ -556,7 +556,7 @@
                }
        }
 
-       public static function onSpecialCheckUserGetLinksFromRow( CheckUser 
$checkUser, $row, &$links ) {
+       public static function onSpecialCheckUserGetLinksFromRow( SpecialPage 
$specialCheckUser, $row, &$links ) {
                if ( !$row->cuc_type == RC_FLOW ) {
                        return true;
                }
@@ -568,11 +568,11 @@
                        $query = Container::get( 'query.checkuser' );
                        // @todo: create hook to allow batch-loading this data, 
instead of doing piecemeal like this
                        $query->loadMetadataBatch( [ $row ] );
-                       $row = $query->getResult( $checkUser, $row );
+                       $row = $query->getResult( $row );
                        if ( $row !== false ) {
                                /** @var Flow\Formatter\CheckUserFormatter 
$formatter */
                                $formatter = Container::get( 
'formatter.checkuser' );
-                               $replacement = $formatter->format( $row, 
$checkUser->getContext() );
+                               $replacement = $formatter->format( $row, 
$specialCheckUser->getContext() );
                        }
                } catch ( Exception $e ) {
                        wfDebugLog( 'Flow', __METHOD__ . ': Exception 
formatting cu ' . json_encode( $row ) . ' ' . $e );
diff --git a/includes/Formatter/CheckUserQuery.php 
b/includes/Formatter/CheckUserQuery.php
index bc5023e..55e365e 100644
--- a/includes/Formatter/CheckUserQuery.php
+++ b/includes/Formatter/CheckUserQuery.php
@@ -4,7 +4,6 @@
 
 use Flow\Exception\FlowException;
 use Flow\Model\UUID;
-use CheckUser;
 
 class CheckUserQuery extends AbstractQuery {
        /**
@@ -66,12 +65,11 @@
        }
 
        /**
-        * @param CheckUser $checkUser
         * @param \StdClass $row
-        * @return CheckUserRow|null
+        * @return FormatterRow|bool
         * @throws FlowException
         */
-       public function getResult( CheckUser $checkUser, $row ) {
+       public function getResult( $row ) {
                if ( $row->cuc_type != RC_FLOW || !$row->cuc_comment ) {
                        return false;
                }
@@ -88,9 +86,8 @@
                }
                $revision = $this->revisionCache[$alpha];
 
-               $res = new CheckUserRow;
+               $res = new FormatterRow();
                $this->buildResult( $revision, 'cuc_timestamp', $res );
-               $res->checkUser = $checkUser;
 
                return $res;
        }
@@ -133,11 +130,4 @@
 
                return [ $workflowId, $revisionId, $postId ];
        }
-}
-
-class CheckUserRow extends FormatterRow {
-       /**
-        * @var CheckUser
-        */
-       public $checkUser;
 }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ibe814999870ba621232049c3ec209d953754d80f
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: Thiemo Mättig (WMDE) <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to