#21971 closed enhancement (invalid)
Checking for Server Protocol causes PHP notices
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | minor | Version: | 3.4.2 |
Component: | Warnings/Notices | Keywords: | |
Focuses: | Cc: |
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)
#1
@
12 years ago
- Milestone Awaiting Review deleted
- Resolution set to invalid
- Status changed from new to closed
#2
@
12 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?
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.