Make WordPress Core

Opened 17 years ago

Closed 16 years ago

Last modified 16 years ago

#11624 closed enhancement (fixed)

Stop using $id global

Reported by: scribu Owned by:
Priority: normal Milestone: 3.1
Component: General Version:
Severity: normal Keywords: has-patch commit
Cc: Focuses:

Description

We already have the $post global which has the ID field.

So the $id global can be replaced with $post->ID everywhere.

Attachments (2)

11624.diff​ (1.4 KB ) - added by scribu 17 years ago.
Remove $id global from the_ID(), get_the_ID() and get_the_content()
11624.2.diff​ (7.3 KB ) - added by scribu 16 years ago.
Replace all instances

Download all attachments as: .zip

Change History (18)

@scribu
17 years ago

Remove $id global from the_ID(), get_the_ID() and get_the_content()

#1 @scribu
17 years ago

  • Cc scribu@… added

#2 @Denis-de-Bernardy
17 years ago

that's a big change which might potentially break a lot of themes and plugins.

#3 follow-up: @scribu
17 years ago

Such as?

#4 @scribu
17 years ago

Themes and plugins should be using get_the_ID() anyway.

#5 in reply to: ↑ 3 @Denis-de-Bernardy
17 years ago

Replying to scribu:

Such as?

Subscribe to comments comes to mind. Or at least it did in prior versions. I'm sure we'd find a few by looking.

#6 @prettyboymp
17 years ago

  • Keywords tested added

This shouldn't affect plugins that still use global $id since it will be still be set in setup_post_content(). Core functions will just stop using it. Its at least a small step in getting rid of all the globals.

#7 @nacin
17 years ago

  • Keywords commit added

This looks good.

#8 @nacin
17 years ago

  • Keywords tested commit removed

I would commit this, but we use $id in a lot more places than post.php. It's not a bad idea to reduce our dependence on globals even by one, but we might as well do it across the board if we are to do it.

#9 follow-up: @xibe
17 years ago

Should we create a ticket with the grand project of getting rid of all globals for 3.1?

#10 in reply to: ↑ 9 ; follow-up: @nacin
17 years ago

Replying to xibe:

Should we create a ticket with the grand project of getting rid of all globals for 3.1?

Heh, yea, that's not going to happen so easily. :)

#11 in reply to: ↑ 10 @xibe
17 years ago

Replying to nacin:

Heh, yea, that's not going to happen so easily. :)

I guess so :)
But that would most certainly appease a lot of developers who like to snark at the "code is poetry" motto.

#12 @nacin
17 years ago

  • Milestone 3.0 → Future Release

Moving out of 3.0 for now.

#13 @prettyboymp
17 years ago

  • Cc mpretty@… added

related #10471

@scribu
16 years ago

Replace all instances

#14 @scribu
16 years ago

  • Keywords commit added
  • Milestone Future Release → 3.1

Updated patch removes all instances of $id that I could find.

#15 @scribu
16 years ago

  • Resolution → fixed
  • Status new → closed

(In [15549]) Don't use the global anymore. Fixes #11624

#16 @nacin
16 years ago

(In [15563]) Adjustments to [15549]. See #11624.

Note: See TracTickets for help on using tickets.