Automattic / Automattic/VIP-Coding-Standards
switch_to_blog() - flag for missing subsequent restore_current_blog()
- 主要语言
- PHP
- 星标
- 261
- 派生
- 44
- 平均合并
- 19 分钟
- 30 天内合并 PR
- 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 中的两个示例添加覆盖:报告没有后续 restore_current_blog() 的 switch,不要报告已恢复的情况。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- php
- 领域
- tooling
- Issue 类型
- 功能
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 45/100