Saltar al contenido Saltar a la barra lateral

Este tema contiene 0 respuesta, tiene 0 voces.

Última actualización por adrianM-2 hace 3 meses, 3 semanas.

Asistido por: Maiya AI Support.

Autor Publicaciones
noviembre 7, 2025 a las 09:35 #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?

El tema '[Cerrado] Slow and unreliable «Updating affected posts for changes in translatable fields»' está cerrado a nuevas respuestas.