Opened 3 years ago
Closed 3 years ago
#12375 closed enhancement (fixed)
HTTP class contains redundant defined() check
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Priority: | normal | Milestone: | 3.0 |
| Component: | HTTP | Version: | |
| Severity: | normal | Keywords: | has-patch commit |
| Cc: |
Description
Line 554 of wp-includes/class-http.php contains a somewhat redundant logic:
if ( ! defined('WP_HTTP_BLOCK_EXTERNAL') || ( defined('WP_HTTP_BLOCK_EXTERNAL') && WP_HTTP_BLOCK_EXTERNAL == false ) )
| will only be executed if the constant is defined, thus it's overhead to check that again. Also checking constants for false (like WP_HTTP_BLOCK_EXTERNAL == false) is not good practice. |
I have attached two patches, one that simply removes the redundant check and simplifies the WP_HTTP_BLOCK_EXTERNAL == false to ! WP_HTTP_BLOCK_EXTERNAL.
The second patch has the same logic, but has De Morgan's laws applied. I could decide what looks better :-)
Attachments (2)
Change History (8)
I'm pretty sure we do this redundancy in multiple places. Used to be more, though I know we've eliminated some of them.
I grep'ed through the core source, but couldn't find any more occurances.
There are three or four more files that have two defined() checks in one line, but those check for different constants.

Patch to fix reduncancy and clean up comparison