Use descriptive key for array of in a Special:EditWatchlist line
authorMatthias Mullie <git@mullie.eu>
Wed, 27 Aug 2014 10:44:49 +0000 (12:44 +0200)
committerMatthias Mullie <git@mullie.eu>
Wed, 27 Aug 2014 10:46:44 +0000 (12:46 +0200)
WatchlistEditorBuildRemoveLine allows subscribers to modify $tools array.
However, it's hard to know exactly which link is which: $tools is just an array
of HTML links.
By adding a descriptive key, it'd be easier to unset or modify a specific link.

AFAICT, there currently are no subscribers to this hook in WMF extensions (Flow
will be coming up with one soon), so this change should be safe.

Change-Id: Id3f69db1aab7d3e3761318d7f8588ae63a0bc6a6

includes/specials/SpecialEditWatchlist.php

index 73438d9..aba5665 100644 (file)
@@ -620,10 +620,10 @@ class SpecialEditWatchlist extends UnlistedSpecialPage {
        private function buildRemoveLine( $title ) {
                $link = Linker::link( $title );
 
-               $tools[] = Linker::link( $title->getTalkPage(), $this->msg( 'talkpagelinktext' )->escaped() );
+               $tools['talk'] = Linker::link( $title->getTalkPage(), $this->msg( 'talkpagelinktext' )->escaped() );
 
                if ( $title->exists() ) {
-                       $tools[] = Linker::linkKnown(
+                       $tools['history'] = Linker::linkKnown(
                                $title,
                                $this->msg( 'history_short' )->escaped(),
                                array(),
@@ -632,7 +632,7 @@ class SpecialEditWatchlist extends UnlistedSpecialPage {
                }
 
                if ( $title->getNamespace() == NS_USER && !$title->isSubpage() ) {
-                       $tools[] = Linker::linkKnown(
+                       $tools['contributions'] = Linker::linkKnown(
                                SpecialPage::getTitleFor( 'Contributions', $title->getText() ),
                                $this->msg( 'contributions' )->escaped()
                        );