From 9ed7f5bcaa0b9b264ef005baf55b3511a4327c69 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rapha=C3=ABl=20Barrois?= Date: Thu, 4 Feb 2010 19:02:09 +0100 Subject: [PATCH] Don't fetch data until needed MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Raphaël Barrois --- include/directory.enums.inc.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/include/directory.enums.inc.php b/include/directory.enums.inc.php index ad7d694..538c8d2 100644 --- a/include/directory.enums.inc.php +++ b/include/directory.enums.inc.php @@ -114,7 +114,7 @@ abstract class DirEnumeration /** An internal array of ID => optionTxt */ - protected $options; + protected $options = null; /** Description of the MySQL storage of the fields */ @@ -134,12 +134,16 @@ abstract class DirEnumeration protected $ac_distinct = true; // Whether we want to keep only distinct valfield value protected $ac_withid = true; // Do we want to fetch id too ? - public function __construct() { - $this->loadOptions(); + protected function _fetchOptions() + { + if (is_null($this->options)) { + $this->loadOptions(); + } } public function getOptions() { + $this->_fetchOptions(); return $this->options; } @@ -310,6 +314,7 @@ class DE_Degrees extends DirEnumeration public function getOptions($eduid = null) { + $this->_fetchOptions(); if ($eduid == null) { return PlIteratorUtils::fromArray($this->options, 1, true); } @@ -397,6 +402,8 @@ class DE_AdminAreas extends DirEnumeration public function getOptions($country = null) { + $this->_fetchOptions(); + if ($country == null) { return PlIteratorUtils::fromArray($this->options, 1, true); } -- 2.1.4