Automattic / WP-Job-Manager

Manage job listings from the WordPress admin panel, and allow users to post jobs directly to your site.
https://wpjobmanager.com
GNU General Public License v3.0
899 stars 368 forks source link

Job Alerts 3.0.0 plugin gives 500 ajax error #2767

Closed Ericmuc closed 7 months ago

Ericmuc commented 7 months ago

Describe the bug I have a ajax 500 fatal error as shown here: PHP Fatal error: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, null given in /domain-pathxxxx/wp-content/plugins/wp-job-manager-alerts/includes/class-add-alert.php:57

To Reproduce Steps to reproduce the behavior:

  1. Go to '/jobs-listing/' with activated job alert plugin "Job Alerts 3.0.0"
  2. the job list don't load and a 500er error is shown in the webbrowser console

Solution I changed the code in class-add-alert.php:57 ff

from if ( count( $args['filter_job_types'] ) !== count( $all_job_types ) ) { foreach ( $args['filter_job_types'] as $job_type ) { $job_type_term = get_term_by( 'slug', $job_type, 'job_listing_type' ); $job_type_array[] = $job_type_term->term_id; } }

to if (is_countable($args['filter_job_types']) && count($args['filter_job_types']) > 0) { if ( count( $args['filter_job_types'] ) !== count( $all_job_types ) ) { foreach ( $args['filter_job_types'] as $job_type ) { $job_type_term = get_term_by( 'slug', $job_type, 'job_listing_type' ); $job_type_array[] = $job_type_term->term_id; } } }

Expected behavior After adding the code from the solution it works, the job list is loading again

Isolating the problem (mark completed items with an [x]):

WordPress Environment

Ericmuc commented 7 months ago

fixed in the latest plugin version, great!