Hi all,
We are using a customized location rewrite function to split the SNMP location of devices into a human readable and a machine understandable format. We are using the community edition, and on updating to the recent version we were faced with thIS error message:
PHP Fatal error: Cannot redeclare custom_rewrite_location() (previously declared in /opt/observium/config.php:87) in /opt/observium/config.php on line 102
This is a common error when a php file is included/required more than once, so I made a workaround by renaming config.php to config.user.php and using require_once() in the original config.php to load these directives (it needs absolute path otherways it cannot find the file).
Shouldn't require_once/include_once be used in all the places where referencing config.php?
Br, Tylla,
It seems your config.php file was somehow modified during the upgrade procedure, such that the custom function you defined in there is being redeclared 15 lines later.
It may be as simple as removing the second declaration of custom_rewrite_location() starting on line 102, though I suspect you may have a few other issues in the config file.
If you have a backup of the config.php file from before the upgrade, I'd first try replacing the current one with that backup. Failing that, you will need to manually go through the config file to fix any other issues introduced during the upgrade. If you can't figure out what else, if anything, is messed up, you can share your config.php here, with any sensitive info edited out...
On 02/23/2016 01:17 PM, Nagy Attila wrote:
Hi all,
We are using a customized location rewrite function to split the SNMP location of devices into a human readable and a machine understandable format. We are using the community edition, and on updating to the recent version we were faced with thIS error message:
PHP Fatal error: Cannot redeclare custom_rewrite_location() (previously declared in /opt/observium/config.php:87) in /opt/observium/config.php on line 102
This is a common error when a php file is included/required more than once, so I made a workaround by renaming config.php to config.user.php and using require_once() in the original config.php to load these directives (it needs absolute path otherways it cannot find the file).
Shouldn't require_once/include_once be used in all the places where referencing config.php?
Br, Tylla,
observium mailing list observium@observium.org http://postman.memetic.org/cgi-bin/mailman/listinfo/observium
Not at all. If that were the case than the error would persist even after I used require_once() for the same unchanged file. And I can reproduce the error if I simply change the require_once() function call to a simple require().
Btw. the declaration is there only once. It starts on line 87 and the ending bracket of the function is on line 102.
So the question remains, shouldn't require_once/include_once be used in all the places where referencing config.php?
On 2016-02-23 19:34, Joseph Zancocchio wrote:
It seems your config.php file was somehow modified during the upgrade procedure, such that the custom function you defined in there is being redeclared 15 lines later.
It may be as simple as removing the second declaration of custom_rewrite_location() starting on line 102, though I suspect you may have a few other issues in the config file.
If you have a backup of the config.php file from before the upgrade, I'd first try replacing the current one with that backup. Failing that, you will need to manually go through the config file to fix any other issues introduced during the upgrade. If you can't figure out what else, if anything, is messed up, you can share your config.php here, with any sensitive info edited out...
On 02/23/2016 01:17 PM, Nagy Attila wrote:
Hi all,
We are using a customized location rewrite function to split the SNMP location of devices into a human readable and a machine understandable format. We are using the community edition, and on updating to the recent version we were faced with thIS error message:
PHP Fatal error: Cannot redeclare custom_rewrite_location() (previously declared in /opt/observium/config.php:87) in /opt/observium/config.php on line 102
This is a common error when a php file is included/required more than once, so I made a workaround by renaming config.php to config.user.php and using require_once() in the original config.php to load these directives (it needs absolute path otherways it cannot find the file).
Shouldn't require_once/include_once be used in all the places where referencing config.php?
Br, Tylla,
observium mailing list observium@observium.org http://postman.memetic.org/cgi-bin/mailman/listinfo/observium
observium mailing list observium@observium.org http://postman.memetic.org/cgi-bin/mailman/listinfo/observium
Do not declare functions in config.php
adam. On 23/02/2016 21:02:04, Nagy Attila tylla_at_memetic.org@tylla.hu wrote: Not at all. If that were the case than the error would persist even after I used require_once() for the same unchanged file. And I can reproduce the error if I simply change the require_once() function call to a simple require().
Btw. the declaration is there only once. It starts on line 87 and the ending bracket of the function is on line 102.
So the question remains, shouldn't require_once/include_once be used in all the places where referencing config.php?
On 2016-02-23 19:34, Joseph Zancocchio wrote:
It seems your config.php file was somehow modified during the upgrade procedure, such that the custom function you defined in there is being redeclared 15 lines later.
It may be as simple as removing the second declaration of custom_rewrite_location() starting on line 102, though I suspect you may have a few other issues in the config file.
If you have a backup of the config.php file from before the upgrade, I'd first try replacing the current one with that backup. Failing that, you will need to manually go through the config file to fix any other issues introduced during the upgrade. If you can't figure out what else, if anything, is messed up, you can share your config.php here, with any sensitive info edited out...
On 02/23/2016 01:17 PM, Nagy Attila wrote:
Hi all,
We are using a customized location rewrite function to split the SNMP location of devices into a human readable and a machine understandable format. We are using the community edition, and on updating to the recent version we were faced with thIS error message:
PHP Fatal error: Cannot redeclare custom_rewrite_location() (previously declared in /opt/observium/config.php:87) in /opt/observium/config.php on line 102
This is a common error when a php file is included/required more than once, so I made a workaround by renaming config.php to config.user.php and using require_once() in the original config.php to load these directives (it needs absolute path otherways it cannot find the file).
Shouldn't require_once/include_once be used in all the places where referencing config.php?
Br, Tylla,
observium mailing list observium@observium.org http://postman.memetic.org/cgi-bin/mailman/listinfo/observium
observium mailing list observium@observium.org http://postman.memetic.org/cgi-bin/mailman/listinfo/observium
_______________________________________________ observium mailing list observium@observium.org http://postman.memetic.org/cgi-bin/mailman/listinfo/observium
OK. Then what's the recommended place of custom_rewrite_location() function?
On 2016-02-23 22:02, Adam Armstrong wrote:
Do not declare functions in config.php
adam.
On 23/02/2016 21:02:04, Nagy Attila tylla_at_memetic.org@tylla.hu wrote:
Not at all. If that were the case than the error would persist even after I used require_once() for the same unchanged file. And I can reproduce the error if I simply change the require_once() function call to a simple require().
Btw. the declaration is there only once. It starts on line 87 and the ending bracket of the function is on line 102.
So the question remains, shouldn't require_once/include_once be used in all the places where referencing config.php?
On 2016-02-23 19:34, Joseph Zancocchio wrote:
It seems your config.php file was somehow modified during the upgrade procedure, such that the custom function you defined in there is being redeclared 15 lines later.
It may be as simple as removing the second declaration of custom_rewrite_location() starting on line 102, though I suspect you may have a few other issues in the config file.
If you have a backup of the config.php file from before the upgrade, I'd first try replacing the current one with that backup. Failing that, you will need to manually go through the config file to fix any other issues introduced during the upgrade. If you can't figure out what else, if anything, is messed up, you can share your config.php here, with any sensitive info edited out...
On 02/23/2016 01:17 PM, Nagy Attila wrote:
Hi all,
We are using a customized location rewrite function to split the SNMP location of devices into a human readable and a machine understandable format. We are using the community edition, and on updating to the recent version we were faced with thIS error message:
PHP Fatal error: Cannot redeclare custom_rewrite_location() (previously declared in /opt/observium/config.php:87) in /opt/observium/config.php on line 102
This is a common error when a php file is included/required more than once, so I made a workaround by renaming config.php to config.user.php and using require_once() in the original config.php to load these directives (it needs absolute path otherways it cannot find the file).
Shouldn't require_once/include_once be used in all the places where referencing config.php?
Br, Tylla,
observium mailing list observium@observium.org http://postman.memetic.org/cgi-bin/mailman/listinfo/observium
observium mailing list observium@observium.org http://postman.memetic.org/cgi-bin/mailman/listinfo/observium
observium mailing list observium@observium.org http://postman.memetic.org/cgi-bin/mailman/listinfo/observium
observium mailing list observium@observium.org http://postman.memetic.org/cgi-bin/mailman/listinfo/observium
includes/functions.inc.php would seem to be a sensible place.
A config file is certainly not the right place to define code, and whinging at other people when it causes things to break is not helpful.
adam. On 23/02/2016 21:08:15, Nagy Attila tylla_at_memetic.org@tylla.hu wrote: OK. Then what's the recommended place of custom_rewrite_location() function?
On 2016-02-23 22:02, Adam Armstrong wrote:
Do not declare functions in config.php
adam. On 23/02/2016 21:02:04, Nagy Attila tylla_at_memetic.org@tylla.hu [mailto:tylla_at_memetic.org@tylla.hu] wrote: Not at all. If that were the case than the error would persist even after I used require_once() for the same unchanged file. And I can reproduce the error if I simply change the require_once() function call to a simple require().
Btw. the declaration is there only once. It starts on line 87 and the ending bracket of the function is on line 102.
So the question remains, shouldn't require_once/include_once be used in all the places where referencing config.php?
On 2016-02-23 19:34, Joseph Zancocchio wrote:
It seems your config.php file was somehow modified during the upgrade procedure, such that the custom function you defined in there is being redeclared 15 lines later.
It may be as simple as removing the second declaration of custom_rewrite_location() starting on line 102, though I suspect you may have a few other issues in the config file.
If you have a backup of the config.php file from before the upgrade, I'd first try replacing the current one with that backup. Failing that, you will need to manually go through the config file to fix any other issues introduced during the upgrade. If you can't figure out what else, if anything, is messed up, you can share your config.php here, with any sensitive info edited out...
On 02/23/2016 01:17 PM, Nagy Attila wrote:
Hi all,
We are using a customized location rewrite function to split the SNMP location of devices into a human readable and a machine understandable format. We are using the community edition, and on updating to the recent version we were faced with thIS error message:
PHP Fatal error: Cannot redeclare custom_rewrite_location() (previously declared in /opt/observium/config.php:87) in /opt/observium/config.php on line 102
This is a common error when a php file is included/required more than once, so I made a workaround by renaming config.php to config.user.php and using require_once() in the original config.php to load these directives (it needs absolute path otherways it cannot find the file).
Shouldn't require_once/include_once be used in all the places where referencing config.php?
Br, Tylla,
observium mailing list observium@observium.org [mailto:observium@observium.org] http://postman.memetic.org/cgi-bin/mailman/listinfo/observium [http://postman.memetic.org/cgi-bin/mailman/listinfo/observium]
observium mailing list observium@observium.org [mailto:observium@observium.org] http://postman.memetic.org/cgi-bin/mailman/listinfo/observium [http://postman.memetic.org/cgi-bin/mailman/listinfo/observium]
_______________________________________________ observium mailing list observium@observium.org [mailto:observium@observium.org] http://postman.memetic.org/cgi-bin/mailman/listinfo/observium [http://postman.memetic.org/cgi-bin/mailman/listinfo/observium]
_______________________________________________ observium mailing list observium@observium.org [mailto:observium@observium.org] http://postman.memetic.org/cgi-bin/mailman/listinfo/observium [http://postman.memetic.org/cgi-bin/mailman/listinfo/observium]
BTW: We are purposefully including the config file multiple times, and require_once is not an option for this functionality
Adding a require_once() / include_once() into your config.php with that custom function is a good way.
Tom
On 23/02/2016 22:09, Adam Armstrong wrote:
includes/functions.inc.php would seem to be a sensible place.
A config file is certainly not the right place to define code, and whinging at other people when it causes things to break is not helpful.
adam.
On 23/02/2016 21:08:15, Nagy Attila tylla_at_memetic.org@tylla.hu wrote:
OK. Then what's the recommended place of custom_rewrite_location() function?
On 2016-02-23 22:02, Adam Armstrong wrote:
Do not declare functions in config.php
adam.
On 23/02/2016 21:02:04, Nagy Attila tylla_at_memetic.org@tylla.hu wrote:
Not at all. If that were the case than the error would persist even after I used require_once() for the same unchanged file. And I can reproduce the error if I simply change the require_once() function call to a simple require().
Btw. the declaration is there only once. It starts on line 87 and the ending bracket of the function is on line 102.
So the question remains, shouldn't require_once/include_once be used in all the places where referencing config.php?
On 2016-02-23 19:34, Joseph Zancocchio wrote:
It seems your config.php file was somehow modified during the
upgrade
procedure, such that the custom function you defined in there is
being
redeclared 15 lines later.
It may be as simple as removing the second declaration of custom_rewrite_location() starting on line 102, though I suspect you may have a few other issues in the config file.
If you have a backup of the config.php file from before the upgrade, I'd first try replacing the current one with that backup. Failing that, you will need to manually go through the config file to fix
any
other issues introduced during the upgrade. If you can't figure out what else, if anything, is messed up, you can share your config.php here, with any sensitive info edited out...
On 02/23/2016 01:17 PM, Nagy Attila wrote:
Hi all,
We are using a customized location rewrite function to split the
SNMP
location of devices into a human readable and a machine understandable format. We are using the community edition, and on updating to the recent version we were faced with thIS error message:
PHP Fatal error: Cannot redeclare custom_rewrite_location() (previously declared in /opt/observium/config.php:87) in /opt/observium/config.php on line 102
This is a common error when a php file is included/required more
than
once, so I made a workaround by renaming config.php to config.user.php and using require_once() in the original config.php to load these directives (it needs absolute path otherways it
cannot
find the file).
Shouldn't require_once/include_once be used in all the places where referencing config.php?
Br, Tylla,
observium mailing list observium@observium.org http://postman.memetic.org/cgi-bin/mailman/listinfo/observium
observium mailing list observium@observium.org http://postman.memetic.org/cgi-bin/mailman/listinfo/observium
observium mailing list observium@observium.org http://postman.memetic.org/cgi-bin/mailman/listinfo/observium
observium mailing list observium@observium.org http://postman.memetic.org/cgi-bin/mailman/listinfo/observium
observium mailing list observium@observium.org http://postman.memetic.org/cgi-bin/mailman/listinfo/observium
May I ask you what is the purpose to include the config file more than once? (I'm really curious as in my practice I never had the urge to do something like this)
On 2016-02-23 23:42, Tom Laermans wrote:
BTW: We are purposefully including the config file multiple times, and require_once is not an option for this functionality
Adding a require_once() / include_once() into your config.php with that custom function is a good way.
Tom
On 23/02/2016 22:09, Adam Armstrong wrote:
includes/functions.inc.php would seem to be a sensible place.
A config file is certainly not the right place to define code, and whinging at other people when it causes things to break is not helpful.
adam.
On 23/02/2016 21:08:15, Nagy Attila tylla_at_memetic.org@tylla.hu wrote:
OK. Then what's the recommended place of custom_rewrite_location() function?
On 2016-02-23 22:02, Adam Armstrong wrote:
Do not declare functions in config.php
adam.
On 23/02/2016 21:02:04, Nagy Attila tylla_at_memetic.org@tylla.hu wrote:
Not at all. If that were the case than the error would persist even after I used require_once() for the same unchanged file. And I can reproduce the error if I simply change the require_once() function call to a simple require().
Btw. the declaration is there only once. It starts on line 87 and the ending bracket of the function is on line 102.
So the question remains, shouldn't require_once/include_once be used in all the places where referencing config.php?
On 2016-02-23 19:34, Joseph Zancocchio wrote:
It seems your config.php file was somehow modified during the
upgrade
procedure, such that the custom function you defined in there is
being
redeclared 15 lines later.
It may be as simple as removing the second declaration of custom_rewrite_location() starting on line 102, though I suspect
you
may have a few other issues in the config file.
If you have a backup of the config.php file from before the
upgrade,
I'd first try replacing the current one with that backup. Failing that, you will need to manually go through the config file to
fix any
other issues introduced during the upgrade. If you can't figure out what else, if anything, is messed up, you can share your config.php here, with any sensitive info edited out...
On 02/23/2016 01:17 PM, Nagy Attila wrote: > Hi all, > > We are using a customized location rewrite function to split
the SNMP
> location of devices into a human readable and a machine > understandable format. > We are using the community edition, and on updating to the recent > version we were faced with thIS error message: > > PHP Fatal error: Cannot redeclare custom_rewrite_location() > (previously declared in /opt/observium/config.php:87) in > /opt/observium/config.php on line 102 > > This is a common error when a php file is included/required
more than
> once, so I made a workaround by renaming config.php to > config.user.php and using require_once() in the original
config.php
> to load these directives (it needs absolute path otherways it
cannot
> find the file). > > Shouldn't require_once/include_once be used in all the places
where
> referencing config.php? > > Br, > Tylla, > > _______________________________________________ > observium mailing list > observium@observium.org > http://postman.memetic.org/cgi-bin/mailman/listinfo/observium
observium mailing list observium@observium.org http://postman.memetic.org/cgi-bin/mailman/listinfo/observium
observium mailing list observium@observium.org http://postman.memetic.org/cgi-bin/mailman/listinfo/observium
observium mailing list observium@observium.org http://postman.memetic.org/cgi-bin/mailman/listinfo/observium
observium mailing list observium@observium.org http://postman.memetic.org/cgi-bin/mailman/listinfo/observium
observium mailing list observium@observium.org http://postman.memetic.org/cgi-bin/mailman/listinfo/observium
Hi,
My thought was that maybe I found something nasty. But as Tom
pointed out in another e-mail this functionality is on purpose, so it's a feature not a bug.
So sorry for wasting some peoples' time, my mail was born with good
intention.
Don't sweat it - it's something that may indeed surprise you if you don't expect it, as the config file is effectively code. :-)
I'm not quite sure where it's being included twice, but since the introduction of settings in SQL and the fact that we now lock certain configuration definitions so you can't change them (and they're also in the $config array), it's likely we include it again to overwrite certain things. I had a more clear picture in my head when I wrote the mail quoted below, but... I'm pretty sure that's why it happens. Could be a bug, too, but then someone will have to go hunting... or you just do as above, and put your function in a separate file :-)
For the custom port description parser, we include a certain file if it exists and is pointed to by a config variable, maybe we should do the same for a custom location rewriter? That way there's a defined place for it, which will not be overwritten, and is not in the config itself.
Tom
On 2016-02-24 17:51, Attila Nagy wrote:
May I ask you what is the purpose to include the config file more than once? (I'm really curious as in my practice I never had the urge to do something like this)
On 2016-02-23 23:42, Tom Laermans wrote:
BTW: We are purposefully including the config file multiple times, and require_once is not an option for this functionality
Adding a require_once() / include_once() into your config.php with that custom function is a good way.
Tom
On 23/02/2016 22:09, Adam Armstrong wrote:
includes/functions.inc.php would seem to be a sensible place.
A config file is certainly not the right place to define code, and whinging at other people when it causes things to break is not helpful.
adam.
On 23/02/2016 21:08:15, Nagy Attila tylla_at_memetic.org@tylla.hu wrote:
OK. Then what's the recommended place of custom_rewrite_location() function?
On 2016-02-23 22:02, Adam Armstrong wrote:
Do not declare functions in config.php
adam.
On 23/02/2016 21:02:04, Nagy Attila tylla_at_memetic.org@tylla.hu wrote:
Not at all. If that were the case than the error would persist even after I used require_once() for the same unchanged file. And I can reproduce the error if I simply change the require_once() function call to a simple require().
Btw. the declaration is there only once. It starts on line 87 and the ending bracket of the function is on line 102.
So the question remains, shouldn't require_once/include_once be used in all the places where referencing config.php?
On 2016-02-23 19:34, Joseph Zancocchio wrote: > It seems your config.php file was somehow modified during the upgrade > procedure, such that the custom function you defined in there is being > redeclared 15 lines later. > > It may be as simple as removing the second declaration of > custom_rewrite_location() starting on line 102, though I suspect you > may have a few other issues in the config file. > > If you have a backup of the config.php file from before the upgrade, > I'd first try replacing the current one with that backup. Failing > that, you will need to manually go through the config file to fix any > other issues introduced during the upgrade. If you can't figure out > what else, if anything, is messed up, you can share your config.php > here, with any sensitive info edited out... > > On 02/23/2016 01:17 PM, Nagy Attila wrote: >> Hi all, >> >> We are using a customized location rewrite function to split the SNMP >> location of devices into a human readable and a machine >> understandable format. >> We are using the community edition, and on updating to the recent >> version we were faced with thIS error message: >> >> PHP Fatal error: Cannot redeclare custom_rewrite_location() >> (previously declared in /opt/observium/config.php:87) in >> /opt/observium/config.php on line 102 >> >> This is a common error when a php file is included/required more than >> once, so I made a workaround by renaming config.php to >> config.user.php and using require_once() in the original config.php >> to load these directives (it needs absolute path otherways it cannot >> find the file). >> >> Shouldn't require_once/include_once be used in all the places where >> referencing config.php? >> >> Br, >> Tylla, >> >> _______________________________________________ >> observium mailing list >> observium@observium.org >> http://postman.memetic.org/cgi-bin/mailman/listinfo/observium > > _______________________________________________ > observium mailing list > observium@observium.org > http://postman.memetic.org/cgi-bin/mailman/listinfo/observium
observium mailing list observium@observium.org http://postman.memetic.org/cgi-bin/mailman/listinfo/observium
observium mailing list observium@observium.org http://postman.memetic.org/cgi-bin/mailman/listinfo/observium
observium mailing list observium@observium.org http://postman.memetic.org/cgi-bin/mailman/listinfo/observium
observium mailing list observium@observium.org http://postman.memetic.org/cgi-bin/mailman/listinfo/observium
observium mailing list observium@observium.org http://postman.memetic.org/cgi-bin/mailman/listinfo/observium
On 2016-02-24 17:56, Tom Laermans wrote:
For the custom port description parser, we include a certain file if it exists and is pointed to by a config variable, maybe we should do the same for a custom location rewriter? That way there's a defined place for it, which will not be overwritten, and is not in the config itself.
Yes that would make things much clearer. (and at that point maybe a separate config directory could be justified)
Anyway for the time being I'll go now with the lazy way as you proposed/I figured out. :)
OK, I don't want to argue with you as you are the boss here. :) But I - as a programmer - would never put a custom (override) function into an include file that will be overwritten on next update. And a config file is the right place for everything configuration related and this time the custom function belongs to configuration as it's content completely depends on the actual site where it is run. After all I will go with my workaround by using require_once() to include my custom function config file.
My thought was that maybe I found something nasty. But as Tom pointed out in another e-mail this functionality is on purpose, so it's a feature not a bug. So sorry for wasting some peoples' time, my mail was born with good intention.
BR, Tylla
On 2016-02-23 22:09, Adam Armstrong wrote:
includes/functions.inc.php would seem to be a sensible place.
A config file is certainly not the right place to define code, and whinging at other people when it causes things to break is not helpful.
adam.
On 23/02/2016 21:08:15, Nagy Attila tylla_at_memetic.org@tylla.hu wrote:
OK. Then what's the recommended place of custom_rewrite_location() function?
participants (5)
-
Adam Armstrong
-
Attila Nagy
-
Joseph Zancocchio
-
Nagy Attila
-
Tom Laermans