Make WordPress Core

Opened 16 years ago

Closed 13 years ago

#16942 closed defect (bug) (fixed)

Dead code in add_query_arg()

Reported by: hakre Owned by: wonderboymusic
Priority: normal Milestone: 3.7
Component: General Version: 3.1
Severity: trivial Keywords: has-patch commit
Cc: Focuses:

Description

As it just has been checked that $uri contains at least one ?, then exploding $uri on ? with a limit of 2 must return two elements, right?

	if ( strpos( $uri, '?' ) !== false ) {
		$parts = explode( '?', $uri, 2 );
		if ( 1 == count( $parts ) ) {

So the if clause can never be true, the code is dead.

Attachments (2)

16942.patch​ (685 bytes ) - added by hakre 16 years ago.
Stripping the dead.
16942-refresh.patch​ (610 bytes ) - added by c3mdigital 13 years ago.
Refresh of Hakre's patch

Download all attachments as: .zip

Change History (10)

@hakre
16 years ago

Stripping the dead.

#1 @scribu
16 years ago

Shouldn't add_query_arg() be using parse_url() ?

#2 @scribu
16 years ago

I guess not, since parse_url() doesn't work with relative URLs.

#3 @dd32
16 years ago

  • Keywords commit added
  • Severity normal → trivial

Looks right with the edgecases of ?test and test.php?, an empty item will be returned before, and after respectively, resulting in always having a count of 2.

#4 @hakre
16 years ago

Related: #16958

#5 @c3mdigital
13 years ago

  • Keywords needs-refresh added

@c3mdigital
13 years ago

Refresh of Hakre's patch

#6 @c3mdigital
13 years ago

  • Keywords needs-refresh removed

#7 @SergeyBiryukov
13 years ago

  • Milestone Awaiting Review → 3.7

#8 @wonderboymusic
13 years ago

  • Owner set to wonderboymusic
  • Resolution → fixed
  • Status new → closed

In 25333:

Remove dead code in add_query_arg().

Props hakre, c3mdigital.
Fixes #16942.

Note: See TracTickets for help on using tickets.