6.0.0-beta1
7/6/25

[#14452] Cannot redeclare class Horde_Hooks
Summary Cannot redeclare class Horde_Hooks
Queue Horde Groupware Webmail Edition
Queue Version 5.2.15
Type Bug
State Resolved
Priority 1. Low
Owners
Requester webmaster (at) object (dot) earth
Created 08/24/2016 (3238 days ago)
Due
Updated 08/25/2016 (3237 days ago)
Assigned
Resolved 08/25/2016 (3237 days ago)
Github Issue Link
Github Pull Request
Milestone
Patch No

History
08/25/2016 03:48:53 PM Michael Rubinsky Comment #6
State ⇒ Resolved
Reply to this comment
Ah, knowing it was from prefs only was what I needed. Looks like this 
bug that was already fixed in Git for the next bug fix release:

https://github.com/horde/horde/commit/a36f1883af3ef5c35491afd706ac1ecb178d4d3c
08/25/2016 03:07:39 PM webmaster (at) object (dot) earth Comment #5 Reply to this comment
A: grep -iR Horde_Hooks *
shows no other occurance of the horde_hooks class other than in the 
file already mentioned.

A debugging of the file /usr/share/php/Horde/Registry.php
on line 1836

shows the load of these hooks (app => conf_file):
horde => hooks.php
imp => hooks.php
ingo => hooks.php
nag => hooks.php
kronolith => hooks.php
turba => attributes.php
turba => backends.php
turba => hooks.php
mnemo => hooks.php
trean => hooks.php
passwd => hooks.php
  => hooks.php

the last entry does not carry an app name, which might cause the issue.
This entry occurs only in the preferences area, where I encounter the 
problem. In other areas (e.g. Ingo), the debug outputs the loading of:

horde => hooks.php
ingo => hooks.php
imp => hooks.php
nag => hooks.php
kronolith => hooks.php
turba => attributes.php
turba => backends.php
turba => hooks.php
mnemo => hooks.php
trean => hooks.php
passwd => hooks.php

it is the same, except the app-less line is missing and no error occurs.

08/25/2016 02:14:11 PM Michael Rubinsky Comment #4 Reply to this comment
Where did you see that you need to create a *.local.php version of
the hooks file?
I anticipated this pattern from other places to prevent updates from 
overwriting my changes.
Understandable, though the header of the hooks file explains 
differently since this doesn't work with files that contain class 
declarations.
This file declares the Horde_Hooks class, therefore
cannot be loaded more than once. All hooks need to be created in the
hooks.php file.
I don't have a hooks.php file, only the hooks.local.php.
I moved hooks.local.php to hooks.php with the same result. It 
doesn't make the error disappear.
Horde is distributed with a hooks.php.dist file that needs to be moved 
to hooks.php if any hooks need to be defined. If you are still getting 
this error, you must still have another file being loaded that 
contains the Horde_Hooks class declaration (or for some reason you 
have it multiple times in your own file).

08/25/2016 02:07:34 PM webmaster (at) object (dot) earth Comment #3 Reply to this comment
Where did you see that you need to create a *.local.php version of 
the hooks file?
I anticipated this pattern from other places to prevent updates from 
overwriting my changes.
This file declares the Horde_Hooks class, therefore cannot be loaded 
more than once. All hooks need to be created in the hooks.php file.
I don't have a hooks.php file, only the hooks.local.php.
I moved hooks.local.php to hooks.php with the same result. It doesn't 
make the error disappear.




08/24/2016 12:56:30 PM Michael Rubinsky Comment #2
Priority ⇒ 1. Low
State ⇒ Not A Bug
Reply to this comment
Where did you see that you need to create a *.local.php version of the 
hooks file? This file declares the Horde_Hooks class, therefore cannot 
be loaded more than once. All hooks need to be created in the 
hooks.php file.
08/24/2016 09:04:04 AM webmaster (at) object (dot) earth Comment #1
Priority ⇒ 2. Medium
Type ⇒ Bug
Summary ⇒ Cannot redeclare class Horde_Hooks
Queue ⇒ Horde Groupware Webmail Edition
Milestone ⇒
Patch ⇒ No
New Attachment: hooks.local.php Download
State ⇒ Unconfirmed
Reply to this comment
The logs show an error message:

[Wed Aug 24 08:59:10.159980 2016] [:error] [pid 19586] [client 
xxx.xxx.xxx.xxx:3938] PHP Fatal error:  Cannot redeclare class 
Horde_Hooks in /var/www/domain.tld/public_html/config/hooks.local.php 
on line 303, referer: https://domain.tld/services/prefs.php
[Wed Aug 24 08:59:10.160011 2016] [:error] [pid 19586] [client 
xxx.xxx.xxx.xxx:3938] PHP Stack trace:, referer: 
https://domain.tld/services/prefs.php
[Wed Aug 24 08:59:10.160020 2016] [:error] [pid 19586] [client 
xxx.xxx.xxx.xxx:3938] PHP   1. {main}() 
/var/www/domain.tld/public_html/services/ajax.php:0, referer: 
https://domain.tld/services/prefs.php
[Wed Aug 24 08:59:10.160029 2016] [:error] [pid 19586] [client 
xxx.xxx.xxx.xxx:3938] PHP   2. Horde_Core_Ajax_Application->send() 
/var/www/domain.tld/public_html/services/ajax.php:70, referer: 
https://domain.tld/services/prefs.php
[Wed Aug 24 08:59:10.160038 2016] [:error] [pid 19586] [client 
xxx.xxx.xxx.xxx:3938] PHP   3. Horde_Core_Ajax_Response->sendAndExit() 
/usr/share/php/Horde/Core/Ajax/Application.php:241, referer: 
https://domain.tld/services/prefs.php
[Wed Aug 24 08:59:10.160047 2016] [:error] [pid 19586] [client 
xxx.xxx.xxx.xxx:3938] PHP   4. 
Horde_Core_Ajax_Response_HordeCore->send() 
/usr/share/php/Horde/Core/Ajax/Response.php:55, referer: 
https://domain.tld/services/prefs.php
[Wed Aug 24 08:59:10.160055 2016] [:error] [pid 19586] [client 
xxx.xxx.xxx.xxx:3938] PHP   5. 
Horde_Core_Ajax_Response_HordeCore->_jsonData() 
/usr/share/php/Horde/Core/Ajax/Response/HordeCore.php:76, referer: 
https://domain.tld/services/prefs.php
[Wed Aug 24 08:59:10.160064 2016] [:error] [pid 19586] [client 
xxx.xxx.xxx.xxx:3938] PHP   6. Horde_Themes_Css->getStylesheetUrls() 
/usr/share/php/Horde/Core/Ajax/Response/HordeCore.php:133, referer: 
https://domain.tld/services/prefs.php
[Wed Aug 24 08:59:10.160072 2016] [:error] [pid 19586] [client 
xxx.xxx.xxx.xxx:3938] PHP   7. Horde_Themes_Css->getStylesheets() 
/usr/share/php/Horde/Themes/Css.php:93, referer: 
https://domain.tld/services/prefs.php
[Wed Aug 24 08:59:10.160081 2016] [:error] [pid 19586] [client 
xxx.xxx.xxx.xxx:3938] PHP   8. Horde_Core_Hooks->callHook() 
/usr/share/php/Horde/Themes/Css.php:189, referer: 
https://domain.tld/services/prefs.php
[Wed Aug 24 08:59:10.160089 2016] [:error] [pid 19586] [client 
xxx.xxx.xxx.xxx:3938] PHP   9. Horde_Core_Hooks->hookExists() 
/usr/share/php/Horde/Core/Hooks.php:50, referer: 
https://domain.tld/services/prefs.php
[Wed Aug 24 08:59:10.160106 2016] [:error] [pid 19586] [client 
xxx.xxx.xxx.xxx:3938] PHP  10. Horde_Registry->loadConfigFile() 
/usr/share/php/Horde/Core/Hooks.php:89, referer: 
https://domain.tld/services/prefs.php
[Wed Aug 24 08:59:10.160115 2016] [:error] [pid 19586] [client 
xxx.xxx.xxx.xxx:3938] PHP  11. 
Horde_Registry_Loadconfig->__construct() 
/usr/share/php/Horde/Registry.php:1840, referer: 
https://domain.tld/services/prefs.php


This error occurs independly of the logged in user.
It occurs only, if the user is in certain tabs in the settings area 
(e.g.: Preferences -> Global Preferences)

The user's browser sends the following request that causes the error:

POST /services/ajax.php/horde/topbarUpdate HTTP/1.1
Host: domain.tld
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:47.0) 
Gecko/20100101 Firefox/47.0
Accept: text/javascript, text/html, application/xml, text/xml, */*
Accept-Language: de,en-US;q=0.7,en;q=0.3
Accept-Encoding: gzip, deflate, br
X-Requested-With: XMLHttpRequest
X-Prototype-Version: 1.7.3
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
Referer: https://domain.tld/admin/config/config.php?app=horde
Content-Length: 165
Cookie: tgsitpamooe=ks43bhj1ual84ig71u3vh87ro6; 
horde_secret_key=DZ5R-I-QFVeZlPlHQK4M1E0
Connection: keep-alive
app=horde&hash=f6b907f7638ae3a2559b05ec848099a9&location=https%3A%2F%2Fdomain.tld%2Fadmin%2Fconfig%2Fconfig.php%3Fapp%3Dhorde&token=q2272ohEO_-MTlHjvj9H0f2

The server's response is: HTTP/1.0 500 Internal Server Error

I attached the file hooks.local.php. It only lowercases the $userId.

This error does not affect he correct execution of the webinterface.

Saved Queries