Add sniff to check that WP is killed after wp_(safe_)redirect

Open
#1,205 9 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
48/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
php
Domain
tooling

Research direction

Start by reading the existing WordPress.VIP.RestrictedFunctions.wp_redirect_wp_redirect sniff and the referenced wp_redirect() and wp_safe_redirect() documentation. Implement coverage for calls followed by die(), exit, or wp_die(), including the conditional example; done means both redirect functions are checked without duplicating the existing error message.

Written by the indexing model from the issue text.

Description

Component: Extra Focus: WP interoperability Type: Enhancement

Add sniff to check that any call to wp_redirect() and wp_safe_redirect() is followed by a call to die(), exit or wp_die().

The call is allowed to be conditional.

wp_redirect( $url );
exit;

if ( wp_redirect( $url ) ) {
    exit;
}

Refs:

Reminder: if/when this sniff is pulled, the error message for WordPress.VIP.RestrictedFunctions.wp_redirect_wp_redirect can be shortened to avoid message duplication.

Suggestions for additional functions which should be checked for this welcome!

Dominant language
PHP
Stars
2.8k
Forks
521
Avg merge
5d 20h
Merged PRs (30d)
1

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from WordPress/WordPress-Coding-Standards

All issues in WordPress/WordPress-Coding-Standards

Similar issues

More PHP issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.