Automattic / Automattic/VIP-Coding-Standards

New sniff: Flag unusable query parameters

Offen
#731 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Type: Enhancement
Vorherrschende Sprache
PHP
Sterne
261
Forks
44
Ø Merge
19 Min.
Gemergte PRs (30 T.)
1

Beschreibung

## 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'[, ...[, ...]])
```

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Es wird keine Implementierungsdatei oder kein Test genannt. Beginne damit, vorhandene PHP_CodeSniffer-Sniffs und deren Tests zu finden, und vergleiche dann die dokumentierten VIP-Parameter mit den aufgeführten GET-Zugriffsformen; als erledigt gilt die Aufgabe, wenn diese Formen gemeldet werden, POST und nicht zugehörige Parameter jedoch nicht.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
php
Bereich
tooling
Issue-Typ
Feature
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
45/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.