• Hello,

    Relevanssi generates a PHP Warning:

    PHP Warning:
    preg_match(): Unknown modifier '/' in /.../plugins/relevanssi/lib/utils.php on line 811

    with the request :

    GET /?s=https%3A%2F%2Fr.—.com%2Fwatch.php%3Fvid%3D0f75a740f

    Can you fix this?

    Thanks!

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Mikko Saari

    (@msaari)

    I can’t reproduce this issue; this search should not cause this error message. The code on line 811 (assuming you’re on the latest version) should not run at all with this search query.

    Can you perhaps provide a full stacktrace of the error? I’d need to see where this error originated, what called the relevanssi_stripos() function and with what parameters.

    With just this information, there’s nothing I can do about this.

    Thread Starter DreamOn11

    (@dreamon11)

    Thanks.

    Here a the full stacktrace:


    PHP Warning:
    preg_match(): Unknown modifier ‘/’ in /data/www/xxx/releases/20210318083313/web/app/plugins/relevanssi/lib/utils.php on line 811

    Request:
    GET /?s=https%3A%2F%2Fr.xxx.com%2Fwatch.php%3Fvid%3D0f75a740f

    Backtrace:
    #(0): App\{closure}(2, ‘preg_match(): Unknown modifier ‘/”, ‘/data/www/xxx/releases/20210318083313/web/app/plugins/relevanssi/lib/utils.php’, ‘811’, Array)
    #1 /data/www/xxx/releases/20210318083313/web/app/plugins/relevanssi/lib/search.php(1002): relevanssi_do_excerpt(WP_Post, ‘https://r.xxx.com/watch.php?vid=0f75a740f’, ‘450’, ‘chars’)
    #2 /data/www/xxx/releases/20210318083313/web/app/plugins/relevanssi/lib/search.php(94): relevanssi_do_query(WP_Query)
    #3 /data/www/xxx/releases/20210318083313/web/wp/wp-includes/class-wp-hook.php(292): relevanssi_query(NULL, WP_Query)
    #4 /data/www/xxx/releases/20210318083313/web/wp/wp-includes/plugin.php(255): apply_filters(NULL, Array)
    #5 /data/www/xxx/releases/20210318083313/web/wp/wp-includes/class-wp-query.php(2957): apply_filters_ref_array(‘posts_pre_query’, Array)
    #6 /data/www/xxx/releases/20210318083313/web/wp/wp-includes/class-wp-query.php(3465): get_posts()
    #7 /data/www/xxx/releases/20210318083313/web/wp/wp-includes/class-wp.php(629): query(Array)
    #8 /data/www/xxx/releases/20210318083313/web/wp/wp-includes/class-wp.php(752): query_posts()
    #9 /data/www/xxx/releases/20210318083313/web/wp/wp-includes/functions.php(1291): main(”)
    #10 /data/www/xxx/releases/20210318083313/web/wp/wp-blog-header.php(16): wp()
    #11 /data/www/xxx/releases/20210318083313/web/index.php(5): require(‘/data/www/xxx/releases/20210318083313/web/wp/wp-blog-header.php’)

    Plugin Author Mikko Saari

    (@msaari)

    Ah, I see, this happens in excerpt-building. Is this a legit search in the first place, is this something that is meaningful to search on your site or is it just spam? If it’s spam, I would recommend just blocking it.

    Anyway, I’ll fix this in the next version. If you want a quick fix, replace this in lib/utils.php

    $needle_regex = str_replace(
    	array( '?', '*' ),
    	array( '.', '.*' ),
    	$needle
    );

    with this:

    $needle_regex = str_replace(
    	array( '?', '*' ),
    	array( '.', '.*' ),
    	preg_quote( $needle, '/' )
    );
    Thread Starter DreamOn11

    (@dreamon11)

    I think it is spam, but it’s always better when the code doesn’t generate warnings or errors 🙂

    Thanks for the fix!

    When you talk about blocking, what do you mean? Relevanssi can perform this?

    Great plugin and support 😉

    Plugin Author Mikko Saari

    (@msaari)

    Agree about the warnings.

    I was thinking of keyword blocking (like this).

    (I’ve been thinking about integrating something like that within Relevanssi, either built-in or as an add-on plugin, an easy way to do keyword blocking, blocking searches with Chinese characters or cyrillic text and so on. That might be helpful.)

    Thread Starter DreamOn11

    (@dreamon11)

    (I’ve been thinking about integrating something like that within Relevanssi, either built-in or as an add-on plugin, an easy way to do keyword blocking, blocking searches with Chinese characters or cyrillic text and so on. That might be helpful.)

    It’s a good idea! It will be useful!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘PHP Warning: preg_match(): Unknown modifier ‘/’’ is closed to new replies.