Skip to content

Commit f893daa

Browse files
committed
lint fixes
1 parent 78061fd commit f893daa

File tree

4 files changed

+35
-35
lines changed

4 files changed

+35
-35
lines changed

bootstrap.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,5 +83,5 @@ function () {
8383
);
8484

8585
// Add action to process image sideload queue
86-
add_action( 'nfd_process_image_sideload_queue', [ ImageSideloadTaskManager::class, 'process_queue' ] );
86+
add_action( 'nfd_process_image_sideload_queue', array( ImageSideloadTaskManager::class, 'process_queue' ) );
8787
}

includes/Services/ThemeGeneratorService.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
/**
99
* ThemeGeneratorService for the onboarding module.
10-
*
10+
*
1111
* Handles image processing and media library operations for the onboarding flow.
1212
*/
1313
class ThemeGeneratorService {
@@ -26,11 +26,11 @@ public static function process_homepage_images_immediate_async( $post_id, $conte
2626
if ( empty( $image_urls ) ) {
2727
return;
2828
}
29-
29+
3030
// Create and add task to queue
3131
$task = new ImageSideloadTask( $post_id, $image_urls );
3232
ImageSideloadTaskManager::add_to_queue( $task );
33-
33+
3434
// Schedule a single event to process the queue (if not already scheduled)
3535
if ( ! wp_next_scheduled( 'nfd_process_image_sideload_queue' ) ) {
3636
wp_schedule_single_event( time(), 'nfd_process_image_sideload_queue' );
@@ -173,4 +173,4 @@ public static function connect_to_filesystem() {
173173

174174
return true;
175175
}
176-
}
176+
}

includes/TaskManagers/ImageSideloadTaskManager.php

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
/**
99
* Task Manager for Image Sideloading
10-
*
10+
*
1111
* Manages a queue of ImageSideloadTask objects and processes them in FIFO order.
1212
*/
1313
class ImageSideloadTaskManager {
@@ -34,7 +34,7 @@ class ImageSideloadTaskManager {
3434
*/
3535
public static function add_to_queue( ImageSideloadTask $task ) {
3636
$queue = self::get_queue();
37-
37+
3838
// Check if task already exists
3939
$task_id = $task->get_id();
4040
foreach ( $queue as $existing_task ) {
@@ -45,11 +45,11 @@ public static function add_to_queue( ImageSideloadTask $task ) {
4545

4646
// Add task to queue (FIFO - add to end)
4747
$queue[] = array(
48-
'id' => $task_id,
49-
'post_id' => $task->get_post_id(),
50-
'urls' => $task->get_image_urls(),
51-
'status' => 'pending',
52-
'created' => time(),
48+
'id' => $task_id,
49+
'post_id' => $task->get_post_id(),
50+
'urls' => $task->get_image_urls(),
51+
'status' => 'pending',
52+
'created' => time(),
5353
);
5454

5555
self::set_queue( $queue );
@@ -105,45 +105,45 @@ public static function set_status( $status ) {
105105
*/
106106
public static function process_next_task() {
107107
$queue = self::get_queue();
108-
108+
109109
if ( empty( $queue ) ) {
110110
self::set_status( 'idle' );
111111
return false;
112112
}
113113

114114
// Get the next task
115115
$task_data = array_shift( $queue );
116-
116+
117117
// Mark as processing
118-
$task_data['status'] = 'processing';
118+
$task_data['status'] = 'processing';
119119
$task_data['started'] = time();
120-
120+
121121
// Create task object and execute
122-
$task = new ImageSideloadTask( $task_data['post_id'], $task_data['urls'] );
122+
$task = new ImageSideloadTask( $task_data['post_id'], $task_data['urls'] );
123123
$result = $task->execute();
124124

125125
if ( is_wp_error( $result ) ) {
126126
// Mark as failed
127-
$task_data['status'] = 'failed';
128-
$task_data['error'] = $result->get_error_message();
127+
$task_data['status'] = 'failed';
128+
$task_data['error'] = $result->get_error_message();
129129
$task_data['completed'] = time();
130-
130+
131131
// Add back to queue for retry
132132
$queue[] = $task_data;
133-
133+
134134
self::set_queue( $queue );
135135
self::set_status( 'processing' );
136-
136+
137137
return $result;
138138
}
139139

140140
// Mark as completed
141-
$task_data['status'] = 'completed';
141+
$task_data['status'] = 'completed';
142142
$task_data['completed'] = time();
143-
143+
144144
self::set_queue( $queue );
145145
self::set_status( 'processing' );
146-
146+
147147
return true;
148148
}
149149

@@ -154,31 +154,31 @@ public static function process_next_task() {
154154
* @return array Array with 'processed' and 'remaining' counts
155155
*/
156156
public static function process_queue( $max_tasks = 5 ) {
157-
$processed = 0;
158-
$queue = self::get_queue();
157+
$processed = 0;
158+
$queue = self::get_queue();
159159
$initial_count = count( $queue );
160160

161161
self::set_status( 'processing' );
162162

163163
while ( $processed < $max_tasks && ! empty( $queue ) ) {
164164
$result = self::process_next_task();
165-
166-
if ( $result === false ) {
165+
166+
if ( false ===$result ) {
167167
break; // Queue is empty
168168
}
169-
169+
170170
if ( is_wp_error( $result ) ) {
171171
// Continue processing other tasks even if one fails
172172
$processed++;
173173
continue;
174174
}
175-
175+
176176
$processed++;
177177
}
178178

179179
$remaining = count( self::get_queue() );
180-
181-
if ( $remaining === 0 ) {
180+
181+
if ( 0 === $remaining ) {
182182
self::set_status( 'idle' );
183183
}
184184

includes/Tasks/ImageSideloadTask.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function execute() {
4343
try {
4444
// Upload images to WordPress media library
4545
$result = ThemeGeneratorService::upload_images_to_wp_media_library( $this->image_urls, $this->post_id );
46-
46+
4747
if ( is_wp_error( $result ) ) {
4848
return $result;
4949
}
@@ -78,6 +78,6 @@ public function get_image_urls() {
7878
* @return string
7979
*/
8080
public function get_id() {
81-
return 'image_sideload_' . $this->post_id . '_' . md5( serialize( $this->image_urls ) );
81+
return 'image_sideload_' . $this->post_id . '_' . md5( maybe_serialize( $this->image_urls ) );
8282
}
8383
}

0 commit comments

Comments
 (0)