דלג לתוכן דלג לסרגל צד

נושא זה מכיל 0 1, יש ל 0 קולות.

עודכן לאחרונה על ידי adrianM-2 לפני חודש 5, שבוע 2.

בסיוע: 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"' סגור לתגובות חדשות.