Make WordPress Core

Opened 3 years ago

Closed 7 months ago

#16942 closed defect (bug) (fixed)

Dead code in add_query_arg()

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


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

Download all attachments as: .zip

Change History (10)

hakre3 years ago

Stripping the dead.

comment:1 scribu3 years ago

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

comment:2 scribu3 years ago

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

comment:3 dd323 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.

comment:4 hakre3 years ago

Related: #16958

comment:5 c3mdigital8 months ago

  • Keywords needs-refresh added

c3mdigital8 months ago

Refresh of Hakre's patch

comment:6 c3mdigital8 months ago

  • Keywords needs-refresh removed

comment:7 SergeyBiryukov8 months ago

  • Milestone changed from Awaiting Review to 3.7

comment:8 wonderboymusic7 months 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.