[Tue Jun 09 00:00:37.121924 2026] [php7:notice] [pid 1873272:tid 1873272] [client x:41356] PHP Notice: Constant SPACEAPI_TEST_CONST already defined in /var/www/spaceAPI_config.php on line 3
[Tue Jun 09 00:00:37.124484 2026] [php7:notice] [pid 1873272:tid 1873272] [client x:41356] PHP Notice: Constant SPACEAPI_KEY already defined in /var/www/spaceAPI_config.php on line 7
Caused by
|
include( $_SERVER['DOCUMENT_ROOT']."/../spaceAPI_config.php" ); |
and
|
include( $_SERVER['DOCUMENT_ROOT']."/../spaceAPI_config.php" ); |
I've hotfixed it by suppressing the warnings (see #6). Regarding a long-term fix:
Using include_once instead of include causes the database variables not to be set it seems (based on new warnings being shown; I didn't want to have it in a broken state so I quickly reverted that change)
PHP does not allow if ( not defined('X')) { const X = ...; } so we can't just wrap it in a check. We could use if ( not defined('X')) { define('X', ...); } maybe
- Using
define('X', ...); instead of const x = ...; behaves differently with scoping. We would need to check if that's a change we can do
- We could migrate the global constants to variables, so having
SPACEAPI_KEY be a $variable_name instead of a constant. Then redefinitions are not a problem.
- Or vice versa: make them all global constants instead of variables, and we need not include it more than once.
- The entries could be split out into separate files. Then we include the file with
SPACEAPI_KEY once and the file with $variables wherever it is needed
Caused by
spaceAPI/SensorAbstraction.php
Line 23 in b4cbd4c
spaceAPI/StateAbstraction.php
Line 16 in b4cbd4c
I've hotfixed it by suppressing the warnings (see #6). Regarding a long-term fix:
Usingcauses the database variables not to be set it seems (based on new warnings being shown; I didn't want to have it in a broken state so I quickly reverted that change)include_onceinstead ofincludePHP does not allowso we can't just wrap it in a check. We could useif ( not defined('X')) { const X = ...; }if ( not defined('X')) { define('X', ...); }maybedefine('X', ...);instead ofconst x = ...;behaves differently with scoping. We would need to check if that's a change we can doSPACEAPI_KEYbe a$variable_nameinstead of a constant. Then redefinitions are not a problem.SPACEAPI_KEYonce and the file with$variableswherever it is needed