Automattic / Automattic/VIP-Coding-Standards

New sniff: Flag unusable query parameters

オープン
#731 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
Type: Enhancement
主要言語
PHP
スター
261
フォーク
44
平均マージ
19分
マージ済み PR(30日)
1

説明

## What problem would the enhancement address for VIP?
On VIP, a selection of [query parameters](https://docs.wpvip.com/technical-references/caching/page-cache/#h-query-parameters) are stripped at the edge which so that the URLs are not cached as separate variants. These parameters are predominantly used for analytics. As such, `$_GET['...']` and other ways of reading the values of the query parameters will return `null` on production and non-production environments.

Helping customers to appreciate when a query parameter isn't going to work on a VIP-hosted site, should save some hours of debugging.

## Describe the solution you'd like

A new sniff to create violations when trying to read one of the documented parameters.

## What code should be reported as a violation?
Substitute `foo` for any of the params in the documentation.

```php
$_GET['foo']
$_REQUEST['foo']
filter_input( INPUT_GET, 'foo'[, ...[, ...]])

$qs = filter_input_array( INPUT_GET[, ...[, ...]] )
$qs['foo'];
```

There may well be other ways to retrieve query string parameters as well.

## What code should *not* be reported as a violation?

```php
$_GET['not-foo']
$_POST['foo']
filter_input( INPUT_POST, 'foo'[, ...[, ...]])
```

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

実装ファイルもテストも指定されていません。まず既存の PHP_CodeSniffer の sniff とそのテストを見つけ、次に文書化されている VIP パラメーターと一覧にある GET のアクセス形式を比較してください。その形式が報告され、POST と無関係なパラメーターは報告されなければ完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
php
領域
tooling
issue の種類
機能追加
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
45/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。