Automattic / Automattic/VIP-Coding-Standards

switch_to_blog() - flag for missing subsequent restore_current_blog()

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

説明

## Describe the solution you'd like

From https://github.com/Automattic/VIP-Coding-Standards/pull/649#discussion_r606174833, it would be worth flagging that `restore_current_blog()` should be called subsequently (if not already).

## What code should be reported as a violation?

```
function switch_blog() {
$id = get_current_blog_id();

if ( $id === 2 ) {
return;
}

switch_to_blog( 2 );
}
```

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

```
function switch_blog() {
$id = get_current_blog_id();

if ( $id === 2 ) {
return;
}

switch_to_blog( 2 );
restore_current_blog();
}
```

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

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

調査の方向性

switch_to_blog() を処理する既存のルールまたは sniff を見つけ、呼び出しの対応が取れているかをどのように判定しているかを確認します。Issue の 2 つの例に対するカバレッジを追加します。後続の restore_current_blog() がない switch は報告し、復元されるケースは報告しないようにします。

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

評価

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

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

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