Skip to content
Snippets Groups Projects
Commit 9f92d6df authored by Igor Biki's avatar Igor Biki
Browse files

ISTWCMS-7275: Improve type definition for batch context parameters

Updated function signatures to explicitly define $context and related parameters as arrays. This enhances code clarity and enforces stricter type safety, reducing potential errors during batch operations.
parent 97bc5ed7
No related branches found
No related tags found
No related merge requests found
...@@ -55,7 +55,7 @@ function uw_custom_blocks_post_update_references_block_titles_updates_12(&$sandb ...@@ -55,7 +55,7 @@ function uw_custom_blocks_post_update_references_block_titles_updates_12(&$sandb
* The batch context array, which is updated with initial counts and a status * The batch context array, which is updated with initial counts and a status
* message for the batch process. * message for the batch process.
*/ */
function _references_block_titles_updates_batch_start($count, &$context): void { function _references_block_titles_updates_batch_start($count, array &$context): void {
$context['results']['nodes_count'] = $count; $context['results']['nodes_count'] = $count;
$context['results']['nodes_processed'] = 0; $context['results']['nodes_processed'] = 0;
$context['results']['nodes_updated'] = 0; $context['results']['nodes_updated'] = 0;
...@@ -77,12 +77,8 @@ function _references_block_titles_updates_batch_start($count, &$context): void { ...@@ -77,12 +77,8 @@ function _references_block_titles_updates_batch_start($count, &$context): void {
* @param array $context * @param array $context
* A reference to the batch context array that tracks progress and statistics, * A reference to the batch context array that tracks progress and statistics,
* including the number of nodes and revisions processed and updated. * including the number of nodes and revisions processed and updated.
*
* @return void
* This function does not return a value. It modifies the $context array
* directly and updates the node and its revisions in-place.
*/ */
function _references_block_titles_updates_batch_update($nid, &$context): void { function _references_block_titles_updates_batch_update($nid, array &$context): void {
$node = \Drupal::entityTypeManager()->getStorage('node')->load($nid); $node = \Drupal::entityTypeManager()->getStorage('node')->load($nid);
if ($node) { if ($node) {
...@@ -162,7 +158,7 @@ function _references_block_titles_updates_batch_update($nid, &$context): void { ...@@ -162,7 +158,7 @@ function _references_block_titles_updates_batch_update($nid, &$context): void {
* The batch context array, which is updated with a status message * The batch context array, which is updated with a status message
* indicating the processing of temporary storage. * indicating the processing of temporary storage.
*/ */
function _references_block_titles_updates_batch_temp_storage(&$context) { function _references_block_titles_updates_batch_temp_storage(array &$context) {
// Make sure to load temp storage, and loop over sections there. // Make sure to load temp storage, and loop over sections there.
$context['message'] = t('Processing temporary storage.'); $context['message'] = t('Processing temporary storage.');
} }
...@@ -174,7 +170,7 @@ function _references_block_titles_updates_batch_temp_storage(&$context) { ...@@ -174,7 +170,7 @@ function _references_block_titles_updates_batch_temp_storage(&$context) {
* The batch context array, which gets updated with status messages * The batch context array, which gets updated with status messages
* about nodes and revisions processed during the batch operation. * about nodes and revisions processed during the batch operation.
*/ */
function _references_block_titles_updates_batch_end(&$context) { function _references_block_titles_updates_batch_end(array &$context) {
$context['message'] = t('Updated @nodes_updated out of @nodes_processed (total @total) nodes.', [ $context['message'] = t('Updated @nodes_updated out of @nodes_processed (total @total) nodes.', [
'@nodes_updated' => $context['results']['nodes_updated'], '@nodes_updated' => $context['results']['nodes_updated'],
'@nodes_processed' => $context['results']['nodes_processed'], '@nodes_processed' => $context['results']['nodes_processed'],
...@@ -199,6 +195,6 @@ function _references_block_titles_updates_batch_end(&$context) { ...@@ -199,6 +195,6 @@ function _references_block_titles_updates_batch_end(&$context) {
* @return string * @return string
* Translated message indicating the completion of the batch process. * Translated message indicating the completion of the batch process.
*/ */
function _references_block_titles_updates_batch_finished($success, $results, $operations) { function _references_block_titles_updates_batch_finished($success, array $results, array $operations) {
return t('Finished.'); return t('Finished.');
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment