Make WordPress Core

Opened 14 years ago

Closed 11 years ago

#16942 closed defect (bug) (fixed)

Dead code in add_query_arg()

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

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 14 years ago.
Stripping the dead.
16942-refresh.patch (610 bytes) - added by c3mdigital 11 years ago.
Refresh of Hakre's patch

Download all attachments as: .zip

Change History (10)

@hakre
14 years ago

Stripping the dead.

#1 @scribu
14 years ago

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

#2 @scribu
14 years ago

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

#3 @dd32
14 years ago

  • Keywords commit added
  • Severity changed from normal to 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
14 years ago

Related: #16958

#5 @c3mdigital
11 years ago

  • Keywords needs-refresh added

@c3mdigital
11 years ago

Refresh of Hakre's patch

#6 @c3mdigital
11 years ago

  • Keywords needs-refresh removed

#7 @SergeyBiryukov
11 years ago

  • Milestone changed from Awaiting Review to 3.7

#8 @wonderboymusic
11 years ago

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

In 25333:

Remove dead code in add_query_arg().

Props hakre, c3mdigital.
Fixes #16942.

Note: See TracTickets for help on using tickets.