Make WordPress Core

Opened 2 years ago

Closed 2 years ago

Last modified 15 months ago

#61408 closed defect (bug) (fixed)

Site logo returns image attachment when no logo is defined

Reported by: greenshady Owned by: joedolson
Priority: normal Milestone: 6.6
Component: Themes Version: 6.6
Severity: normal Keywords: has-patch needs-testing has-test-info commit
Cc: Focuses:

Description

This is a regression that seems to have cropped up from this change: https://core.trac.wordpress.org/changeset/58213

Ticket: https://core.trac.wordpress.org/ticket/60922

To reproduce, activate the Twenty Twenty-Four theme on your site but do not set a logo for the site. Ensure that the Site Logo block is in the header (it is by default).

View any page on the site, you shouldn't see a logo. View an image attachment page, the logo will use the attached image instead.

Attachments (5)

logo-attachment-incorrect.jpeg (203.5 KB ) - added by greenshady 2 years ago.
Attachment image being used for site logo.
61408.diff (530 bytes ) - added by joedolson 2 years ago.
Only execute wp_attachment_is_image if there is a value in site logo.
Patch testing.png (255.9 KB ) - added by krupajnanda 2 years ago.
Screenshot at Jun 12 11-49-40 PM.png (23.5 KB ) - added by hmbashar 2 years ago.
showing this error, doesn't work for me
61408.2.diff (545 bytes ) - added by rajinsharwar 2 years ago.
Refreshed patch

Download all attachments as: .zip

Change History (13)

@greenshady
2 years ago

Attachment image being used for site logo.

#1 @joedolson
2 years ago

  • Keywords needs-patch added
  • Milestone Awaiting Review6.6
  • Owner set to joedolson
  • Status newaccepted

The problem is that has_custom_logo() now uses wp_attachment_is_image(), which uses the $post global if no value is passed. Need to exit earlier in has_custom_logo().

@joedolson
2 years ago

Only execute wp_attachment_is_image if there is a value in site logo.

#2 @joedolson
2 years ago

  • Keywords has-patch needs-testing added; needs-patch removed

Thanks, @greenshady!

#3 @greenshady
2 years ago

Tested the patch. It's working for me.

#4 @krupajnanda
2 years ago

  • Keywords needs-testing-info added

Hey @greenshady

I was trying to test this fix. I am not pretty sure if I have followed the correct steps. But it would be helpful if you could point me to the right direction. Please check the attachment and what it says.

@hmbashar
2 years ago

showing this error, doesn't work for me

@rajinsharwar
2 years ago

Refreshed patch

#5 @rajinsharwar
2 years ago

  • Keywords has-testing-info commit added; needs-testing-info removed

Hi @hmbashar @krupajnanda, it seems that the lines upstream have changed compared to patch 61408. Please try this new one: 61408.2.diff

I have tested the fix myself, and it does seem to work.
Before: https://img001.prntscr.com/file/img001/0UfuioC6S52gevPD9b6e3A.png
After: https://img001.prntscr.com/file/img001/XnyPGihER4arXIVLxCbHOg.png

Note for testers: Please know that attachment pages are disabled by default from 6.4. So, you can visit wp-admin/options.php on your site, search for wp_attachment_pages_enabled, and change the option to 1 to enable the option for testing.

As it's a relatively small change, and already has two manual tests, marking this for commit.

#6 @joedolson
2 years ago

  • Resolutionfixed
  • Status acceptedclosed

In 58407:

Themes: Fix attachment rendered as site logo on attachment page.

Fix issue where the attachment thumbnail would be rendered as the site logo on attachment single templates if no site logo is set. Avoid calling wp_attachment_is_image() with no value, since that function will fallback to the global $post variable. Follow up to [58213]. See #60922.

Props greenshady, krupajnanda, hmbashar, rajinsharwar, joedolson.
Fixes #61408.

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


2 years ago

#8 @wordpressdotorg
15 months ago

  • Keywords has-test-info added; has-testing-info removed
Note: See TracTickets for help on using tickets.