[wp-hackers] siteurl and home variables / constants

Stephen Rider wp-hackers at striderweb.com
Mon Mar 30 14:07:34 GMT 2009


+1 on this.

If the constant is defined, it should be an absolute.  The constant  
should *always* override the value in the DB.

On Mar 30, 2009, at 7:57 AM, SoJ Web wrote:

> Sounds like a good idea to me; performance issues aside, I'd think  
> it ought to do that anyway. Isn't that the point of those constants?
>
> On Mar 30, 2009, at 4:29 AM, Joost de Valk wrote:
>
>> I was looking at the code for site_url in /wp-includes/link- 
>> template.php, and saw that it /always/ does a  
>> get_option('siteurl'), even when, as on my site, WP_SITEURL is  
>> defined in wp-config.php. The same goes for get_bloginfo in /wp- 
>> includes/general-template.php, for both WP_SITEURL and WP_HOME.
>>
>> Wouldn't it be good to check for that before doing the get_option,  
>> to save a query or two on each page load?
>>
>> It would be quite easy to make those functions use check for the  
>> defined constants before doing a database call.
>>
>> A quick plugin I cooked[1] up that does this by using the  
>> pre_option_* hook, showed me that this would save quite a number of  
>> calls (though of course after the two first calls, these would be  
>> cached). The only "issue" I encountered was that in functions.php's  
>> is_blog_installed function, a db query is done to check whether a  
>> blog is installed, and the query that's done is, you've guessed it,  
>> retrieving the siteurl...
>>
>> Anyway, I think some performance improvement could be made by  
>> adding in a check for the defined constants, but maybe I'm missing  
>> something?



More information about the wp-hackers mailing list