Automattic / Automattic/VIP-Coding-Standards

New sniff: Flag unusable query parameters

未关闭
#731 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
Type: Enhancement
主要语言
PHP
星标
261
派生
44
平均合并
19 分钟
30 天内合并 PR
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 摘要。