Skip to content Skip to sidebar

This topic contains 0 reply, has 0 voices.

Last updated by adrianM-2 5 months, 1 week ago.

Assisted by: Maiya AI Support.

Author Posts
November 7, 2025 at 9:35 am #17556284

adrianM-2

Background of the issue:
I am trying to update affected posts for changes in translatable fields using WPML. This task is extremely slow and often does not complete. We have about 100,000 posts, making this process unfeasible. As a workaround, I am using a WP CLI task that can be triggered through a cron job. Here is the code I am using:

<code>
<?php

use WPMLBackgroundTaskAbstractTaskEndpoint;
use WPMLCollectSupportCollection;
use WPMLCoreBackgroundTaskRepositoryBackgroundTaskRepository;
use function WPMLContainermake;

if ( defined( 'WP_CLI' ) && WP_CLI ) {
WP_CLI::add_command( 'concerti-wpml-process-tasks', 'concerti_do_action_wpml_process_task' );
}

function concerti_do_action_wpml_process_task(): void {

$taskRepository = make( BackgroundTaskRepository::class );
while ( $tasks = $taskRepository->getAllRunnableTasks() ) {
foreach ( $tasks as $task ) {
WP_CLI::log( "Processing task: " . $task->getTaskId() . ' ' . $task->getTaskType() );

$realTask = make( $task->getTaskType() );

if ( $realTask instanceof AbstractTaskEndpoint ) {
$realTask->run( new Collection( [ 'taskId' => $task->getTaskId() ] ) );
} else {
WP_CLI::log( "Wrong type: " . gettype( $realTask ) );
}
}
}
}
</code>

I call it like:

<code>
wp concerti-wpml-process-tasks
</code>

Symptoms:
The task of updating affected posts for changes in translatable fields is extremely slow and often does not complete. It is not feasible with the current setup as it 'never' finishes.

Questions:
Why is the task of updating affected posts for changes in translatable fields so slow?
How can I ensure the task completes successfully given the large number of posts?

The topic ‘[Closed] Slow and unreliable “Updating affected posts for changes in translatable fields”’ is closed to new replies.