临下班,小客户期望我的 Widgets 能够修改一些内容。
点完 Save 按钮,都准备关机了,却看到菊花转呀转,始终始终保存不上。
得,扔个修改后的 index.html 上去,回家再说吧。

审查元素 Console 报了这个:

[Error] Failed to load resource: the server responded with a status of 500 (Internal Server Error) (admin-ajax.php, line 0)

先用了重启大法、停插件大法,都无效之后。
开始搜 admin-ajax 500 ,结果吐出来一堆垃圾文章。
甚至傻乎乎的照做,重装了 php5-curl 还是解决不了问题。

沉住气,查了一下 error.log (出问题果然还是要先查日志)

[Sun Sep 06 20:51:42.828453 2015] [:error] [pid 2987] [client 211.151.229.101:58371] PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 4915229 bytes) in /cuikai/www/html/wp-includes/wp-db.php on line 1173, referer: http://uicss.cn/wp-admin/widgets.php

再去查 wp-db.php on line 1173
得到一个线索,wp升级的时候会产生很多杂七杂八的玩意,导致后台各种慢。
顺藤摸瓜找到一篇 7 年前的文章,是通过直接删数据库冗余的临时解决方案。
略过不表。

说一下怎么治根。

第一步:
打开 wp-includes/taxonomy.php file 跳转到 4448 行

wp_schedule_single_event( ‘wp_batch_split_terms’, time() + MINUTE_IN_SECONDS );
修改为
wp_schedule_single_event( time() + MINUTE_IN_SECONDS, ‘wp_batch_split_terms’ );
以绝后患。

第二步:
创建一个 /wp-content/mu-plugins/fix.php 内容如下:

<?php function clear_bad_cron_entries() { // Fix incorrect cron entries for term splitting $cron_array = _get_cron_array(); if ( isset( $cron_array[‘wp_batch_split_terms’] ) ) { unset( $cron_array[‘wp_batch_split_terms’] ); _set_cron_array( $cron_array ); } } clear_bad_cron_entries();

在浏览器地址栏访问一下该文件 uicss.cn/wp-content/mu-plugins/fix.php

ok 大功告成。
捎带着,后台各种操作也变快了,噗哈哈哈。