[dev] conf.php not getting loaded
Jan Schneider
jan at horde.org
Fri Jun 27 09:24:38 UTC 2008
Zitat von Nathan Mills <nathan at nwacg.net>:
> I found myself needing to call a function from an application in
> prefs.php to populate an enum field. I ran across the issue with
> including base.php in prefs.php, did some research, and found that I
> should be including the one file with the function I need.
>
> That part works, but for some reason conf.php is getting lost when
> (and only when) I call the function. If it's never called from
> prefs.php, there's no problem. What am I doing wrong?
>
> I'm doing this in prefs.php:
>
> require_once dirname(__FILE__) . '/../lib/Astdial.php';
>
> $_prefs['channel'] = array(
> 'value' => '',
> 'locked' => false,
> 'shared' => false,
> 'type' => 'enum',
> 'enum' => Astdial::listDestinations(),
> 'desc' => _("Phone number where you can be reached")
> );
>
> This is the function in question:
>
> function listDestinations()
> {
> static $dests;
> if(is_null($dests)) {
> $apiargs = array(
> 'addresses' => array(''),
> 'addressbooks' => array('asterisk'),
> 'fields' => array()
> );
> $result = $GLOBALS['registry']->call('contacts/search', $apiargs);
> if(is_a($result, 'PEAR_Error')) {
> return $result;
> }
> $dests = array();
> if(!empty($result)) {
> $result = $result[''];
> foreach ($result as $dest) {
> $dests[$dest['id']] = $dest['name'];
> }
> }
> uasort($dests, 'strcoll');
> }
> return $dests;
> }
This is probably a side-effect of the registry call. prefs.php is
loaded during the pushApp() call, i.e. when loading an applications.
This same method is also importing the conf.php file.
But with executing $registry->call(), you push (implicitly) another
application on the application stack, while the current application is
still not completely loaded. My guess is that the registry is choking
on this behavior.
Jan.
--
Do you need professional PHP or Horde consulting?
http://horde.org/consulting/
More information about the dev
mailing list