WordPress / gutenberg

The Block Editor project for WordPress and beyond. Plugin is available from the official repository.
https://wordpress.org/gutenberg/
Other
10.32k stars 4.12k forks source link

[Site Logo] Previous theme's site_logo renders instead of current custom_logo (when switching themes) #64523

Open hellofromtonya opened 4 weeks ago

hellofromtonya commented 4 weeks ago

Description

This issue was originally reported in WordPress Core Trac https://core.trac.wordpress.org/ticket/53817.

An edge case was identified in Trac 53770 where when a previous theme's logo renders when switching back to a theme.

WordPress 5.8 introduced new functionality (in _override_custom_logo_theme_mod()) where, when exists, the 'site_logo' option is used instead of the theme's 'custom_logo' mod. See Trac 53247 / r51091.

What happens when switching back to a theme that has a custom logo stored in its theme mod option? It no longer renders that theme's custom logo but instead renders what's stored in the 'site_logo' option. The 'site_logo' was set by the previous theme.

This is a breaking change from 5.7.2 and earlier.

In other words, is this an edge case that needs to be fixed OR is this new behavior by design?

Step-by-step reproduction instructions

  1. Go to Appearance > Themes > Activate the Twenty Twenty-One theme.
  2. Go to Customize > Site Identity > Select logo (under Logo setting) and set the logo.
  3. Click Publish.
  4. Exit Customizer.
  5. Go Themes > Activate the Twenty Twenty theme.
  6. Go to Customize > Site Identify > Select logo but select a different logo this time.
  7. Click Publish.
  8. Exist Customizer.
  9. Go back and active the Twenty Twenty-One theme again.
  10. Go back to Customize > Site Identity.

Notice:

Screenshots, screen recording, code snippet

WordPress 5.7.2: TT1 has a white logo and TT has a black logo 53817-5 7 2

In WP 5.7.2. as shown in the gif:

WordPress 5.8.0: TT1 should have a white logo and TT should have a black logo 53817-5 8 0

In WP 5.8.0 as shown in gif:

Environment info

No response

Please confirm that you have searched existing issues in the repo.

Please confirm that you have tested with all plugins deactivated except Gutenberg.

hellofromtonya commented 4 weeks ago

Copying @sebastienserre's comment from the Trac ticket to here:

I've just commented at https://make.wordpress.org/core/2024/08/07/agenda-dev-chat-wednesday-aug-7-2024/

Is the idea to synchronize, have the same value in site_logo and custom_logo shouldn't be the easiest way to solve this issue ?

-- edit --- The sync is done at https://github.com/WordPress/wordpress-develop/blob/9928cd6bcb35d14a700e3930355b6703f0cb4dc8/src/wp-includes/blocks/site-logo.php#L137-L155 but it seems overidden by https://github.com/WordPress/wordpress-develop/blob/9928cd6bcb35d14a700e3930355b6703f0cb4dc8/src/wp-includes/blocks/site-logo.php#L130