4 июл. 2016 г.

Wordpress: 500 internal Server error на заглавной странице

Начиная с этого поста я буду стараться публиковать записи, которые могут быть полезны англоязычным посетителям, на двух языках.

Столкнулся с тем ошибкой "500 internal server error" при открытии одного из сайтов под управлением Wordpress. Открытие других страниц по прямым ссылкам происходит нормально, а home page дает эту ошибку.
/var/log/apache2/error.log содержит записи "PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted". Все посты на эту тему указывают на то, что нужно увеличить объем доступной PHP памяти. Но у меня ему и так выделено 128MB. На других сайтах на том же хосте все нормально в этом плане.
Полез посмотреть базу сайта. Оказалось, что активная тема в одном из своих PHP-скриптов содержит строку:
add_custom_field('Bannerimage', 1)
, которая выполняется при каждом обращении к базе постов. Это привело к созданию более 44 тысяч записей в таблице wp_postmeta и, соответственно, заполнению всей выделенной памяти.
Судя по всему это какой-то дебажный код, попавший в релизную сборку темы. Строчку удалил, все такие записи из этой таблицы вычистил, сайт проверил. Домашняя страница стала открываться нормально.



Just faced "500 internal server error" error while opening front page of one of Wordpress powered sites. Other pages including admin dashboard are opened successfully by direct links. File /var/log/apache2/error.log contains lines like "PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted". All internet posts point that the reason is low memory accessible to PHP. Although it is already configured 128MB for PHP. Furthermore, other sites on same host work well.
Decided to discover site' database. And figured out that wp_postmeta table contains more than 44K records which contain Bannerimage value. Short search through sources revealed that active theme contains in one of PHP files line like:
add_custom_field('Bannerimage', 1)
, which executed every referencing to posts table. Sequentially all memory was grabbed while reading the table.
Seems it some debug code was left in release build. I've removed the code line, deleted all such records from the table, checked site. Home page now is opened well.

Комментариев нет:

Отправить комментарий