Make WordPress Core


Ignore:
Timestamp:
01/12/2015 02:23:43 AM (11 years ago)
Author:
jeremyfelt
Message:

Check for existence of data from get_blogaddress_by_id() before returning a URL

  • Prevent a notice when an invalid ID is used with get_blogaddres_by_id().
  • Return a falsy empty string rather than the previous "http://".
  • Add unit tests for get_blogaddress_by_id().

Props nerrad.

Fixes #30566.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/ms-blogs.php

    r31155 r31157  
    3434 *
    3535 * @param int $blog_id Blog ID
    36  * @return string
     36 * @return string Full URL of the blog if found. Empty string if not.
    3737 */
    3838function get_blogaddress_by_id( $blog_id ) {
    3939    $bloginfo = get_blog_details( (int) $blog_id, false ); // only get bare details!
    40     return esc_url( 'http://' . $bloginfo->domain . $bloginfo->path );
     40    return isset( $bloginfo->domain ) && isset( $bloginfo->path ) ?  esc_url( 'http://' . $bloginfo->domain . $bloginfo->path ) : '';
    4141}
    4242
Note: See TracChangeset for help on using the changeset viewer.