The error message:

Warning: preg_quote() expects parameter 1 to be string, array given in Drupal\oembed\Provider\ConfigEntityProvider::Drupal\oembed\Provider\{closure}() (line 98 of modules/contrib/oembed/src/Provider/ConfigEntityProvider.php).

The following lines of code somehow end up with the value of $scheme that is not a string.

  private static function schemeToRegex($schemes, $capture_subpatterns = FALSE) {
    $patterns = array_map(function ($scheme) use ($capture_subpatterns) {
      return str_replace('\*', $capture_subpatterns ? '(.*)' : '.*', preg_quote($scheme, '#'));
    }, $schemes);

    return '#'. implode('|', $patterns) .'#i';
  }

it seems like the expected structure is that $schemes is an array of strings, but for some reason it contains an array of arrays.

CommentFileSizeAuthor
#5 preg-quote-error-2826119-5.patch3.36 KBmarthinal

Issue fork oembed-2826119

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

jwilson3 created an issue. See original summary.

jwilson3’s picture

Issue summary: View changes
jwilson3’s picture

Issue summary: View changes

It seems like array_map expects the use parameter to be an array, but $capture_subpatterns is a boolean, this might be part of the problem.

jwilson3’s picture

Issue summary: View changes

Hrm. nevermind the above. I get how "use" works now, but It seems like the expected structure is that $schemes is an array of strings, but for some reason it contains an array of arrays.

marthinal’s picture

Status: Active » Needs review
StatusFileSize
new3.36 KB

$schemes is an array of arrays. I've created patch where we use all the regex to verify if the url is supported and obtain the provider name. We can refactor and improve but anyway we need to fix this problem because the current method schemeToRegex() is not working as expected.

AstonVictor made their first commit to this issue’s fork.

astonvictor’s picture

Status: Needs review » Fixed

thanks for the patch.

merged and fixed.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.