تخطي إلى المحتوى تخطي إلى الشريط الجانبي

يحتوي هذا الموضوع 0 ردود ، لديه 0 voices.

آخر تحديث بواسطة adrianM-2 قبل 4 أشهر.

يساعده: Maiya AI Support.

الكاتب المشاركات
7 نوفمبر، 2025 في 9: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?

الموضوع ”[مغلق] Slow and unreliable “Updating affected posts for changes in translatable fields”“ مغلق للردود الجديدة.