Opened 2 years ago

Last modified 2 years ago

#16942 new defect

Dead code in add_query_arg()

Reported by: hakre Owned by:
Priority: normal Milestone: Awaiting Review
Component: General Version: 3.1
Severity: trivial Keywords: has-patch commit
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 (1)

16942.patch (685 bytes) - added by hakre 2 years ago.
Stripping the dead.

Download all attachments as: .zip

Change History (5)

hakre2 years ago

Stripping the dead.

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

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

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

Related: #16958

Note: See TracTickets for help on using tickets.