HEX
Server: Apache/2.4.34 (Red Hat) OpenSSL/1.0.2k-fips
System: Linux WORDPRESS 3.10.0-1160.118.1.el7.x86_64 #1 SMP Thu Apr 4 03:33:23 EDT 2024 x86_64
User: digital (1020)
PHP: 7.2.24
Disabled: NONE
Upload Files
File: /datos/www/fabricas.colombiatrade.com.co/public_html/modules/contrib/rules/rules.install
<?php

/**
 * @file
 * Install, update and uninstall functions for the rules module.
 */

use Drupal\rules\Entity\ReactionRuleConfig;
use Drupal\rules\Entity\RulesComponentConfig;

/**
 * Update the "tags" property of Reaction Rules and Rules Components.
 *
 * Rules 8.x-3.0-alpha4 and earlier erroneously set the "tags" property to
 * "array(0 => '')" if there were no tags. The proper value is an empty array,
 * "array()".
 */
function rules_update_8301() {
  // Update Reaction Rules and Rules Components. Rules 8.x-3.0-alpha4 and
  // earlier erroneously sets the "tags" property to "array(0 => '')" if
  // there are no tags. The proper value is an empty array, "array()".
  $ids = \Drupal::entityQuery('rules_reaction_rule')->execute();
  foreach ($ids as $id) {
    $rule = ReactionRuleConfig::load($id);
    $tags = $rule->getTags();
    if ($tags == [0 => '']) {
      $rule->set('tags', []);
      $rule->save();
    }
  }
  $ids = \Drupal::entityQuery('rules_component')->execute();
  foreach ($ids as $id) {
    $rule = RulesComponentConfig::load($id);
    $tags = $rule->getTags();
    if ($tags == [0 => '']) {
      $rule->set('tags', []);
      $rule->save();
    }
  }

}