Automattic / Automattic/VIP-Coding-Standards
New sniff: Flag unusable query parameters
- Ngôn ngữ chính
- PHP
- Star
- 261
- Fork
- 44
- Merge trung bình
- 19 phút
- Pull request đã merge (30 ngày)
- 1
Mô tả
## 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'[, ...[, ...]])
```
Hướng dẫn đóng góp
Hướng nghiên cứu
Không có tệp triển khai hoặc bài kiểm thử nào được nêu tên. Hãy bắt đầu bằng cách xác định các sniff PHP_CodeSniffer hiện có và các bài kiểm thử của chúng, sau đó so sánh các tham số VIP được ghi chép với các dạng truy cập GET được liệt kê; được xem là hoàn thành khi các dạng đó được báo cáo, còn POST và các tham số không liên quan thì không.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- php
- Lĩnh vực
- tooling
- Loại issue
- Tính năng
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 45/100