Factorise call to getSuggestedDurations() in SpecialBlock::getFormFields()
authorAlexandre Emsenhuber <ialex.wiki@gmail.com>
Mon, 29 Apr 2013 13:48:57 +0000 (15:48 +0200)
committerAlexandre Emsenhuber <ialex.wiki@gmail.com>
Mon, 29 Apr 2013 13:48:57 +0000 (15:48 +0200)
So that it is not needed to parse the message two times per request.

Change-Id: I07f48dc35f4904d043844c2a3370bc27cdd5fb45

includes/specials/SpecialBlock.php

index 645de23..5a2ad62 100644 (file)
@@ -127,6 +127,8 @@ class SpecialBlock extends FormSpecialPage {
 
                $user = $this->getUser();
 
+               $suggestedDurations = self::getSuggestedDurations();
+
                $a = array(
                        'Target' => array(
                                'type' => 'text',
@@ -139,11 +141,11 @@ class SpecialBlock extends FormSpecialPage {
                                'validation-callback' => array( __CLASS__, 'validateTargetField' ),
                        ),
                        'Expiry' => array(
-                               'type' => !count( self::getSuggestedDurations() ) ? 'text' : 'selectorother',
+                               'type' => !count( $suggestedDurations ) ? 'text' : 'selectorother',
                                'label-message' => 'ipbexpiry',
                                'required' => true,
                                'tabindex' => '2',
-                               'options' => self::getSuggestedDurations(),
+                               'options' => $suggestedDurations,
                                'other' => $this->msg( 'ipbother' )->text(),
                                'default' => $this->msg( 'ipb-default-expiry' )->inContentLanguage()->text(),
                        ),