Apache errors - "constant already defined"

Permalink
Hi all

I've noticed that my Apache error log is showing hundreds of errors saying the constants in site.php are already defined:

[Mon Nov 07 12:17:06 2011] [error] [client 1.2.3.4] PHP Notice:  Constant DB_PASSWORD already defined in /var/www/config/site.php on line 5, referer: http://1.2.3.4/index.php/dashboard/settings/
[Mon Nov 07 12:17:06 2011] [error] [client 1.2.3.4] PHP Notice:  Constant DB_DATABASE already defined in /var/www/config/site.php on line 6, referer: http://1.2.3.4/index.php/dashboard/settings/
[Mon Nov 07 12:17:06 2011] [error] [client 1.2.3.4] PHP Notice:  Constant BASE_URL already defined in /var/www/config/site.php on line 7, referer: http://1.2.3.4/index.php/dashboard/settings/
[Mon Nov 07 12:17:06 2011] [error] [client 1.2.3.4] PHP Notice:  Constant DIR_REL already defined in /var/www/config/site.php on line 8, referer: http://1.2.3.4/index.php/dashboard/settings/
[Mon Nov 07 12:17:06 2011] [error] [client 1.2.3.4] PHP Notice:  Constant FORM_BLOCK_SENDER_EMAIL already defined in /var/www/config/site.php on line 9, referer: http://1.2.3.4/index.php/dashboard/settings/
[Mon Nov 07 12:17:06 2011] [error] [client 1.2.3.4] PHP Notice:  Constant PASSWORD_SALT already defined in /var/www/config/site.php on line 10, referer: http://1.2.3.4/index.php/dashboard/settings/
[Mon Nov 07 12:17:06 2011] [error] [client 1.2.3.4] PHP Notice:  Constant PERMISSIONS_MODEL already defined in /var/www/config/site.php on line 11, referer: http://1.2.3.4/index.php/dashboard/settings/


This happens on every page load, so it's obviously putting some strain on the server having to log all of this. The site is running 5.4.2.2 (upgraded from 5.4.1 IIRC).

Any idea how to sort this?

melat0nin
View Replies:
foiseworth replied on at Permalink Reply
foiseworth
The reason for the error (I think) is that the constants are being redefined so either:

1. site.php has them entered twice

2. a file elsewhere is also including them or including site.php again

Could you post a copy of site.php?
melat0nin replied on at Permalink Reply
melat0nin
Thanks for the reply

site.php isn't declaring them twice. I can't think what other file might be redeclaring them. Here's site.php:

<?php
define('DB_SERVER', 'localhost');
define('DB_USERNAME', 'dbuser');
define('DB_PASSWORD', 'dbpass');
define('DB_DATABASE', 'db');
define('BASE_URL', 'http://myurl.com');
define('DIR_REL', '');
define('FORM_BLOCK_SENDER_EMAIL', [email protected]');
define('PASSWORD_SALT', 'lksjdflkjsdfndlkjsfd');
define('PERMISSIONS_MODEL', 'advanced');
define('USER_USERNAME_ALLOW_SPACES', true);
//define('CACHE_FRONTEND_OPTIONS', serialize(array('automatic_cleaning_factor' => 0)));
define('CACHE_LIBRARY', 'apc');
define('AVATAR_NONE', '/themes/mytheme/images/default-avatar.jpg');
?><?php define('DIRNAME_APP_UPDATED', 'concrete5.4.2.2');?>
melat0nin replied on at Permalink Reply
melat0nin
I've found the issue: I had



specified in site.php. I've removed that and the errors have stopped being logged. That said, I wonder why it's happening in the first place?
gtjw replied on at Permalink Reply
Try this with in site.php

if (defined('DB_SERVER'))
    define('DB_SERVER', 'localhost');
if (defined('DB_USERNAME'))
    define('DB_USERNAME', 'dbuser');
etc.


And see if it helps out.
If it does, site.php is loaded twice
if it doesn't you have another page where the script defines the constances.