Automattic / Automattic/VIP-Coding-Standards

New Sniff: wp_get_post_revisions memory issues

Đang mở
#468 2 bình luận 0 reaction 0 người được giao Xem trên GitHub
Standard: VIP-Go Type: Enhancement
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?
`wp_get_post_revisions` can be problematic because it loads the entire post object for each revision. I've seen this in CLI commands and other places, where you might be looping through a set of posts, and then suddenly have to load the entire post objects for every revision a post has. If those revisions are large and numerous - it quickly fails.

Related trac: https://core.trac.wordpress.org/ticket/34560

## Describe the solution you'd like
We should suggest they only get the IDs for the revisions instead of the whole object:

```
wp_get_post_revisions( $post->ID, array( 'fields' => 'ids' ) );
```

## What code should be reported as a violation?

Anything that doesn't have the fields argument, like:

```
wp_get_post_revisions( $post->ID );
```

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

Getting the `ids` field or other fields instead of the whole object.
```
wp_get_post_revisions( $post->ID, array( 'fields' => 'ids' ) );
```

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Hướng nghiên cứu

Bắt đầu với các ví dụ wp_get_post_revisions vi phạm và được cho phép trong issue, cùng với ticket WordPress Trac được liên kết. Hoàn thành có nghĩa là các lệnh gọi không có đối số fields được báo cáo, trong khi các lệnh gọi yêu cầu ids hoặc một giá trị fields khác thì không được báo cáo.

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
performance, tooling
Loại issue
Tính năng
Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Đặc tả rõ ràng
Mức phù hợp với người mới
38/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.