21.05.2026 | Michael Ebert Do bulk updates as a batch job custom_module.install <?php /** * Update node title of all nodes. */ function custom_module_update_10001(&$sandbox) { // Define you entity type. $entity_type = 'node'; // Load the entity type manager service. $entity_type_manager = \Drupal::service('entity_type.manager'); // Get the storage for the entity type. $entity_storage = $entity_type_manager->getStorage($entity_type); if (!isset($sandbox['total'])) { $all_entity_ids = $entity_storage->getQuery() ->accessCheck() ->execute(); $sandbox['total'] = count($all_entity_ids); $sandbox['current'] = 0; if (empty($sandbox['total'])) { $sandbox['#finished'] = 1; return; } } $entities_per_batch = 25; $entity_ids = $entity_storage->getQuery() ->accessCheck() ->range($sandbox['current'], $entities_per_batch) ->execute(); if (empty($entity_ids)) { $sandbox['#finished'] = 1; return; } // Optionally, perform operations with the loaded entities. // For example, load and modify each node and set a new title. foreach ($entity_ids as $entity_id) { $entity = $entity_storage->load($entity_id); if ($entity->hasField('title')) { $entity->setTitle('New Title'); } $entity->save(); $sandbox['current']++; } \Drupal::messenger() ->addMessage($sandbox['current'] . ' users processed.'); if ($sandbox['current'] >= $sandbox['total']) { $sandbox['#finished'] = 1; } else { $sandbox['#finished'] = ($sandbox['current'] / $sandbox['total']); } } Issue:You have to update many entities during development and the server runs out of memory.Solution:Update entities in batch mode. Copy-paste the snippet code. Zurück zur DevBit-Übersicht Weitere DevBits 21.11.2025 | Peter Majmesku PHP 8.5 New Features: Pipe Operator and URI Extension The New URI Extension php_8.5_examples_uri_extension.php <?php ##### URI Extension ##### // PHP 8.4 way $components = parse_url('https://php.net/releases/8.4/en.php'); var_dump($components['host']); // string(7) "php.net" // PHP 8.5 URI Extension use Uri\Rfc3986\Uri; $uri = new Uri('https://php.net/releases/8.5/en.php'); var_dump($uri->getHost()); // string(7) "php.net" The New Pipe Operator php_8.5_pipe_operator.php <?php ##### Pipe Operator ##### // PHP 8.4 way $title = ' PHP 8.5 Released '; $slug = strtolower( str_replace('.', '', str_replace(' ', '-', trim($title) ) ) ); var_dump($slug); // string(15) "php-85-released" // PHP 8.5 Pipe Operator $title = ' PHP 8.5 Released '; $slug = $title |> trim(...) |> (fn($str) => str_replace(' ', '-', $str)) |> (fn($str) => str_replace('.', '', $str)) |> strtolower(...); var_dump($slug); // string(15) "php-85-released" php 13.11.2025 | Dominik Wille Don't list a widget for a field type. CustomWidget.php public static function isApplicable(FieldDefinitionInterface $field_definition) { if (isset($field_definition->getDisplayOptions('form')['type'])) { return $field_definition->getDisplayOptions('form')['type'] == 'slot_content_weights'; } return FALSE; } php widgets fields