WordPress.org

Make WordPress Core

Opened 2 years ago

Last modified 11 days ago

#49086 new defect (bug)

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

Reported by: 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 2 years ago.

Download all attachments as: .zip

Change History (5)

#1 @henry.wright
2 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 either set to 0 or the option is deleted.

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
}
Last edited 2 years ago by henry.wright (previous) (diff)

@henry.wright
2 years ago

#2 @henry.wright
2 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
16 months ago

  • Component changed from General to Media

#4 @r-a-y
11 days 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 11 days ago by r-a-y (previous) (diff)
Note: See TracTickets for help on using tickets.