Make WordPress Core

Opened 4 years ago

Closed 4 years ago

Last modified 13 months ago

#55888 closed defect (bug) (fixed)

False is not a valid cache key in community-events

Reported by: malthert Owned by: davidbaumwald
Priority: normal Milestone: 6.1
Component: Administration Version:
Severity: normal Keywords: has-patch changes-requested dev-feedback
Cc: Focuses:

Description

There is a check for this in 1 place, but it's missing in the other, causing issues, since you pass an invalid type to get_site_transient

Attachments (1)

55888-1.patch​ (1.0 KB ) - added by rafiahmedd 4 years ago.
2nd opinion.

Download all attachments as: .zip

Change History (12)

This ticket was mentioned in ​PR #2764 on ​WordPress/wordpress-develop by ​kkmuffme.


4 years ago
#1

  • Keywords has-patch added

Add check for false transient key, which is not a valid key.
There already is a check in the other place in this file where this is used. Added it in all places now.

Trac ticket: https://core.trac.wordpress.org/ticket/55888#ticket

#2 @SergeyBiryukov
4 years ago

  • Component General → Administration
  • Milestone Awaiting Review → 6.1

#3 @davidbaumwald
4 years ago

  • Owner set to davidbaumwald
  • Status new → reviewing

#4 @malthert
4 years ago

Early return is better and also it's more in the style of the existing check of line 337

This ticket was mentioned in ​Slack in #core by audrasjb. ​View the logs.


4 years ago

#6 @audrasjb
4 years ago

  • Keywords changes-requested added

Reviewed during today's bug scrub.

The patch doesn’t look bad, but I’d say the last comment would probably provide a better approach for this (early return when falsey transient key).

#7 @costdev
4 years ago

  • Keywords dev-feedback added

Calling get_site_transient( false ) doesn't cause any notices/warning/errors. What am I missing?

#8 @malthert
4 years ago

@costdev I can't remember it's been a while and I don't have time to dive into it atm, but since the function arg is string, we shouldn't pass a bool at least.

#9 @davidbaumwald
4 years ago

  • Severity critical → normal

#10 @davidbaumwald
4 years ago

  • Resolution → fixed
  • Status reviewing → closed

In 54338:

Administration: Guard against false transient key in get_cached_events().

Inside WP_Community_Events::get_cached_events(), WP_Community_Events::get_events_transient_key() is used to retrieve the transient key name, based on the user's location. However, the transient key can potentially return false, resulting in a call to get_site_transient() with the $key being false.

This change first attempts to evaluate and guard against a false return from WP_Community_Events::get_events_transient_key(). The result is an early false return from WP_Community_Events::get_cached_events().

Props malthert, rafiahmedd, audrasjb, costdev.
Fixes #55888.

​@SergeyBiryukov commented on ​PR #2764:


13 months ago
#11

Thanks for the PR! This was merged in r54338.

Note: See TracTickets for help on using tickets.