r88633: lazy-load 'customFilters' field in SpecialRecentChanges. Almost every functio...
authorAaron Schulz <aaron@users.mediawiki.org>
Fri, 13 Jan 2012 09:14:56 +0000 (09:14 +0000)
committerAaron Schulz <aaron@users.mediawiki.org>
Fri, 13 Jan 2012 09:14:56 +0000 (09:14 +0000)
includes/specials/SpecialRecentchanges.php

index 51baef9..067a956 100644 (file)
@@ -73,9 +73,7 @@ class SpecialRecentChanges extends IncludableSpecialPage {
        public function setup( $parameters ) {
                $opts = $this->getDefaultOptions();
 
-               $this->customFilters = array();
-               wfRunHooks( 'SpecialRecentChangesFilters', array( $this, &$this->customFilters ) );
-               foreach( $this->customFilters as $key => $params ) {
+               foreach( $this->getCustomFilters() as $key => $params ) {
                        $opts->add( $key, $params['default'] );
                }
 
@@ -90,6 +88,19 @@ class SpecialRecentChanges extends IncludableSpecialPage {
                return $opts;
        }
 
+       /**
+        * Get custom show/hide filters
+        *
+        * @return Array Map of filter URL param names to properties (msg/default)
+        */
+       protected function getCustomFilters() {
+               if ( $this->customFilters === null ) {
+                       $this->customFilters = array();
+                       wfRunHooks( 'SpecialRecentChangesFilters', array( $this, &$this->customFilters ) );
+               }
+               return $this->customFilters;
+       }
+
        /**
         * Create a FormOptions object specific for feed requests and return it
         *
@@ -806,14 +817,14 @@ class SpecialRecentChanges extends IncludableSpecialPage {
                // show/hide links
                $showhide = array( wfMsg( 'show' ), wfMsg( 'hide' ) );
                $filters = array(
-                       'hideminor' => 'rcshowhideminor',
-                       'hidebots'  => 'rcshowhidebots',
-                       'hideanons' => 'rcshowhideanons',
-                       'hideliu'   => 'rcshowhideliu',
+                       'hideminor'     => 'rcshowhideminor',
+                       'hidebots'      => 'rcshowhidebots',
+                       'hideanons'     => 'rcshowhideanons',
+                       'hideliu'       => 'rcshowhideliu',
                        'hidepatrolled' => 'rcshowhidepatr',
-                       'hidemyself' => 'rcshowhidemine'
+                       'hidemyself'    => 'rcshowhidemine'
                );
-               foreach ( $this->customFilters as $key => $params ) {
+               foreach ( $this->getCustomFilters() as $key => $params ) {
                        $filters[$key] = $params['msg'];
                }
                // Disable some if needed