Make WordPress Core

Opened 5 years ago

Last modified 3 years ago

#49086 new defect (bug)

The "site_icon" option isn't always removed when the site icon is deleted

Reported by: henrywright's profile henry.wright Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Media Keywords: dev-feedback has-patch
Focuses: Cc:

Description

If you delete the site icon image by going to Media > Library, the "site_icon" option isn't deleted from the database. Note the option is deleted if you go Appearance > Customize and remove the icon through the Site Identity tab.

Attachments (1)

49086.diff (641 bytes) - added by henry.wright 5 years ago.

Download all attachments as: .zip

Change History (5)

#1 @henry.wright
5 years ago

  • Keywords dev-feedback added

I should clarify.

When the site icon is removed by Appearance > Customize, the value of site_icon in the options table is set to 0.

When the site icon image file is deleted by Media > Library, the value of site_icon in the options table remains something like 55.

This causes problems because the result of get_option( 'site_option' ) is used to determine if a site icon exists in functions like get_site_icon_url().

$site_icon_id = get_option( 'site_icon' );
 
if ( $site_icon_id ) {
    // This does not guarantee the site icon exists because of the bug above
}
Version 0, edited 5 years ago by henry.wright (next)

@henry.wright
5 years ago

#2 @henry.wright
5 years ago

  • Keywords has-patch added

49086.diff deletes the site_icon option if the media file used for the site icon is deleted.

#3 @sabernhardt
4 years ago

  • Component changed from General to Media

#4 @r-a-y
3 years ago

I can confirm this bug. If a site icon is manually deleted from the Media Library, the corresponding site_icon option is never updated or removed.

Although a developer can use has_site_icon() to determine the existence of a site icon, some might use get_option( 'blog_icon' ) directly as @henry.wright mentions.

Last edited 3 years ago by r-a-y (previous) (diff)
Note: See TracTickets for help on using tickets.