PluginProbe
Lasso Lite – Affiliate Link Manager & Product Displays / 158
Lasso Lite – Affiliate Link Manager & Product Displays v158
158 157 155 156 154 153 152 151 150 149 148 trunk 0.9.9 104 105 106 107 108 109 110 111 112 113 114 115 All 57 releases
← All changes | classes/processes/class-process.php +30 -1 111158 View file →
@@ -37,8 +37,9 @@
37 37 const EXCEEDED_TIME_LIMIT = 10; // ? Exceeded time limit in seconds
38 38 const AGE_OUT = 6; // ? Age out time after n hours
39 39 const RESTART_ATTEMPTED_LIMIT = 3;
40 40 const OPTION_RESTART_ATTEMPTED = 'lasso_lite_process_restart_attempted'; // ? Age out time after n hours
41 + const COMPLETE_ACTION_KEY = 'lasso_lite_process_complete';
41 42
42 43 /**
43 44 * Action name
44 45 *
@@ -311,9 +312,9 @@
311 312 $key
312 313 );
313 314 // @codingStandardsIgnoreEnd
314 315
315 - $queue = $lasso_db->get_var( $sql ); // ? We want to track SQL errors in Sentry
316 + $queue = $lasso_db->get_var( $sql ); // ? SQL errors surfaced via log_error() -> trigger_error()
316 317 $count = 0;
317 318 $unserialized_queue = maybe_unserialize( $queue );
318 319 if ( is_array( $unserialized_queue ) ) {
319 320 $count = count( $unserialized_queue );
@@ -365,8 +366,9 @@
365 366 public function complete() {
366 367 parent::complete();
367 368 $this->set_completed();
368 369 $this->task_end_log();
370 + do_action( self::COMPLETE_ACTION_KEY, $this->action );
369 371 }
370 372
371 373 /**
372 374 * Check whether CPU exceeded or not
@@ -512,8 +514,31 @@
512 514 $lasso_db->remove_all_lasso_processes();
513 515 }
514 516
515 517 /**
518 + * Log once when a configured background process class is missing.
519 + *
520 + * @param mixed $process_class Process class name from filter/map.
521 + */
522 + private static function log_missing_process_class_once( $process_class ) {
523 + $class_label = is_string( $process_class ) ? $process_class : wp_json_encode( $process_class );
524 + static $logged_this_request = array();
525 + if ( isset( $logged_this_request[ $class_label ] ) ) {
526 + return;
527 + }
528 + $logged_this_request[ $class_label ] = true;
529 +
530 + $log_key = 'lasso_lite_missing_proc_' . md5( $class_label );
531 + if ( get_option( $log_key ) ) {
532 + return;
533 + }
534 + update_option( $log_key, 1, false );
535 +
536 + // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
537 + error_log( 'Lasso Lite: skipping missing background process class ' . $class_label );
538 + }
539 +
540 + /**
516 541 * Get Background Process is running
517 542 */
518 543 public function get_list_background_processing() {
519 544 $result = array(
@@ -525,8 +550,12 @@
525 550 $process_classes = Lasso_Verbiage::PROCESS_DESCRIPTION;
526 551 $process_classes = apply_filters( 'lasso_lite_all_processes', $process_classes );
527 552
528 553 foreach ( $process_classes as $process_class => $process_name ) {
554 + if ( ! is_string( $process_class ) || ! class_exists( $process_class ) ) {
555 + self::log_missing_process_class_once( $process_class );
556 + continue;
557 + }
529 558 /** @var Process $process_class_obj */ // phpcs:ignore
530 559 $process_class_obj = new $process_class();
531 560 $process_next_schedule = $process_class_obj->next_schedule();
532 561