Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion includes/model/ListingForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -964,7 +964,11 @@ protected function set_directory() {

if ( ! empty( $maybe_directory_id ) && ! is_numeric( $maybe_directory_id ) ) {
$term = get_term_by( 'slug', $maybe_directory_id, ATBDP_TYPE );
$maybe_directory_id = $term->term_id;
if ( $term && ! is_wp_error( $term ) ) {
$maybe_directory_id = $term->term_id;
} else {
$maybe_directory_id = 0;
}
}

$this->current_listing_type = (int) $maybe_directory_id;
Expand Down
2 changes: 1 addition & 1 deletion includes/model/SearchForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -1062,7 +1062,7 @@ public static function get_taxonomy_select_option_data( $id ) {

$taxonomy = get_term( $id );

if ( is_wp_error( $taxonomy ) ) {
if ( is_wp_error( $taxonomy ) || ! is_object( $taxonomy ) ) {
return $item;
}

Expand Down
38 changes: 27 additions & 11 deletions includes/modules/background-process/wp-background-process.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,12 @@ protected function is_queue_empty() {

$key = $wpdb->esc_like( $this->identifier . '_batch_' ) . '%';

$count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM %s WHERE %s LIKE %s", $table, $column, $key ) );
$count = $wpdb->get_var(
$wpdb->prepare(
"SELECT COUNT(*) FROM {$table} WHERE {$column} LIKE %s",
$key
)
);

return ( $count > 0 ) ? false : true;
}
Expand Down Expand Up @@ -267,19 +272,26 @@ protected function get_batch() {

$query = $wpdb->get_row(
$wpdb->prepare(
"
SELECT *
FROM %s
WHERE %s LIKE %s
ORDER BY %s ASC
LIMIT 1
", $table, $column, $key, $key_column
)
"SELECT * FROM {$table} WHERE {$column} LIKE %s ORDER BY {$key_column} ASC LIMIT 1",
$key
)
);

$batch = new stdClass();
$batch->key = $query->$column;
$batch->data = maybe_unserialize( $query->$value_column );
$batch->key = '';
$batch->data = [];

if ( ! is_object( $query ) ) {
return $batch;
}

$batch->key = isset( $query->$column ) ? $query->$column : '';
$batch->data = maybe_unserialize( $query->$value_column ?? [] );

if ( ! is_array( $batch->data ) ) {
$batch->data = [];
}


return $batch;
}
Expand All @@ -296,6 +308,10 @@ protected function handle() {
do {
$batch = $this->get_batch();

if ( empty( $batch->key ) || empty( $batch->data ) || ! is_array( $batch->data ) ) {
break;
}

foreach ( $batch->data as $key => $value ) {
$task = $this->task( $value );

Expand Down
Loading