[wp-trac] [WordPress Trac] #12375: HTTP class contains redundant defined() check

WordPress Trac noreply at wordpress.org
Sat Nov 15 23:49:15 UTC 2014


#12375: HTTP class contains redundant defined() check
------------------------------+---------------------
 Reporter:  TobiasBg          |       Owner:  nacin
     Type:  enhancement       |      Status:  closed
 Priority:  normal            |   Milestone:  3.0
Component:  HTTP API          |     Version:
 Severity:  normal            |  Resolution:  fixed
 Keywords:  has-patch commit  |     Focuses:
------------------------------+---------------------

Comment (by najamelan):

 I just wanted to share an idea on the matter. Surely checking if it's
 defined is necessary to avoid php spewing warnings, however I don't like
 either of the patches. It seems the proper way to do this is to test
 somewhere early on in code that is garanteed to run on every request (wp-
 settings.php) like this:


 {{{
 if( ! defined( WP_HTTP_BLOCK_EXTERNAL ) )

     define( WP_HTTP_BLOCK_EXTERNAL, false );
 }}}


 Now it can be counted on to exist everywhere, and code can be simplified
 where it matters. I mean it's still extra code to work around the lack of
 an elegant matter in php to express this, but the test exists only once,
 far away from code logic.

 It might seem strange when there is only one occurrence of this elsewhere,
 but that's right now, and might change later since there is quite some
 inconsistencies in the user interface when using WP_HTTP_BLOCK_EXTERNAL.
 It will throw errors on the plugins page because it can't connect to
 wordpress, it will still show you update as quick action even though this
 can no longer work, it will want to put a plugin count in the menu bar, on
 the admin-bar etc...

 On top of that this could be done with all defines used in the core to
 clean things up all over.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/12375#comment:7>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list