Add sniff to delete_option() + add_option
Maintainer antworten meist innerhalb von 1 Tag
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 35/100
Rechercherichtung
Beginne damit nachzuverfolgen, wie bestehende PHP_CodeSniffer-Sniffs Aufrufe von delete_option() und add_option() darstellen, einschließlich ihres Scopes und des Umgangs mit Option-Keys. Als abgeschlossen gilt die Meldung übereinstimmender Aufrufe im selben Scope unter Ausschluss anderer Scopes oder Keys sowie der Vorschlag, update_option() zu verwenden; das Issue nennt keine Zieldatei und keinen Test.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
What problem would the enhancement address for VIP?
As explained at https://github.com/woocommerce/woocommerce/pull/27696 there is a race condition when delete_option('foo') is followed by add_option('foo', '...').
Describe the solution you'd like
Having a sniff that looked for a delete_option() call followed by an add_option() immediately
or at some point within the same scope, for the same option key, could flag this race condition and suggest using update_option() instead.
What code should be reported as a violation?
function reset_settings() {
$defaults = get_default_settings();
delete_option( 'my_settings' );
add_option( 'my_settings', $defaults );
}
Likely to need some consideration of an option key that is using a variable.
What code should not be reported as a violation?
add_option()in a different scope.- different option key (including different variable).
- Vorherrschende Sprache
- PHP
- Sterne
- 261
- Forks
- 44
- Ø Merge
- 3 T. 9 Std.
- Gemergte PRs (30 T.)
- 10
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Keine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus Automattic/VIP-Coding-Standards
-
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 48/100
Automattic/VIP-Coding-Standards#876 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Breaking Change Type: Maintenance
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 35/100
Automattic/VIP-Coding-Standards#849 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 45/100
Automattic/VIP-Coding-Standards#832 ·
Maintainer antworten meist innerhalb von 1 Tag
-
WordPress.WP.AlternativeFunctions.file_system_operations error messages cannot be fixed anymoreOffen
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 48/100
Automattic/VIP-Coding-Standards#823 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Status: Awaiting feedback
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 45/100
Automattic/VIP-Coding-Standards#754 · 3 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in Automattic/VIP-Coding-Standards
Ähnliche Issues
-
GD decoder discards the finfo media type in mediaTypeByBinary() since 4.4.0Evtl. vergeben @lazerg hat das heute übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 77/100
Intervention/image#1556 ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug No Code Attached Yet
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 79/100
joomla/joomla-cms#48730 ·
Maintainer antworten meist innerhalb von 1 Tag
-
[Sync EN] Add more details about the array returned from openssl_x509_parse (php#2666) (#6013)Offensync-en
Schwierigkeit 1/5 1-3 Stunden Anfängerfreundlichkeit 76/100
Maintainer antworten meist innerhalb von 1 Tag
-
[Sync EN] Add more details about the array returned from openssl_x509_parse (php#2666) (#6013)Offensync-en
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
Maintainer antworten meist innerhalb von 1 Tag
-
Перевод устарел
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 65/100