Установка и настройка PHPBB3.

PhpBB < 3.0.8 Ошибка при генерации капчи и разрастание лога ошибок

Александр » 05 апр 2017, 20:32

Примерно полгода назад я как-то копался в дампе своего форума и обнаружил большую таблицу с логами одной и той же ошибки, связанной с генерацией GD-капчи в файле /includes/captcha/captcha_gd.php, кстати, эта же проблема как потом прочитал, актуальна и для 3D wave captcha.
В дампе базы это выглядело примерно так:
Код: Выделить всё
(21877, 2, 1, 0, 0, 0, '91.200.12.141', 1475024077, 'LOG_IMAGE_GENERATION_ERROR', 'a:3:{i:0;s:32:"/includes/captcha/captcha_gd.php";i:1;i:80;i:2;s:41:"mt_rand(): max(-7) is smaller than min(0)";}'),
(21878, 2, 1, 0, 0, 0, '91.200.12.141', 1475024077, 'LOG_IMAGE_GENERATION_ERROR', 'a:3:{i:0;s:32:"/includes/captcha/captcha_gd.php";i:1;i:80;i:2;s:42:"mt_rand(): max(-11) is smaller than min(0)";}'),
(21879, 2, 1, 0, 0, 0, '89.218.186.82', 1475028279, 'LOG_IMAGE_GENERATION_ERROR', 'a:3:{i:0;s:32:"/includes/captcha/captcha_gd.php";i:1;i:80;i:2;s:41:"mt_rand(): max(-5) is smaller than min(0)";}'),
(21880, 2, 1, 0, 0, 0, '89.218.186.82', 1475028279, 'LOG_IMAGE_GENERATION_ERROR', 'a:3:{i:0;s:32:"/includes/captcha/captcha_gd.php";i:1;i:80;i:2;s:41:"mt_rand(): max(-5) is smaller than min(0)";}'),
(21881, 2, 1, 0, 0, 0, '89.218.186.82', 1475028279, 'LOG_IMAGE_GENERATION_ERROR', 'a:3:{i:0;s:32:"/includes/captcha/captcha_gd.php";i:1;i:80;i:2;s:41:"mt_rand(): max(-7) is smaller than min(0)";}'),
(21882, 2, 1, 0, 0, 0, '89.218.186.82', 1475028279, 'LOG_IMAGE_GENERATION_ERROR', 'a:3:{i:0;s:32:"/includes/captcha/captcha_gd.php";i:1;i:80;i:2;s:41:"mt_rand(): max(-8) is smaller than min(0)";}'),
(21883, 2, 1, 0, 0, 0, '89.218.186.82', 1475028279, 'LOG_IMAGE_GENERATION_ERROR', 'a:3:{i:0;s:32:"/includes/captcha/captcha_gd.php";i:1;i:80;i:2;s:42:"mt_rand(): max(-11) is smaller than min(0)";}'),
(21884, 2, 1, 0, 0, 0, '89.218.186.82', 1475028279, 'LOG_IMAGE_GENERATION_ERROR', 'a:3:{i:0;s:32:"/includes/captcha/captcha_gd.php";i:1;i:80;i:2;s:42:"mt_rand(): max(-17) is smaller than min(0)";}'),
(21885, 2, 1, 0, 0, 0, '89.218.186.82', 1475028279, 'LOG_IMAGE_GENERATION_ERROR', 'a:3:{i:0;s:32:"/includes/captcha/captcha_gd.php";i:1;i:80;i:2;s:42:"mt_rand(): max(-26) is smaller than min(0)";}'),
(21886, 2, 1, 0, 0, 0, '185.31.162.245', 1475033132, 'LOG_IMAGE_GENERATION_ERROR', 'a:3:{i:0;s:32:"/includes/captcha/captcha_gd.php";i:1;i:80;i:2;s:41:"mt_rand(): max(-1) is smaller than min(0)";}'),
(21887, 2, 1, 0, 0, 0, '185.31.162.245', 1475033132, 'LOG_IMAGE_GENERATION_ERROR', 'a:3:{i:0;s:32:"/includes/captcha/captcha_gd.php";i:1;i:80;i:2;s:41:"mt_rand(): max(-1) is smaller than min(0)";}'),
(21888, 2, 1, 0, 0, 0, '185.31.162.245', 1475046108, 'LOG_IMAGE_GENERATION_ERROR', 'a:3:{i:0;s:32:"/includes/captcha/captcha_gd.php";i:1;i:80;i:2;s:41:"mt_rand(): max(-1) is smaller than min(0)";}'),
(21889, 2, 1, 0, 0, 0, '185.31.162.245', 1475046108, 'LOG_IMAGE_GENERATION_ERROR', 'a:3:{i:0;s:32:"/includes/captcha/captcha_gd.php";i:1;i:80;i:2;s:41:"mt_rand(): max(-1) is smaller than min(0)";}'),
(21890, 2, 1, 0, 0, 0, '185.31.162.245', 1475046108, 'LOG_IMAGE_GENERATION_ERROR', 'a:3:{i:0;s:32:"/includes/captcha/captcha_gd.php";i:1;i:80;i:2;s:41:"mt_rand(): max(-1) is smaller than min(0)";}'),
(21891, 2, 1, 0, 0, 0, '185.31.162.245', 1475046108, 'LOG_IMAGE_GENERATION_ERROR', 'a:3:{i:0;s:32:"/includes/captcha/captcha_gd.php";i:1;i:80;i:2;s:41:"mt_rand(): max(-1) is smaller than min(0)";}'),
(21892, 2, 1, 0, 0, 0, '185.31.162.245', 1475046108, 'LOG_IMAGE_GENERATION_ERROR', 'a:3:{i:0;s:32:"/includes/captcha/captcha_gd.php";i:1;i:80;i:2;s:41:"mt_rand(): max(-2) is smaller than min(0)";}'),
(21893, 2, 1, 0, 0, 0, '185.31.162.245', 1475046108, 'LOG_IMAGE_GENERATION_ERROR', 'a:3:{i:0;s:32:"/includes/captcha/captcha_gd.php";i:1;i:80;i:2;s:41:"mt_rand(): max(-3) is smaller than min(0)";}'),
(21894, 2, 1, 0, 0, 0, '185.31.162.245', 1475046108, 'LOG_IMAGE_GENERATION_ERROR', 'a:3:{i:0;s:32:"/includes/captcha/captcha_gd.php";i:1;i:80;i:2;s:41:"mt_rand(): max(-6) is smaller than min(0)";}'),
(21895, 2, 1, 0, 0, 0, '89.223.104.101', 1475057765, 'LOG_IMAGE_GENERATION_ERROR', 'a:3:{i:0;s:32:"/includes/captcha/captcha_gd.php";i:1;i:80;i:2;s:41:"mt_rand(): max(-3) is smaller than min(0)";}'),
(21896, 2, 1, 0, 0, 0, '89.223.104.101', 1475057765, 'LOG_IMAGE_GENERATION_ERROR', 'a:3:{i:0;s:32:"/includes/captcha/captcha_gd.php";i:1;i:80;i:2;s:41:"mt_rand(): max(-4) is smaller than min(0)";}'),
(21897, 2, 1, 0, 0, 0, '89.223.104.101', 1475057765, 'LOG_IMAGE_GENERATION_ERROR', 'a:3:{i:0;s:32:"/includes/captcha/captcha_gd.php";i:1;i:80;i:2;s:41:"mt_rand(): max(-5) is smaller than min(0)";}'),
(21898, 2, 1, 0, 0, 0, '89.223.104.101', 1475057765, 'LOG_IMAGE_GENERATION_ERROR', 'a:3:{i:0;s:32:"/includes/captcha/captcha_gd.php";i:1;i:80;i:2;s:41:"mt_rand(): max(-6) is smaller than min(0)";}'),
(21899, 2, 1, 0, 0, 0, '89.223.104.101', 1475057765, 'LOG_IMAGE_GENERATION_ERROR', 'a:3:{i:0;s:32:"/includes/captcha/captcha_gd.php";i:1;i:80;i:2;s:41:"mt_rand(): max(-9) is smaller than min(0)";}'),
(21900, 2, 1, 0, 0, 0, '89.223.104.101', 1475057765, 'LOG_IMAGE_GENERATION_ERROR', 'a:3:{i:0;s:32:"/includes/captcha/captcha_gd.php";i:1;i:80;i:2;s:42:"mt_rand(): max(-13) is smaller than min(0)";}'),
(21901, 2, 1, 0, 0, 0, '89.223.104.101', 1475057765, 'LOG_IMAGE_GENERATION_ERROR', 'a:3:{i:0;s:32:"/includes/captcha/captcha_gd.php";i:1;i:80;i:2;s:42:"mt_rand(): max(-21) is smaller than min(0)";}'),
(21902, 2, 1, 0, 0, 0, '176.10.99.204', 1475072976, 'LOG_IMAGE_GENERATION_ERROR', 'a:3:{i:0;s:32:"/includes/captcha/captcha_gd.php";i:1;i:80;i:2;s:41:"mt_rand(): max(-4) is smaller than min(0)";}'),
(21903, 2, 1, 0, 0, 0, '176.10.99.204', 1475072976, 'LOG_IMAGE_GENERATION_ERROR', 'a:3:{i:0;s:32:"/includes/captcha/captcha_gd.php";i:1;i:80;i:2;s:41:"mt_rand(): max(-4) is smaller than min(0)";}'),
(21904, 2, 1, 0, 0, 0, '176.10.99.204', 1475072976, 'LOG_IMAGE_GENERATION_ERROR', 'a:3:{i:0;s:32:"/includes/captcha/captcha_gd.php";i:1;i:80;i:2;s:41:"mt_rand(): max(-5) is smaller than min(0)";}'),
(21905, 2, 1, 0, 0, 0, '176.10.99.204', 1475072976, 'LOG_IMAGE_GENERATION_ERROR', 'a:3:{i:0;s:32:"/includes/captcha/captcha_gd.php";i:1;i:80;i:2;s:41:"mt_rand(): max(-7) is smaller than min(0)";}'),
(21906, 2, 1, 0, 0, 0, '176.10.99.204', 1475072976, 'LOG_IMAGE_GENERATION_ERROR', 'a:3:{i:0;s:32:"/includes/captcha/captcha_gd.php";i:1;i:80;i:2;s:41:"mt_rand(): max(-9) is smaller than min(0)";}'),
(21907, 2, 1, 0, 0, 0, '176.10.99.204', 1475072976, 'LOG_IMAGE_GENERATION_ERROR', 'a:3:{i:0;s:32:"/includes/captcha/captcha_gd.php";i:1;i:80;i:2;s:42:"mt_rand(): max(-14) is smaller than min(0)";}'),
(21908, 2, 1, 0, 0, 0, '176.10.99.204', 1475072976, 'LOG_IMAGE_GENERATION_ERROR', 'a:3:{i:0;s:32:"/includes/captcha/captcha_gd.php";i:1;i:80;i:2;s:42:"mt_rand(): max(-22) is smaller than min(0)";}'),
(21909, 2, 1, 0, 0, 0, '91.200.12.106', 1475081883, 'LOG_IMAGE_GENERATION_ERROR', 'a:3:{i:0;s:32:"/includes/captcha/captcha_gd.php";i:1;i:80;i:2;s:41:"mt_rand(): max(-1) is smaller than min(0)";}'),
(21910, 2, 1, 0, 0, 0, '91.200.12.106', 1475081883, 'LOG_IMAGE_GENERATION_ERROR', 'a:3:{i:0;s:32:"/includes/captcha/captcha_gd.php";i:1;i:80;i:2;s:41:"mt_rand(): max(-1) is smaller than min(0)";}'),
(21911, 2, 1, 0, 0, 0, '91.200.12.106', 1475081883, 'LOG_IMAGE_GENERATION_ERROR', 'a:3:{i:0;s:32:"/includes/captcha/captcha_gd.php";i:1;i:80;i:2;s:41:"mt_rand(): max(-1) is smaller than min(0)";}'),
(21912, 2, 1, 0, 0, 0, '91.200.12.106', 1475081883, 'LOG_IMAGE_GENERATION_ERROR', 'a:3:{i:0;s:32:"/includes/captcha/captcha_gd.php";i:1;i:80;i:2;s:41:"mt_rand(): max(-2) is smaller than min(0)";}'),
(21913, 2, 1, 0, 0, 0, '91.200.12.106', 1475081883, 'LOG_IMAGE_GENERATION_ERROR', 'a:3:{i:0;s:32:"/includes/captcha/captcha_gd.php";i:1;i:80;i:2;s:41:"mt_rand(): max(-3) is smaller than min(0)";}'),
(21914, 2, 1, 0, 0, 0, '91.200.12.106', 1475081883, 'LOG_IMAGE_GENERATION_ERROR', 'a:3:{i:0;s:32:"/includes/captcha/captcha_gd.php";i:1;i:80;i:2;s:41:"mt_rand(): max(-5) is smaller than min(0)";}')

