Skip navigation

Resolved

Reported for: WPML Multilingual CMS 4.6.9

Resolved in: WPML Multilingual CMS 4.6.13

Topic Tags: Bug

Overview of the issue

Under some scenarios, you may encounter a PHP warning like the following, particularly if you are using Google XML Sitemaps plugin alongside our system

Warning: preg_match(): Unknown modifier '-' in /wp-content/plugins/sitepress-multilingual-cms/inc/absolute-links/absolute-links.class.php on line 186

Workaround

Please, make sure of having a full backup of your site before proceeding.

  • Open …/wp-content/plugins/sitepress-multilingual-cms/inc/absolute-links/absolute-links.class.php file.
  • Look for line 186.
  • Replace:
    if ( preg_match( "!^$match!", $request_match, $matches ) || preg_match( "!^$match!", urldecode( $request_match ), $matches ) ) {
    
  • With:
    if ( preg_match( "~^$match~", $request_match, $matches ) || preg_match( "~^$match~", urldecode( $request_match ), $matches ) ) {
    

комментариев 11 на “Google XML Sitemaps - PHP Warning: preg_match(): Unknown modifier...”

  1. When we can expect a permanent fix? it is showing the same error again and again after the updates. Please let me know

    message repeated 71 times: [ PHP Warning: preg_match(): Unknown modifier ‘-‘ in /wp-content/plugins/sitepress-multilingual-cms/inc/absolute-links/absolute-links.class.php on line 186]

    PHP Warning: preg_match(): Unknown modifier ‘-‘ in /wp-content/plugins/sitepress-multilingual-cms/inc/absolute-links/absolute-links.class.php on line 186

    message repeated 5 times: [ PHP Warning: preg_match(): Unknown modifier ‘-‘ in /wp-content/plugins/sitepress-multilingual-cms/inc/absolute-links/absolute-links.class.php on line 186]

    PHP Warning: preg_match(): Unknown modifier ‘-‘ in /wp-content/plugins/sitepress-multilingual-cms/inc/absolute-links/absolute-links.class.php on line 186

  2. I tried this fix, then got a blank site and:

    PHP Fatal error: Uncaught Error: Call to a member function get_requested_lang() on null in /home/wp-content/plugins/sitepress-multilingual-cms/sitepress.class.php:1131
    Stack trace:
    #0 /home/wp-content/plugins/sitepress-multilingual-cms/classes/utilities/class-wpml-locale.php(106): SitePress->get_current_language()
    #1 /home/wp-content/plugins/sitepress-multilingual-cms/sitepress.class.php(3479): WPML_Locale->locale()
    #2 /home/wp-includes/class-wp-hook.php(324): SitePress->locale_filter()
    #3 /home/wp-includes/plugin.php(205): WP_Hook->apply_filters()
    #4 /home/wp-includes/l10n.php(80): apply_filters()
    #5 /home/wp-includes/l10n.php(165): get_locale()
    #6 /home/wp-includes/l10n.php(951): determine_locale()
    #7 /home/wp-includes/class-wp-fatal-error-handler.php(49): load_default_textdomain()
    #8 [internal function]: WP_Fatal_Error_Handler->handle()
    #9 {main}
    thrown in /home/wp-content/plugins/sitepress-multilingual-cms/sitepress.class.php on line 1131

    I reverted and got the site back.