Make WordPress Core

Changes between Initial Version and Version 4 of Ticket #60922


Ignore:
Timestamp:
04/05/2024 11:22:27 AM (21 months ago)
Author:
afercia
Comment:

After some debugging, turns out the root problem is that get_custom_logo() first retrives the logo ID by retrieving get_theme_mod( 'custom_logo' ). That option is set when setting a site logo but it's noc cleared when the image is deleted from the Media Library (or deleted from the file system).

get_custom_logo() does check if the$custom_logo_id exists but that comes from the site_logo option in the wp_options table. That value still exists even when the referenced image is deleted from the Media Library.

get_custom_logo() does _not_ check whether the image actually exists. When the image is deleted from the Media Library, wp_get_attachment_image returns an empty string and there's no check for that, the markup is rendered regardless and prints an empty string.

Looks like this function assumes the image does exist when the custom_logo/site_logo option is set, which isn't true.

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #60922

    • Property Component changed from General to Themes
  • Ticket #60922 – Description

    initial v4  
    2525- Go to the site editor, edit the Blog Home template.
    2626- Select the Site Logo block. Add it if necessary.
    27 - Do not set a logo image, leave the block empty and save.
     27- Set a logo image and save.
     28- Go to the Media Library and delete the image you set as site logo.
    2829- Go to the front end.
    2930- Inspect the source and observe the site logo link is an empty link.