В админке форума в разделе «Обслуживание – Лог ошибок» были эти же данные на русском вида
Ошибка при создании изображения
» Ошибка в /includes/captcha/captcha_gd.php в строке 80: mt_rand(): max(-4) is smaller than min(0)

Разрастание базы форума PhpBB3, ошибка генерации капчи

И таких строк было много.. ещё это тогда я поставил себе в план разобраться с этим, просто времени не хватало, а проблема казалась не очень критичной.
Вот, на днях удалось её решить.
Наверное, она касается многих форумов версии ниже 3.08 и работающих на версиях PHP выше 5.3.3. Просто не все же ведь в коде ковыряются, а разрастание базы данных происходит медленно (но верно!). У меня за 3 года образовались примерно 30.000 записей с этой ошибкой, что давало примерно 5 Мб "веса", учитывая, что вся база примерно в 2 раза больше весила. У кого форумы большие с десятками – сотнями мегабайт постов, % конечно будет наверное, по менее (но не факт, многое от активности ботов зависит), и они могут тоже не догадываться, о том, что в недрах дампа можно найти такое вот интересное...
В общем, по сообщению понятно, что в файле /includes/captcha/captcha_gd.php функция mt_rand() иногда получает второй аргумент, который меньше первого. PHP до версий 5.3.3 это дело проглатывал, но в поздних версиях стал генерировать ошибку, соответственно, и капча при этом не генерировалась.
У меня не было времени глубоко залезать в код в поисках причины создания и передачи таких неправильных параметров функции mt_rand, поэтому искал ответ в Google.
В рунете по этому поводу вообще ничего не нашел, хорошо, нашелся ответ на англоязычном форуме:
https://tracker.phpbb.com/browse/PHPBB3-10042, там же дана ссылка на репозиторий с патчем:
https://github.com/phpbb/phpbb/pull/103
Ну, и конечно, после патчинга имеет смысл логи ошибок наконец очистить, если вы раньше этого не делали.
Александр
 
Сообщения: 397
Зарегистрирован: 20 мар 2014, 17:05

Вернуться в Форум PHPBB (PHP Bulleting Board)