From 37679cfdcd235254348eba509ba4e787ba8d6468 Mon Sep 17 00:00:00 2001 From: Olav Morken <olav.morken@uninett.no> Date: Wed, 3 Apr 2013 06:25:51 +0000 Subject: [PATCH] memcache: Check for existence of memcache extension. The old test was faulty, since PHP would fail before reaching it. This patch adds a specific test for the Memcache class before continuing. Thanks to Thijs Kinkhorst for reporting this bug! git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@3230 44740490-163a-0410-bde0-09ae8108e29a --- lib/SimpleSAML/Memcache.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/SimpleSAML/Memcache.php b/lib/SimpleSAML/Memcache.php index e83835ed4..11cf3b587 100644 --- a/lib/SimpleSAML/Memcache.php +++ b/lib/SimpleSAML/Memcache.php @@ -249,12 +249,13 @@ class SimpleSAML_Memcache { * @return A Memcache object of the servers in the group. */ private static function loadMemcacheServerGroup(array $group) { + + if(!class_exists('Memcache')) { + throw new Exception('Missing Memcache class. Is the memcache extension installed?'); + } + /* Create the Memcache object. */ $memcache = new Memcache(); - if($memcache == NULL) { - throw new Exception('Unable to create an instance of a Memcache object.' . - ' Is the memcache extension installed?'); - } /* Iterate over all the servers in the group and add them to the Memcache object. */ foreach($group as $index => $server) { -- GitLab