organic-search-analytics
organic-search-analytics copied to clipboard
PHP warnings and notices in data capture
I run the data capture daily on a cPanel/LiteSpeed/PHP7.1 server. For each domain, I see these two warnings in error_log:
[12-Jun-2017 14:00:50 UTC] PHP Notice: Undefined index: DOCUMENT_ROOT in <installation_dir>/inc/code/globalIncludes.php on line 4 [12-Jun-2017 14:00:50 UTC] PHP Notice: Undefined index: SCRIPT_FILENAME in <installation_dir>/inc/code/globalIncludes.php on line 7
(In the log file, the actual installation directory appears instead of <installation_dir>).
The code should check for the respective indexes before using them (using isset()), and use suitable defaults when they are not set.
Similarly, in data-capture-run.php, the "domain" and "date" indexes should be checked before issuing the error message on line 85.
Interesting observation regarding DOCUMENT_ROOT and SCRIPT_FILENAME. I'll need to retest a cron task on a traditional linux box when I have time here. There is a chance that the DOCUMENT_ROOT and SCRIPT_FILENAME parameters are only passed on a HTTP request (as you suggest as a solution) and not via a direct PHP request.
That said, the usage of the variables these parameters are being accessed to populate are not used very heavily (at this time...) and are actually used primarily for loading external assets such as JS and CSS files on the report and settings pages. So the fact that these errors are thrown when using a cron request really does not have a negative impact.
Good catch regarding data-capture-run.php on line 85.