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 Responses to “Google XML Sitemaps - PHP Warning: preg_match(): Unknown modifier...”

    • Until we don’t release a new version including a fix, this line may need to be replace.
      We will keep this link updated.

  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

    • Hello there,
      This is already in our devs roadmap. At the moment we don’t have an ETA but we will keep this page updated.

  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.

  3. Have the same error on Version 4.6.11 and can confirm that this workaround solves the issue.

    An ETA would be helpful once it’s available

    • Thanks for your feedback John, I’m glad it helped. 🙂
      So far we don’t have an ETA but we will keep this page updated.
      Regards