function tmgmt_extension_suit_update_8001 in TMGMT Extension Suite 8
Same name and namespace in other branches
- 8.3 tmgmt_extension_suit.install \tmgmt_extension_suit_update_8001()
- 8.2 tmgmt_extension_suit.install \tmgmt_extension_suit_update_8001()
Add missing job item hashes.
File
- ./
tmgmt_extension_suit.install, line 18 - Update function for the tmgmt_extension_suit module.
Code
function tmgmt_extension_suit_update_8001() {
// Apply field to an entity. Field is defined in
// tmgmt_extension_suit_entity_base_field_info() hook.
\Drupal::service('entity.definition_update_manager')
->applyUpdates();
$query = db_select('tmgmt_job_item', 'tji');
$result = $query
->condition('tji.plugin', 'content')
->condition('tji.item_type', 'node')
->fields('tji', [
'tjiid',
])
->orderBy('tji.changed', 'DESC')
->groupBy('tji.tjiid')
->groupBy('tji.changed')
->execute();
if ($items = $result
->fetchCol()) {
$job_items = JobItem::loadMultiple($items);
foreach ($job_items as $job_item) {
$hash = _tmgmt_extension_suit_get_job_item_hash($job_item);
$job_item
->set('tes_source_content_hash', $hash);
$job_item
->save();
}
}
}