From 508f7a05646c14a56daf443d5d4a9eae493e6250 Mon Sep 17 00:00:00 2001 From: Thiemo Kreuz Date: Mon, 18 Nov 2019 13:36:25 +0100 Subject: [PATCH] Remove dead code from Cite::referencesFormatEntry() Note how this code was broken since 2018 (Iff480bc). In this execution path, $val is a string. There is no $val['dir']. Luckily, this was dead code since 2008 already. See https://phabricator.wikimedia.org/rECIT448a99da5108c26ce88d3df7cf5df2b5b5b1d1d3 line 283 on the right. Bug: T237241 Change-Id: I671f3379a124a2644a9b0eac38d46c59106980a7 --- includes/Cite.php | 37 ++++++++++++++----------------------- 1 file changed, 14 insertions(+), 23 deletions(-) diff --git a/includes/Cite.php b/includes/Cite.php index d7b2d3ea0..5c90c44ec 100644 --- a/includes/Cite.php +++ b/includes/Cite.php @@ -71,8 +71,14 @@ class Cite { * // all occourances of it to * // use the same number * ], - * 0 => 'Anonymous reference', - * 1 => 'Another anonymous reference', + * 0 => [ + * 'text' => 'Anonymous reference', + * 'count' => -1, + * ], + * 1 => [ + * 'text' => 'Another anonymous reference', + * 'count' => -1, + * ], * 'some key' => [ * 'text' => 'this one occurs once' * 'count' => 0, @@ -89,7 +95,7 @@ class Cite { * * User supplied keys can't be integers, therefore avoiding * conflict with anonymous keys * - * @var array[] + * @var array[][] */ private $mRefs = []; @@ -464,7 +470,7 @@ class Cite { $this->mGroupCnt[$group] = 0; } if ( $follow != null ) { - if ( isset( $this->mRefs[$group][$follow] ) && is_array( $this->mRefs[$group][$follow] ) ) { + if ( isset( $this->mRefs[$group][$follow] ) ) { // add text to the note that is being followed $this->mRefs[$group][$follow]['text'] .= ' ' . $text; } else { @@ -505,7 +511,7 @@ class Cite { } // Valid key with first occurrence - if ( !isset( $this->mRefs[$group][$key] ) || !is_array( $this->mRefs[$group][$key] ) ) { + if ( !isset( $this->mRefs[$group][$key] ) ) { $this->mRefs[$group][$key] = [ 'text' => $text, 'count' => 0, @@ -784,25 +790,10 @@ class Cite { * Format a single entry for the referencesFormat() function * * @param string $key The key of the reference - * @param mixed $val The value of the reference, string for anonymous - * references, array for user-suppplied - * @return string Wikitext + * @param array $val A single reference as documented at {@see $mRefs} + * @return string Wikitext, wrapped in a single
  • element */ - private function referencesFormatEntry( $key, $val ) { - // Anonymous reference - if ( !is_array( $val ) ) { - return wfMessage( - 'cite_references_link_one', - $this->normalizeKey( - self::getReferencesKey( $key ) - ), - $this->normalizeKey( - $this->refKey( $key ) - ), - $this->referenceText( $key, $val ), - $val['dir'] - )->inContentLanguage()->plain(); - } + private function referencesFormatEntry( $key, array $val ) { $text = $this->referenceText( $key, $val['text'] ); if ( isset( $val['follow'] ) ) { return wfMessage(