Plugin Directory

Changeset 3338991


Ignore:
Timestamp:
08/04/2025 01:06:41 PM (8 months ago)
Author:
recruitly
Message:

Upgrade to 2.0.31

Location:
recruitly/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • recruitly/trunk

    • Property svn:ignore
      •  

        old new  
        11.idea
         2.claude
  • recruitly/trunk/admin/dataloader.php

    r3262547 r3338991  
    691691        }
    692692
    693         $job = json_decode($curlResp);
     693        // Clean up JSON before parsing
     694        // Remove BOM if present
     695        $curlResp = preg_replace('/^\xEF\xBB\xBF/', '', $curlResp);
     696       
     697        // Fix any encoding issues
     698        if (function_exists('mb_check_encoding') && !mb_check_encoding($curlResp, 'UTF-8')) {
     699            $curlResp = mb_convert_encoding($curlResp, 'UTF-8', 'UTF-8');
     700        }
     701
     702        // Decode with proper error handling
     703        // Use JSON_INVALID_UTF8_SUBSTITUTE if available (PHP 7.2+)
     704        $json_options = 0;
     705        if (defined('JSON_INVALID_UTF8_SUBSTITUTE')) {
     706            $json_options = JSON_INVALID_UTF8_SUBSTITUTE;
     707        }
     708        $job = json_decode($curlResp, false, 512, $json_options);
     709       
     710        // Check for JSON errors
     711        if (json_last_error() !== JSON_ERROR_NONE) {
     712            recruitly_log_exception(new Exception('JSON decode error in sync_post_type_single: ' . json_last_error_msg()));
     713            return;
     714        }
    694715
    695716        if (!property_exists($job, 'id')) {
     
    788809        }
    789810
    790         // Decode the JSON response
    791         $restResponse = json_decode(wp_remote_retrieve_body($response));
     811        // Get and clean the response body
     812        $responseBody = wp_remote_retrieve_body($response);
     813       
     814        // Remove BOM if present
     815        $responseBody = preg_replace('/^\xEF\xBB\xBF/', '', $responseBody);
     816       
     817        // Fix any encoding issues
     818        if (function_exists('mb_check_encoding') && !mb_check_encoding($responseBody, 'UTF-8')) {
     819            $responseBody = mb_convert_encoding($responseBody, 'UTF-8', 'UTF-8');
     820        }
     821       
     822        // Decode the JSON response with error handling
     823        // Use JSON_INVALID_UTF8_SUBSTITUTE if available (PHP 7.2+)
     824        $json_options = 0;
     825        if (defined('JSON_INVALID_UTF8_SUBSTITUTE')) {
     826            $json_options = JSON_INVALID_UTF8_SUBSTITUTE;
     827        }
     828        $restResponse = json_decode($responseBody, false, 512, $json_options);
     829       
     830        // Check for JSON errors
     831        if (json_last_error() !== JSON_ERROR_NONE) {
     832            recruitly_log_exception(new Exception('JSON decode error in get_total_jobs_count: ' . json_last_error_msg()));
     833            return 0;
     834        }
    792835
    793836        // Return the count if available, otherwise return 0
     
    881924
    882925                    // Get the response body
    883                     $restResponse = json_decode(wp_remote_retrieve_body($response));
    884 
    885                     // Verify server response and display errors
    886                     if (property_exists($restResponse, 'reason') && property_exists($restResponse, 'message')) {
     926                    $responseBody = wp_remote_retrieve_body($response);
     927                   
     928                    // Clean up JSON before parsing
     929                    // Remove BOM if present
     930                    $responseBody = preg_replace('/^\xEF\xBB\xBF/', '', $responseBody);
     931                   
     932                    // Fix any encoding issues
     933                    if (function_exists('mb_check_encoding') && !mb_check_encoding($responseBody, 'UTF-8')) {
     934                        $responseBody = mb_convert_encoding($responseBody, 'UTF-8', 'UTF-8');
     935                    }
     936                   
     937                    // Decode with proper error handling
     938                    // Use JSON_INVALID_UTF8_SUBSTITUTE if available (PHP 7.2+)
     939                    $json_options = 0;
     940                    if (defined('JSON_INVALID_UTF8_SUBSTITUTE')) {
     941                        $json_options = JSON_INVALID_UTF8_SUBSTITUTE;
     942                    }
     943                    $restResponse = json_decode($responseBody, false, 512, $json_options);
     944                   
     945                    // Check for JSON errors
     946                    if (json_last_error() !== JSON_ERROR_NONE) {
     947                        recruitly_log_exception(new Exception('JSON decode error in sync_post_type: ' . json_last_error_msg()));
     948                        continue;
     949                    }
     950
     951                    // Verify server response and display errors 
     952                    if ($restResponse && property_exists($restResponse, 'reason') && property_exists($restResponse, 'message')) {
    887953                        recruitly_admin_notice(htmlspecialchars($restResponse->message), 'error');
    888954                        continue;
     
    9981064                $error_message = $response->get_error_message();
    9991065                echo esc_html("Failed to fetch data: $error_message");
     1066                return;
    10001067            } else {
    1001                 $body = wp_remote_retrieve_body($response);
    1002                 $image_data = wp_json_decode($body, true);
     1068                // Get the raw image data (not JSON)
     1069                $image_data = wp_remote_retrieve_body($response);
    10031070            }
    10041071
  • recruitly/trunk/readme.txt

    r3262547 r3338991  
    131131* Add additional recruiter fields.
    132132
     133= 2.0.31 =
     134* Fix character encoding issues.
     135
    133136== Upgrade Notice ==
    134137
  • recruitly/trunk/recruitly.php

    r3262547 r3338991  
    44Plugin URI: https://recruitly.io
    55Description: Recruitly job board integration.
    6 Version: 2.0.30
     6Version: 2.0.31
    77Author: Recruitly
    88Author URI: https://recruitly.io
     
    1515    exit; // Exit if accessed directly
    1616}
    17 define('RECRUITLY_PLUGIN_VERSION', '2.0.30');
     17define('RECRUITLY_PLUGIN_VERSION', '2.0.31');
    1818
    1919defined('RECRUITLY_POST_TYPE') or define('RECRUITLY_POST_TYPE', 'current-vacancies');
Note: See TracChangeset for help on using the changeset viewer.