WordPress.org

Make WordPress Core

Opened 5 weeks ago

Last modified 5 weeks ago

#53540 new defect (bug)

Use $image[0] instead of $image['0'] in media file

Reported by: chintan1896 Owned by:
Milestone: 5.9 Priority: normal
Severity: normal Version:
Component: Media Keywords: has-patch good-first-bug
Focuses: Cc:

Description

I think we need to use $image[0] instead of $image['0'] in media file.
When called for srcset that time we have used $image[0] Please check here. https://github.com/WordPress/WordPress/blob/master/wp-includes/media.php#L1218

Attachments (1)

53540.diff (537 bytes) - added by chintan1896 5 weeks ago.

Download all attachments as: .zip

Change History (6)

@chintan1896
5 weeks ago

#1 @desrosj
5 weeks ago

  • Milestone changed from Awaiting Review to 5.9

#2 follow-up: @adamsilverstein
5 weeks ago

@chintan1896 thanks for the patch. I'm curious why you noticed this issue, did it create a warning or error in your system? Or was it more something you noticed when reviewing the source code?

When using arrays, PHP will automatically cast the '0' string to 0 int, so this is more of a cosmetic fix than functional, is that right?

#3 in reply to: ↑ 2 @chintan1896
5 weeks ago

Replying to adamsilverstein:

@chintan1896 thanks for the patch. I'm curious why you noticed this issue, did it create a warning or error in your system? Or was it more something you noticed when reviewing the source code?

When using arrays, PHP will automatically cast the '0' string to 0 int, so this is more of a cosmetic fix than functional, is that right?

I have noticed when reviewing the source code. Yes, you are right this is a cosmetic fix. I have suggested for code consistency. We have used 0 in https://github.com/WordPress/WordPress/blob/master/wp-includes/media.php#L1218

This ticket was mentioned in Slack in #core-media by antpb. View the logs.


5 weeks ago

#5 @antpb
5 weeks ago

  • Keywords good-first-bug added
Note: See TracTickets for help on using tickets.