[dev] turba-git hooks

Ronan SALMON rsalmon at mbpgroup.com
Tue Mar 22 17:00:36 UTC 2011


Quoting Michael Rubinsky <mrubinsk at horde.org>:

> Quoting Ronan SALMON <rsalmon at mbpgroup.com>:
>
>> Quoting Michael Rubinsky <mrubinsk at horde.org>:
>>
>>> Quoting Ronan SALMON <rsalmon at mbpgroup.com>:
>>>
>>>> Michael Rubinsky <mrubinsk at horde.org> a écrit :
>>>>
>>>>> Quoting Ronan SALMON <rsalmon at mbpgroup.com>:
>>>>>
>>>>>> Hi all,
>>>>>>
>>>>>> I have 3 backends enabled : localsql, localldap, favourites
>>>>>>
>>>>>> I'm trying to setup a hook to automatically set pref  
>>>>>> 'addressbooks'. So far, I've always been able to automatically  
>>>>>> set backends 'localldap' and 'favourites', but not backend  
>>>>>> 'localsql'.
>>>>>>
>>>>>> Here is my hook :
>>>>>>
>>>>>> public function prefs_init($pref, $value, $username)
>>>>>> {
>>>>>> switch ($pref) {
>>>>>> case 'addressbooks':
>>>>>>    return json_encode(array_keys(Turba::availableSources()));
>>>>>> }
>>>>>> }
>>>>>>
>>>>>> This returns the 3 backends just fine, but when I login and go  
>>>>>> to turba's preferences, the 'localsql' backend is never in the  
>>>>>> selected group.
>>>>>
>>>>> Probably because localsql is using shares. Try something like:
>>>>>
>>>>> return  
>>>>> json_encode(array_keys(Turba:getConfigFromShares((Turba::availableSources()))));
>>>>
>>>> localsql and favourites are configured as defined in the default  
>>>> configuration prefs.php.
>>>>
>>>> If I try to return  
>>>> json_encode(array_keys(Turba::getConfigFromShares(Turba::availableSources())));
>>>> I get the following errors :
>>>>
>>>> 2011-03-22T16:21:49+01:00 NOTICE: HORDE [turba] PHP ERROR:  
>>>> Undefined variable: driver [pid 26971 on line 479 of  
>>>> "/var/www/html/hordetest/turba/lib/Turba.php"]
>>>> 2011-03-22T16:21:49+01:00 DEBUG:  1.  
>>>> Horde_Core_Auth_Application->authenticate()  
>>>> /var/www/html/hordetest/login.php:151
>>>> 2. Horde_Core_Auth_Application->authenticate()  
>>>> /var/www/html/hordetest/libs/Horde/Core/Auth/Application.php:128
>>>> 3. Horde_Core_Auth_Application->_setAuth()  
>>>> /var/www/html/hordetest/libs/Horde/Core/Auth/Application.php:140
>>>> 4. Horde_Registry->callAppMethod()  
>>>> /var/www/html/hordetest/libs/Horde/Core/Auth/Application.php:593
>>>> 5. Horde_Registry->pushApp()  
>>>> /var/www/html/hordetest/libs/Horde/Registry.php:1040
>>>> 6. Horde_Registry->loadPrefs()  
>>>> /var/www/html/hordetest/libs/Horde/Registry.php:1286
>>>> 7. Horde_Prefs->retrieve()  
>>>> /var/www/html/hordetest/libs/Horde/Registry.php:1437
>>>> 8. Horde_Prefs->_loadScope()  
>>>> /var/www/html/hordetest/libs/Horde/Prefs.php:336
>>>> 9. Horde_Core_Prefs_Storage_Hooks->get()  
>>>> /var/www/html/hordetest/libs/Horde/Prefs.php:368
>>>> 10. Horde::callHook()  
>>>> /var/www/html/hordetest/libs/Horde/Core/Prefs/Storage/Hooks.php:30
>>>> 11. call_user_func_array() /var/www/html/hordetest/libs/Horde.php:1730
>>>> 12. IMP_Hooks->prefs_init()
>>>> 13. Horde_Registry->call() /var/www/html/hordetest/imp/config/hooks.php:74
>>>> 14. Horde_Registry->callByPackage()  
>>>> /var/www/html/hordetest/libs/Horde/Registry.php:955
>>>> 15. Horde_Registry->pushApp()  
>>>> /var/www/html/hordetest/libs/Horde/Registry.php:993
>>>> 16. Horde_Registry->loadPrefs()  
>>>> /var/www/html/hordetest/libs/Horde/Registry.php:1286
>>>> 17. Horde_Prefs->retrieve()  
>>>> /var/www/html/hordetest/libs/Horde/Registry.php:1437
>>>> 18. Horde_Prefs->_loadScope()  
>>>> /var/www/html/hordetest/libs/Horde/Prefs.php:336
>>>> 19. Horde_Core_Prefs_Storage_Hooks->get()  
>>>> /var/www/html/hordetest/libs/Horde/Prefs.php:368
>>>> 20. Horde::callHook()  
>>>> /var/www/html/hordetest/libs/Horde/Core/Prefs/Storage/Hooks.php:30
>>>> 21. call_user_func_array() /var/www/html/hordetest/libs/Horde.php:1730
>>>> 22. Turba_Hooks->prefs_init()
>>>> 23. Turba::getConfigFromShares()  
>>>> /var/www/html/hordetest/turba/config/hooks.php:60
>>>> 24. Horde::errorHandler() /var/www/html/hordetest/turba/lib/Turba.php:479
>>>>
>>>> and it returns :
>>>> Array
>>>> (
>>>>  [0] => localldap
>>>>  [1] => favourites
>>>> )
>>>>
>>>> Output of json_encode(array_keys(Turba::availableSources())) :
>>>> Array
>>>> (
>>>>  [0] => localsql
>>>>  [1] => localldap
>>>>  [2] => favourites
>>>> )
>>>>
>>>> So I guess using Turba::availableSources() is fine.
>>>
>>> I just tested this and it works as expected for me:
>>>
>>> <code>
>>> echo  
>>> json_encode(array_keys(Turba::getConfigFromShares(Turba::availableSources())));
>>> </code>
>>>
>>> <output>
>>> ["FgAPa5Iy92dNWcml68wCkJA","ThY6J5Iy92dNccTGDHvwU_A","favourites","facebook"]
>>> </output>
>>>
>>>
>>> I just pushed a change that fixed the undefined variable error  
>>> (which would only be reached when an exception is thrown), so at  
>>> least now you will be able to get a better error message... see  
>>> what happens now.
>>
>> I get this :
>> The address book "localsql" does not exist. [pid 27017 on line 27  
>> of  
>> "/var/www/html/hordetest/libs/Horde/Core/Notification/Hordelog.php"]
>
> Can you provide a backtrace?

