Commit c9fbbf18 authored by Damien McKenna's avatar Damien McKenna Committed by Damien McKenna
Browse files

Issue #3106384 by DamienMcKenna: Remove the NOODP option on ROBOTS tag.

parent 3d5b0bad
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@ Metatag 8.x-1.x-dev, 2023-xx-xx
#3360836 by DamienMcKenna: Nodewords migration triggers wrong API.
#3106383 by DamienMcKenna, fathima.asmat: Remove the NOYDIR option on ROBOTS
  tag.
#3106384 by DamienMcKenna: Remove the NOODP option on ROBOTS tag.


Metatag 8.x-1.23, 2023-05-12
+22 −16
Original line number Diff line number Diff line
@@ -185,9 +185,9 @@ function metatag_post_update_convert_author_data(&$sandbox) {
}

/**
 * Remove 'noydir' option from meta tag entity fields.
 * Remove 'noydir', 'noodp' ROBOTS options from meta tag entity fields.
 */
function metatag_post_update_remove_robots_noydir(&$sandbox) {
function metatag_post_update_remove_robots_noydir_noodp(&$sandbox) {
  $entity_type_manager = \Drupal::entityTypeManager();
  $database = \Drupal::database();

@@ -246,7 +246,10 @@ function metatag_post_update_remove_robots_noydir(&$sandbox) {
            $query->addField($table, 'langcode');
            $query->addField($table, $field_value_field);
            $query->condition('bundle', $bundle, '=');
            $query->condition($field_value_field, '%noydir%', 'LIKE');
            $db_or = $query->orConditionGroup();
            $db_or->condition($field_value_field, '%noodp%', 'LIKE');
            $db_or->condition($field_value_field, '%noydir%', 'LIKE');
            $query->condition($db_or);
            $result = $query->execute();
            $records = $result->fetchAll();

@@ -294,9 +297,11 @@ function metatag_post_update_remove_robots_noydir(&$sandbox) {
      // only the overridden tags in $new_tags.
      $tags = metatag_data_decode($record->$field_value_field);
      if (!empty($tags['robots'])) {
        $robots_array = explode(', ', $tags['robots']);
        $robots_array = array_diff($robots_array, ['noydir']);
        $tags['robots'] = implode(', ', $robots_array);
        $new_robots = $old_robots = explode(', ', $tags['robots']);
        $new_robots = array_diff($new_robots, ['noodp']);
        $new_robots = array_diff($new_robots, ['noydir']);
        if ($old_robots != $new_robots) {
          $tags['robots'] = implode(', ', $new_robots);

          $tags_string = serialize($tags);
          $database->update($field_table)
@@ -308,6 +313,7 @@ function metatag_post_update_remove_robots_noydir(&$sandbox) {
            ->condition('langcode', $record->langcode)
            ->execute();
        }
      }
      $counter++;
      $current_record++;
    }
+0 −1
Original line number Diff line number Diff line
@@ -157,7 +157,6 @@ class Robots extends MetaNameBase {
      'nofollow' => $this->t('nofollow - Prevents search engines from following links on this page.'),
      'noarchive' => $this->t('noarchive - Prevents cached copies of this page from appearing in search results.'),
      'nosnippet' => $this->t('nosnippet - Prevents descriptions from appearing in search results, and prevents page caching.'),
      'noodp' => $this->t('noodp - Blocks the <a href=":opendirectory">Open Directory Project</a> description from appearing in search results.', [':opendirectory' => 'http://www.dmoz.org/']),
      'noimageindex' => $this->t('noimageindex - Prevent search engines from indexing images on this page.'),
      'notranslate' => $this->t('notranslate - Prevent search engines from offering to translate this page in search results.'),
    ];
+0 −2
Original line number Diff line number Diff line
@@ -224,7 +224,6 @@ $connection->insert('nodewords')
        'noindex' => 0,
        'follow' => 0,
        'noarchive' => 0,
        'noodp' => 0,
      ),
      'use_default' => 0,
    )),
@@ -299,7 +298,6 @@ $connection->insert('nodewords')
        'noarchive' => 0,
        'nofollow' => 0,
        'noindex' => 0,
        'noodp' => 0,
        'nosnippet' => 0,
      ),
      'use_default' => 0,
+0 −2
Original line number Diff line number Diff line
@@ -85,7 +85,6 @@ $connection->insert('metatag')
          'follow' => 0,
          'noarchive' => 0,
          'nosnippet' => 0,
          'noodp' => 0,
          'noimageindex' => 0,
          'notranslate' => 0,
        ],
@@ -108,7 +107,6 @@ $connection->insert('metatag')
          'follow' => 0,
          'noarchive' => 0,
          'nosnippet' => 0,
          'noodp' => 0,
          'noimageindex' => 0,
          'notranslate' => 0,
        ],