Verified Commit cc759090 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3414568 by dimitriskr, smustgrave, quietone: Replace preg_match() with...

Issue #3414568 by dimitriskr, smustgrave, quietone: Replace preg_match() with str_starts_with()/str_ends_with() or similar

(cherry picked from commit 4d5abf7f)
parent d332de97
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -174,7 +174,7 @@ public function getTestClasses($extension = NULL, array $types = []) {
      }
      catch (MissingGroupException $e) {
        // If the class name ends in Test and is not a migrate table dump.
        if (preg_match('/Test$/', $classname) && !str_contains($classname, 'migrate_drupal\Tests\Table')) {
        if (str_ends_with($classname, 'Test') && !str_contains($classname, 'migrate_drupal\Tests\Table')) {
          throw $e;
        }
        // If the class is @group annotation just skip it. Most likely it is an
+1 −1
Original line number Diff line number Diff line
@@ -249,7 +249,7 @@ protected function getFieldInfo($node_type) {
      foreach ($this->fieldInfo as $type => $fields) {
        foreach ($fields as $field => $info) {
          foreach ($info as $property => $value) {
            if ($property == 'db_columns' || preg_match('/_settings$/', $property)) {
            if ($property == 'db_columns' || str_ends_with($property, '_settings')) {
              $this->fieldInfo[$type][$field][$property] = unserialize($value);
            }
          }
+3 −3
Original line number Diff line number Diff line
@@ -883,13 +883,13 @@ protected function introspectIndexSchema($table) {
      ':table_name' => $full_name,
    ])->fetchAll();
    foreach ($result as $row) {
      if (preg_match('/_pkey$/', $row->index_name)) {
      if (str_ends_with($row->index_name, '_pkey')) {
        $index_schema['primary key'][] = $row->column_name;
      }
      elseif (preg_match('/_key$/', $row->index_name)) {
      elseif (str_ends_with($row->index_name, '_key')) {
        $index_schema['unique keys'][$row->index_name][] = $row->column_name;
      }
      elseif (preg_match('/_idx$/', $row->index_name)) {
      elseif (str_ends_with($row->index_name, '_idx')) {
        $index_schema['indexes'][$row->index_name][] = $row->column_name;
      }
    }
+1 −1
Original line number Diff line number Diff line
@@ -347,7 +347,7 @@ public function testUpdateShowDisabledThemes() {
    // Make sure all the update_test_* themes are disabled.
    $extension_config = $this->config('core.extension');
    foreach ($extension_config->get('theme') as $theme => $weight) {
      if (preg_match('/^update_test_/', $theme)) {
      if (str_starts_with($theme, 'update_test_')) {
        $extension_config->clear("theme.$theme");
      }
    }
+1 −1
Original line number Diff line number Diff line
@@ -428,7 +428,7 @@ public function testRenderNullPager() {
    $view->pager = NULL;
    $output = $view->render();
    $output = (string) \Drupal::service('renderer')->renderRoot($output);
    $this->assertEquals(0, preg_match('/<ul class="pager">/', $output), 'The pager is not rendered.');
    $this->assertStringNotContainsString('<ul class="pager">', $output);
  }

  /**
Loading