Something like that ?

debug_print_backtrace(Turba::getConfigFromShares(Turba::availableSources()));

2011-03-22T17:58:39+01:00 WARN: HORDE [turba] PHP ERROR:  
debug_print_backtrace() expects exactly 0 parameters, 1 given [pid  
26971 on line 60 of "/var/www/html/hordetest/turba/config/hooks.php"]
2011-03-22T17:58:39+01:00 DEBUG:  1.  
Horde_Core_Auth_Application->getLoginParams()  
/var/www/html/hordetest/login.php:142
  2. Horde_Core_Auth_Application->getLoginParams()  
/var/www/html/hordetest/libs/Horde/Core/Auth/Application.php:468
  3. Horde_Registry->callAppMethod()  
/var/www/html/hordetest/libs/Horde/Core/Auth/Application.php:469
  4. Horde_Registry->pushApp()  
/var/www/html/hordetest/libs/Horde/Registry.php:1040
  5. Horde_Registry->loadPrefs()  
/var/www/html/hordetest/libs/Horde/Registry.php:1286
  6. Horde_Prefs->retrieve()  
/var/www/html/hordetest/libs/Horde/Registry.php:1437
  7. Horde_Prefs->_loadScope() /var/www/html/hordetest/libs/Horde/Prefs.php:336
  8. Horde_Core_Prefs_Storage_Hooks->get()  
/var/www/html/hordetest/libs/Horde/Prefs.php:368
  9. Horde::callHook()  
/var/www/html/hordetest/libs/Horde/Core/Prefs/Storage/Hooks.php:30
10. call_user_func_array() /var/www/html/hordetest/libs/Horde.php:1730
11. IMP_Hooks->prefs_init()
12. Horde_Registry->call() /var/www/html/hordetest/imp/config/hooks.php:74
13. Horde_Registry->callByPackage()  
/var/www/html/hordetest/libs/Horde/Registry.php:955
14. Horde_Registry->pushApp()  
/var/www/html/hordetest/libs/Horde/Registry.php:993
15. Horde_Registry->loadPrefs()  
/var/www/html/hordetest/libs/Horde/Registry.php:1286
16. Horde_Prefs->retrieve()  
/var/www/html/hordetest/libs/Horde/Registry.php:1437
17. Horde_Prefs->_loadScope() /var/www/html/hordetest/libs/Horde/Prefs.php:336
18. Horde_Core_Prefs_Storage_Hooks->get()  
/var/www/html/hordetest/libs/Horde/Prefs.php:368
19. Horde::callHook()  
/var/www/html/hordetest/libs/Horde/Core/Prefs/Storage/Hooks.php:30
20. call_user_func_array() /var/www/html/hordetest/libs/Horde.php:1730
21. Turba_Hooks->prefs_init()
22. debug_print_backtrace() /var/www/html/hordetest/turba/config/hooks.php:60
23. Horde::errorHandler()


Ronan



More information about the dev mailing list