[dev] how to repair the conf object?

Michael J Rubinsky mrubinsk at horde.org
Mon May 27 13:59:10 UTC 2019


Quoting Sebastian Birnbach <birnbacs at gmail.com>:

> Maybe I was using the incorrect approach to use the nag api.
>
> Everything is fine if I do:
>
> global $registry;
> try{
> $tasks = $registry->tasks->listTasks();
> } catch (Exception $e) {
> echo _("tasks access denied");
> }
> print_r($tasks);
>
> Is this the way to do it?

Exactly.


> And the other one was just ... BS?
>
> Am Mo., 27. Mai 2019 um 12:15 Uhr schrieb Sebastian Birnbach <
> birnbacs at gmail.com>:
>
>>
>>
>> Am Sa., 25. Mai 2019 um 18:37 Uhr schrieb Michael J Rubinsky <
>> mrubinsk at horde.org>:
>>
>>>
>>> [...]
>>>
>>> And this is the conf.xml of you own application, correct? I.e.
>>> /horde/dossierstorage/conf/conf.xml?
>>>
>>
>> My application is called abakus, the xml file is
>> horde/abakus/config/conf.xml
>> Other applications do not use their name in conf.xml so I don't either
>>
>>
>>>
>>>
>>>
>>> It sounds to me like there is some error in how you are initializing
>>> your application within horde and the application's context is leaking
>>> out to other applications.
>>
>>
>>
>>> Did you create a registry entry for your
>>> application?
>>
>>
>> I did create file horde/config/registry.d/abakus.php with content
>>
>> <?php
>>
>> $this->applications['abakus'] = array('name' => _("Abakus")
>>
>> );
>>
>>
>> Is there more to it?
>>
>>
>>
>>
>>> Are you calling Horde_Registry::appInit() at the
>>> beginning of each of your application's requests?
>>>
>> I do. Here is the api.php file I use for testing:
>>
>> <?php
>>
>> require_once __DIR__ . '/lib/Application.php';
>> Horde_Registry::appInit('abakus');
>> $page_output->header(array('title' => _("Nag API Test")));
>>
>> echo "<h3>Testing Nag API</h3>";
>> echo "<pre>\n";
>>
>> echo "dossierstorage driver is " .
>> $GLOBALS['conf']['dossierstorage']['driver'] . "\n";
>>
>> $nag = new Nag_Api();
>> $tasks = $nag->listTasks();
>> print_r($tasks);
>>
>> echo "</pre>\n";
>> $page_output->footer();
>>
>> exit;
>>
>>
>>> Normally, when you load an application, as part of the init process,
>>> your application is pushed onto the registry stack and it's conf.php
>>> values are merged with the horde(base) application's conf.php values.
>>> There should be no other entries in $conf other than the horde/base
>>> application and the currently scoped application.
>>>
>>
>> I see. In api.php:
>> * if I do an Horde_Registry::appInit('abakus'); the calling page
>> (api.php) sees the abakus configuration but nag is unhappy
>> * if I do an Horde_Registry::appInit('nag'); nag is happy but the calling
>> page sees no abakus configuration
>> * if I do both, whichever statement comes fist gets precedence.
>>
>> So, as you said, only one app is active at a time and an inactive app's
>> configuration is not accessible.
>>
>> It surprises me that I need to appInit('nag') to use its API though.
>> How do I work with my own application then?
>>
>>
>>
> --
> dev mailing list
> Frequently Asked Questions: http://wiki.horde.org/FAQ
> To unsubscribe, mail: dev-unsubscribe at lists.horde.org



-- 
mike
The Horde Project
http://www.horde.org
https://www.facebook.com/hordeproject
https://www.twitter.com/hordeproject
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-keys
Size: 9272 bytes
Desc: PGP Public Key
URL: <https://lists.horde.org/archives/dev/attachments/20190527/f49bb88f/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 821 bytes
Desc: PGP Digital Signature
URL: <https://lists.horde.org/archives/dev/attachments/20190527/f49bb88f/attachment-0001.bin>


More information about the dev mailing list