From 914c2ea5bf3aaf02586d739f67d4c7e4f8a3fdc0 Mon Sep 17 00:00:00 2001
From: Darian Anthony Patrick <dpatrick@wikimedia.org>
Date: Tue, 13 Oct 2015 13:47:58 -0700
Subject: [PATCH] Specify visibility when selecting authors

Related to the bug listed below, add a parameter which may be passed
specifying the visibility from the Revision:: namespace, to allow
revision deletion to be respected.

Bug: T71367
Change-Id: Ib977a9588915b610c55163ef6bb27b4b7d5322c5
---
 includes/Title.php | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/includes/Title.php b/includes/Title.php
index 8e5fae9..5669f4d 100644
--- a/includes/Title.php
+++ b/includes/Title.php
@@ -4133,6 +4133,7 @@ class Title {
 	 *     'include_old' Include $old in the range; $new is excluded.
 	 *     'include_new' Include $new in the range; $old is excluded.
 	 *     'include_both' Include both $old and $new in the range.
+	 *     'visibility' One of Revision::FOR_PUBLIC, Revision::FOR_THIS_USER, or Revision::RAW
 	 *     Unknown option values are ignored.
 	 * @return array|null Names of revision authors in the range; null if not both revisions exist
 	 */
@@ -4153,6 +4154,7 @@ class Title {
 		$old_cmp = '>';
 		$new_cmp = '<';
 		$options = (array)$options;
+		$visibility = Revision::RAW;
 		if ( in_array( 'include_old', $options ) ) {
 			$old_cmp = '>=';
 		}
@@ -4163,21 +4165,24 @@ class Title {
 			$old_cmp = '>=';
 			$new_cmp = '<=';
 		}
+		if ( in_array( 'visibility', $options ) ) {
+			$visibility = $options['visibility'];
+		}
 		// No DB query needed if $old and $new are the same or successive revisions:
 		if ( $old->getId() === $new->getId() ) {
 			return ( $old_cmp === '>' && $new_cmp === '<' ) ?
 				array() :
-				array( $old->getUserText( Revision::RAW ) );
+				array( $old->getUserText( $visibility ) );
 		} elseif ( $old->getId() === $new->getParentId() ) {
 			if ( $old_cmp === '>=' && $new_cmp === '<=' ) {
-				$authors[] = $old->getUserText( Revision::RAW );
-				if ( $old->getUserText( Revision::RAW ) != $new->getUserText( Revision::RAW ) ) {
-					$authors[] = $new->getUserText( Revision::RAW );
+				$authors[] = $old->getUserText( $visibility );
+				if ( $old->getUserText( $visibility ) != $new->getUserText( $visibility ) ) {
+					$authors[] = $new->getUserText( $visibility );
 				}
 			} elseif ( $old_cmp === '>=' ) {
-				$authors[] = $old->getUserText( Revision::RAW );
+				$authors[] = $old->getUserText( $visibility );
 			} elseif ( $new_cmp === '<=' ) {
-				$authors[] = $new->getUserText( Revision::RAW );
+				$authors[] = $new->getUserText( $visibility );
 			}
 			return $authors;
 		}
-- 
2.3.8 (Apple Git-58)

