#21971 closed enhancement (invalid)
Checking for Server Protocol causes PHP notices
| Reported by: | omarabid | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | Warnings/Notices | Version: | 3.4.2 |
| Severity: | minor | Keywords: | |
| Cc: | Focuses: |
Description
I'm debugging my WordPress App. through the PHPStorm Debugger which is not a Browser but a simple compiler of the PHP code.
WordPress checks for two global variables without checking that they are defined, which causes an annoying notice in the Debugger.
The file: wp-includes/functions.php
The function: status_header()
The solution is simply to check that the variable is defined
if (isset($_SERVER["SERVER_PROTOCOL"])) {
$protocol = $_SERVER["SERVER_PROTOCOL"];
} else {
$protocol = null;
}
The same problem for the function redirect_canonical().
A simple isset() check will get rid of this annoyance.
Change History (3)
#2
@
14 years ago
I need to load both the Theme and the Queries. I got around it (if anyone is looking for a solution) by creating a prepend.php and adding auto_prepend_file = "prepend.php" to the PHP.ini. The file obviously sets these variables to mimic a web server.
However, isn't it a best practice to check that variables are defined before using them?
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
WordPress is not meant to run on the command line (as a PHP binary app which is what PHP Storm is doing) as is - anytime you run WordPress as a php app versus in the browser, $_SERVER won't be set properly. If you want to run WordPress on the command line without loading queries or the theme:
Run that in whatever directory WordPress is in.