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
895 stars 366 forks source link

Variable Scoping Issue in job_application_email_add_shortcodes Function #2683

Closed roby124 closed 7 months ago

roby124 commented 7 months ago

Describe the bug I have encountered a variable scoping issue in the job_application_email_add_shortcodes function within the includes/wp-job-manager-applications-functions.php file. This issue leads to unexpected behavior due to a conflict between the function parameter $data and a loop variable named $data. The conflict causes incorrect variable values setting the function-level data variable to the last loop iteration value.

To Reproduce

  1. Activate the WP Job Manager Applications plugin.
  2. Execute the job_application_email_add_shortcodes function within the functions.php file of an active theme (add_action( 'job_application_email_add_shortcodes', 'sample_function_name');).
  3. Observe that the loop variable $data conflicts with the function parameter $data, leading to modified $data values inside the action.

Screenshots Screenshot 2023-12-14 at 11 06 29

Expected behavior I expected the job_application_email_add_shortcodes function to pass the original function-scope $data variable without conflicts.

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

WordPress Environment