最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

get posts - var_dump and print_r cause white screen

programmeradmin0浏览0评论

My template is very simple:

get_header();
$new_p = get_posts(array('post_type' => 'post', 'numberposts' => 6));
get_footer();

whenever I put var_dump($new_p); or print_r($new_p); below $new_p = get_posts(array('post_type' => 'post', 'numberposts' => 6));, it gives me the white screen.

Why on Earth would it do it??

This code is OK, though:

var_dump(wp_get_recent_posts(array('post_type' => 'tdlrm_store_item', 'numberposts' => 8), OBJECT));

Any ideas?

My template is very simple:

get_header();
$new_p = get_posts(array('post_type' => 'post', 'numberposts' => 6));
get_footer();

whenever I put var_dump($new_p); or print_r($new_p); below $new_p = get_posts(array('post_type' => 'post', 'numberposts' => 6));, it gives me the white screen.

Why on Earth would it do it??

This code is OK, though:

var_dump(wp_get_recent_posts(array('post_type' => 'tdlrm_store_item', 'numberposts' => 8), OBJECT));

Any ideas?

Share Improve this question edited Feb 8, 2021 at 10:02 Tom J Nowell 61k7 gold badges79 silver badges148 bronze badges asked Feb 8, 2021 at 9:25 ArtemArtem 3152 silver badges13 bronze badges 2
  • 2 Have you checked your PHP error log for the error message? – Tom J Nowell Commented Feb 8, 2021 at 10:02
  • 1 Oh my, I didn't. I have the display_errors on, and was just expecting to see the errors on page, completely forgot to check the error log. How dumb is that ( I've found what caused the problem, though. Someone had put a base64-encoded image into the post content, and the system ran out of memory trying to output it. – Artem Commented Feb 8, 2021 at 11:02
Add a comment  | 

1 Answer 1

Reset to default 2

Actually, memory was exhausted. Someone has copy-pasted an actual 2MB base64-encoded image into the post content, var_dump was trying to output it. Had to delete the image via PHPMyAdmin, because the WP editor won't open. Once it had been deleted, the problem was gone.

发布评论

评论列表(0)

  1. 暂无评论