Opened 3 months ago

#13478 new Bug Report - General

mythweb search.php throws errors

Reported by: goldpizza44 Owned by: Stuart Auchterlonie
Priority: minor Milestone: needs_triage
Component: Plugin - MythWeb Version: v30-fixes
Severity: medium Keywords:
Cc: Ticket locked: no

Description

I installed Fedora 30 with:

Source RPM  : mythweb-30.0-2.fc30.src.rpm
Build Date  : Mon 04 Mar 2019 12:35:26 PM EST

I didn't see this error on earlier versions of Fedora, so this may be related to the php-fpm package on Fedora 30:

Source RPM  : php-7.3.8-1.fc30.src.rpm
Build Date  : Tue 30 Jul 2019 08:07:57 AM EDT

I find that attempting simple searches:

curl 'http://localhost/mythweb/tv/search?type=q&s=elementary&search=Search'

of programs was failing with a error in the /var/log/php-fpm/www-error.log of:

[25-Aug-2019 10:06:02 America/New_York] PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 16384 bytes) in /usr/share/mythweb/classes/Database/Query/mysqlicompat.php on line 69
[25-Aug-2019 10:06:02 America/New_York] PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 24576 bytes) in Unknown on line 0
[25-Aug-2019 10:06:02 America/New_York] PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 24576 bytes) in /usr/share/mythweb/includes/errors.php on line 191
[25-Aug-2019 10:06:02 America/New_York] PHP Warning:  Unknown: Cannot call session save handler in a recursive manner in Unknown on line 0

I initially changed the memory limit in PHP to 1Gb but it exhausted that as well. I debugged and found that PHP was showing errors in:

mythweb/modules/tv/search.php

Warning at /usr/share/mythweb/modules/tv/search.php, line 464:
!!NoTrans: preg_replace(): Compilation failed: invalid range in character class at offset 3!!

The line in question is search.php:464 (and lines 460 and 462) use a REGEX as shown:

return $db->escape('%'.preg_replace('/[\\s-_]+/', '%', $value).'%');

I am not a PHP expert, but I know regex and the '[\ \s-_]+' is causing the issue. I am not sure what the original intention of this REGEX is.

\\ would match a single \
\s would match whitespace
x-y would match a range of chars (in this case \s to _) which does make sense.

I changed to '[\s_-]+' which matches whitespace, an underscore, or a minus and that fixed my issue.

I also see errors on lines 347 and 361 regarding 'continue' which the error says should be 'continue 2'

This is a different error but seems to be a bug as well per:

https://www.php.net/manual/en/control-structures.continue.php


My changes:

 diff search.php /usr/share/mythweb/modules/tv/search.php
347c347
<                     continue;
---
>                     continue 2;
361c361
<                     continue;
---
>                     continue 2;
460c460
<                 return $db->escape(preg_replace('/[\\s-_]+/', '%', $value).'%');
---
>                 return $db->escape(preg_replace('/[\s_-]+/', '%', $value).'%');
462c462
<                 return $db->escape('%'.preg_replace('/[\\s-_]+/', '%', $value));
---
>                 return $db->escape('%'.preg_replace('/[\s_-]+/', '%', $value));
464c464
<                 return $db->escape('%'.preg_replace('/[\\s-_]+/', '%', $value).'%');
---
>                 return $db->escape('%'.preg_replace('/[\s_-]+/', '%', $value).'%');


Change History (0)

Note: See TracTickets for help on using tickets.