Make WordPress Core

Opened 7 months ago

Closed 6 months ago

Last modified 4 months ago

#60032 closed defect (bug) (fixed)

$body_id global variable return value to string not int.

Reported by: upadalavipul's profile upadalavipul Owned by: sergeybiryukov's profile SergeyBiryukov
Milestone: 6.5 Priority: normal
Severity: normal Version: 4.3
Component: General Keywords: has-patch changes-requested
Focuses: coding-standards Cc:

Description (last modified by mukesh27)

I have reviewed the media.php file code and found the $body_id global variable returns the value int and the comment code mentions string values. So think we need to update the comment code here.

Files:

  1. wp-admin/includes/media.php

Attachments (1)

60032.patch (408 bytes) - added by upadalavipul 7 months ago.

Download all attachments as: .zip

Change History (8)

@upadalavipul
7 months ago

#1 @mukesh27
7 months ago

  • Keywords has-patch commit added
  • Milestone changed from Awaiting Review to 6.5
  • Version set to 5.3

Hi there! Thanks for ticket and patch.

Good catch, introduced in [45602] / #47632.

Happy to commit but don't have access. @SergeyBiryukov Could you please commit this one?

#2 @SergeyBiryukov
7 months ago

  • Keywords changes-requested added; commit removed
  • Version changed from 5.3 to 4.3

Hi there, thanks for the patch!

  • The suggested change does not look correct to me. $body_id is actually a string here, see where it's defined in media-upload.php or plugin-install.php.
  • $body_id is incorrectly documented as int in wp_iframe(). That should be updated to string instead.
  • This was not introduced in [45602] / #47632, but rather in [32643] / #32444.
Last edited 7 months ago by SergeyBiryukov (previous) (diff)

#3 @mukesh27
6 months ago

  • Description modified (diff)
  • Summary changed from $body_id global variable return value int not string. to $body_id global variable return value to string not int.

Thanks @SergeyBiryukov for checking the variable name suggest it's ID so i also think it was integer value 😉

#5 @SergeyBiryukov
6 months ago

  • Owner set to SergeyBiryukov
  • Resolution set to fixed
  • Status changed from new to closed

In 57181:

Docs: Consistently document the $body_id global as a string.

Includes declaring the global at the beginning of wp_iframe() and iframe_header().

Follow-up to [32642], [32643].

Props mukesh27, upadalavipul.
Fixes #60032.

@SergeyBiryukov commented on PR #5754:


6 months ago
#6

Thanks for the PR! Merged in r57181.

#7 @sukacynono1957
4 months ago

If the $body_id global variable in wp-admin/includes/media.php is returning a value of type integer, but the comments suggest it should return a string, then indeed, there might be a discrepancy between the expected and actual behavior.

To ensure clarity and consistency, you should update the comments to accurately reflect the type of value returned by the $body_id global variable.

Here's an example of how you might update the comment:

`php
/

  • ID attribute for the body element in the media library. *
  • @global int $body_id The ID attribute for the body element. This should be a string value. */

`

By making this change, you're helping to maintain code clarity and ensuring that other developers who work with this code understand the expected data type of the $body_id global variable.

Note: See TracTickets for help on using tickets.