WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 19 months ago

#18387 closed defect (bug) (fixed)

get_blog_id_from_url() has wrong return

Reported by: lonnylot Owned by:
Milestone: 3.5 Priority: normal
Severity: minor Version: 3.0
Component: Multisite Keywords: has-patch
Focuses: Cc:

Description

If the blog does not exist we sometimes return 0 and sometimes return false. Per the comment we should always be returning an int.

Attachments (3)

wrong_return.diff (368 bytes) - added by lonnylot 3 years ago.
18387.diff (4.8 KB) - added by ryan 19 months ago.
Down the rabbit hole
18387-ut.diff (3.0 KB) - added by ryan 19 months ago.
Unit tests

Download all attachments as: .zip

Change History (10)

lonnylot3 years ago

comment:1 scribu3 years ago

  • Severity changed from normal to minor

comment:2 nacin2 years ago

  • Version set to 3.0

comment:3 wonderboymusic19 months ago

  • Milestone changed from Awaiting Review to 3.5

comment:4 ryan19 months ago

This function needs a lot of help. Its cache is never invalidated and escaped data is used to create cache keys. We need to do something like we did for #20950.

Last edited 19 months ago by ryan (previous) (diff)

comment:5 ryan19 months ago

No to mention it is pretty much the same as domain_exists() and get_id_from_blogname().

ryan19 months ago

Down the rabbit hole

comment:6 ryan19 months ago

  • Register blog-id-cache group as global
  • Introduce clean_blog_cache() so we can run it independently of refresh_blog_details() which assumes the blog still exists and get_blog_details() can be called.
  • Don't db escape cache keys
  • Return 0 for all failures in get_blog_id_from_url()
  • clean_blog_cache() after dropping tables in wpmu_delete_blog() to make sure the cache is for real cleaned.

ryan19 months ago

Unit tests

comment:7 ryan19 months ago

  • Resolution set to fixed
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.