Need to push $app onto the stack before loading it's preferences.
authorMichael J. Rubinsky <mrubinsk@horde.org>
Sat, 10 Apr 2010 17:41:57 +0000 (13:41 -0400)
committerMichael J. Rubinsky <mrubinsk@horde.org>
Sat, 10 Apr 2010 17:41:57 +0000 (13:41 -0400)
Prevents fatal errors due to autoloading not being setup for the app.

horde/lib/Api.php

index 7e3ab5d..0204a41 100644 (file)
@@ -155,8 +155,14 @@ class Horde_Api extends Horde_Registry_Api
      */
     public function getPreference($app, $pref)
     {
+        $pushed = $GLOBALS['registry']->pushApp($app);
         $GLOBALS['registry']->loadPrefs($app);
-        return $GLOBALS['prefs']->getValue($pref);
+        $value = $GLOBALS['prefs']->getValue($pref);
+        if ($pushed) {
+            $GLOBALS['registry']->popApp();
+        }
+
+        return $value;
     }
 
     /**
@@ -169,8 +175,12 @@ class Horde_Api extends Horde_Registry_Api
      */
     public function setPreference($app, $pref, $value)
     {
+        $pushed = $GLOBALS['registry']->pushApp($app);
         $GLOBALS['registry']->loadPrefs($app);
-        return $GLOBALS['prefs']->setValue($pref, $value);
+        $value = $GLOBALS['prefs']->setValue($pref, $value);
+        if ($pushed) {
+            $GLOBALS['registry']->popApp();
+        }
     }
 
     /**