Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix PHP 8.3 deprecations #2836

Merged
merged 1 commit into from
Jul 23, 2024
Merged
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
2 changes: 1 addition & 1 deletion includes/class-wp-job-manager-usage-tracking.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public static function track_job_approval( $post_id, $properties = [] ) {
* @return self
*/
public static function get_instance() {
return self::get_instance_for_subclass( get_class() );
return self::get_instance_for_subclass( static::class );
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Usage_Tracking_Test_Subclass extends WP_Job_Manager_Usage_Tracking_Base {
const TRACKING_ENABLED_OPTION_NAME = 'testing-usage-tracking-enabled';

public static function get_instance() {
return self::get_instance_for_subclass( get_class() );
return self::get_instance_for_subclass( static::class );
}

public function get_prefix() {
Expand Down
1 change: 1 addition & 0 deletions lib/usage-tracking/tests/test-class-usage-tracking.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
class WP_Job_Manager_Usage_Tracking_Test extends WP_UnitTestCase {
private $event_counts = array();
private $track_http_request = array();
private $usage_tracking;

public function setUp(): void {
parent::setUp();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
require 'includes/admin/class-wp-job-manager-cpt.php';

class WP_Test_WP_Job_Manager_CPT extends WPJM_BaseTest {
protected WP_Job_Manager_CPT $job_manager_cpt;

public function setUp(): void {
parent::setUp();

Expand Down
9 changes: 5 additions & 4 deletions wp-job-manager-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -363,17 +363,18 @@ function job_manager_construct_secondary_conditions( $search_term, $is_excluding
// Only selected meta keys.
if ( $searchable_meta_keys ) {
$meta_keys = implode( "','", array_map( 'esc_sql', $searchable_meta_keys ) );
//phpcs:disabled WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- Variables are safe or escaped.
$conditions[] = $wpdb->prepare( "{$wpdb->posts}.ID {$not_string}IN ( SELECT post_id FROM {$wpdb->postmeta} WHERE meta_key IN ( '${meta_keys}' ) AND meta_value LIKE %s )", $meta_value );
// phpcs:disable WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- Variables are safe or escaped.
$conditions[] = $wpdb->prepare( "{$wpdb->posts}.ID {$not_string}IN ( SELECT post_id FROM {$wpdb->postmeta} WHERE meta_key IN ( '{$meta_keys}' ) AND meta_value LIKE %s )", $meta_value );
} else {
// No meta keys defined, search all post meta value.
$conditions[] = $wpdb->prepare( "{$wpdb->posts}.ID {$not_string}IN ( SELECT post_id FROM {$wpdb->postmeta} WHERE meta_value LIKE %s )", $meta_value );
//phpcs:enabled WordPress.DB.PreparedSQL.InterpolatedNotPrepared
// phpcs:enable WordPress.DB.PreparedSQL.InterpolatedNotPrepared
}
}

// Search taxonomy.
$conditions[] = $wpdb->prepare( "{$wpdb->posts}.ID ${not_string}IN ( SELECT object_id FROM {$wpdb->term_relationships} AS tr LEFT JOIN {$wpdb->term_taxonomy} AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id LEFT JOIN {$wpdb->terms} AS t ON tt.term_id = t.term_id WHERE t.name LIKE %s )", $meta_value );
// phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- Variables are safe or escaped.
$conditions[] = $wpdb->prepare( "{$wpdb->posts}.ID {$not_string}IN ( SELECT object_id FROM {$wpdb->term_relationships} AS tr LEFT JOIN {$wpdb->term_taxonomy} AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id LEFT JOIN {$wpdb->terms} AS t ON tt.term_id = t.term_id WHERE t.name LIKE %s )", $meta_value );

return $conditions;
}
Expand Down
Loading