Changeset 3357955
- Timestamp:
- 09/08/2025 01:55:11 PM (7 months ago)
- Location:
- muchat-ai
- Files:
-
- 12 edited
- 1 copied
-
tags/2.0.45 (copied) (copied from muchat-ai/trunk)
-
tags/2.0.45/includes/Models/BaseModel.php (modified) (1 diff)
-
tags/2.0.45/includes/Models/Page.php (modified) (5 diffs)
-
tags/2.0.45/includes/Models/Post.php (modified) (5 diffs)
-
tags/2.0.45/includes/Models/Product.php (modified) (5 diffs)
-
tags/2.0.45/muchat-ai.php (modified) (3 diffs)
-
tags/2.0.45/readme.txt (modified) (2 diffs)
-
trunk/includes/Models/BaseModel.php (modified) (1 diff)
-
trunk/includes/Models/Page.php (modified) (5 diffs)
-
trunk/includes/Models/Post.php (modified) (5 diffs)
-
trunk/includes/Models/Product.php (modified) (5 diffs)
-
trunk/muchat-ai.php (modified) (3 diffs)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
muchat-ai/tags/2.0.45/includes/Models/BaseModel.php
r3300525 r3357955 75 75 $args = [ 76 76 'post_status' => 'publish', 77 'posts_per_page' => $params['per_page'] ??10,78 'paged' => $params['page'] ??1,79 'orderby' => $params['orderby'] ??'modified',80 'order' => $params['order'] ??'ASC',77 'posts_per_page' => isset($params['per_page']) ? $params['per_page'] : 10, 78 'paged' => isset($params['page']) ? $params['page'] : 1, 79 'orderby' => isset($params['orderby']) ? $params['orderby'] : 'modified', 80 'order' => isset($params['order']) ? $params['order'] : 'ASC', 81 81 'fields' => 'ids' 82 82 ]; -
muchat-ai/tags/2.0.45/includes/Models/Page.php
r3330977 r3357955 27 27 $orderby_array = []; 28 28 foreach ($orderby_fields as $field) { 29 $orderby_array[$field] = $params['order'] ??'ASC';29 $orderby_array[$field] = isset($params['order']) ? $params['order'] : 'ASC'; 30 30 } 31 31 … … 38 38 } else { 39 39 // Single field ordering - always add ID as secondary sort 40 $primary_order = $params['order'] ??'ASC';40 $primary_order = isset($params['order']) ? $params['order'] : 'ASC'; 41 41 $args['orderby'] = [ 42 42 $params['order_by'] => $primary_order, … … 49 49 } 50 50 51 $args['order'] = $params['order'] ??'ASC';51 $args['order'] = isset($params['order']) ? $params['order'] : 'ASC'; 52 52 53 53 // Add date filters if provided … … 70 70 71 71 // Set pagination parameters 72 $requested_offset = $params['skip'] ??0;73 $requested_limit = $params['take'] ??10;72 $requested_offset = isset($params['skip']) ? $params['skip'] : 0; 73 $requested_limit = isset($params['take']) ? $params['take'] : 10; 74 74 75 75 $args['posts_per_page'] = $requested_limit; … … 199 199 case 'modified_date': 200 200 $post_data = get_post($page->ID); 201 $data['date_modified'] = $post_data->post_modified_gmt ??null;201 $data['date_modified'] = isset($post_data->post_modified_gmt) ? $post_data->post_modified_gmt : null; 202 202 break; 203 203 case 'permalink': -
muchat-ai/tags/2.0.45/includes/Models/Post.php
r3330977 r3357955 27 27 $orderby_array = []; 28 28 foreach ($orderby_fields as $field) { 29 $orderby_array[$field] = $params['order'] ??'ASC';29 $orderby_array[$field] = isset($params['order']) ? $params['order'] : 'ASC'; 30 30 } 31 31 … … 38 38 } else { 39 39 // Single field ordering - always add ID as secondary sort 40 $primary_order = $params['order'] ??'ASC';40 $primary_order = isset($params['order']) ? $params['order'] : 'ASC'; 41 41 $args['orderby'] = [ 42 42 $params['order_by'] => $primary_order, … … 49 49 } 50 50 51 $args['order'] = $params['order'] ??'ASC';51 $args['order'] = isset($params['order']) ? $params['order'] : 'ASC'; 52 52 53 53 // Add date filters if provided … … 64 64 65 65 // Set pagination parameters 66 $requested_offset = $params['skip'] ??0;67 $requested_limit = $params['take'] ??10;66 $requested_offset = isset($params['skip']) ? $params['skip'] : 0; 67 $requested_limit = isset($params['take']) ? $params['take'] : 10; 68 68 69 69 // Update the query with pagination parameters … … 139 139 case 'modified_date': 140 140 $post_data = get_post($post->ID); 141 $data['date_modified'] = $post_data->post_modified_gmt ??null;141 $data['date_modified'] = isset($post_data->post_modified_gmt) ? $post_data->post_modified_gmt : null; 142 142 break; 143 143 case 'permalink': -
muchat-ai/tags/2.0.45/includes/Models/Product.php
r3330738 r3357955 36 36 $orderby_array = []; 37 37 foreach ($orderby_fields as $field) { 38 $orderby_array[$field] = $params['order'] ??'ASC';38 $orderby_array[$field] = isset($params['order']) ? $params['order'] : 'ASC'; 39 39 } 40 40 … … 47 47 } else { 48 48 // Single field ordering - always add ID as secondary sort 49 $primary_order = $params['order'] ??'ASC';49 $primary_order = isset($params['order']) ? $params['order'] : 'ASC'; 50 50 $args['orderby'] = [ 51 51 $params['order_by'] => $primary_order, … … 58 58 } 59 59 60 $args['order'] = $params['order'] ??'ASC';60 $args['order'] = isset($params['order']) ? $params['order'] : 'ASC'; 61 61 62 62 // Add date filters if provided … … 82 82 83 83 // Set pagination parameters 84 $requested_offset = $params['skip'] ??0;85 $requested_limit = $params['take'] ??30;84 $requested_offset = isset($params['skip']) ? $params['skip'] : 0; 85 $requested_limit = isset($params['take']) ? $params['take'] : 30; 86 86 87 87 // Update the query with pagination parameters … … 192 192 case 'date_modified': 193 193 $post_data = get_post($product->get_id()); 194 $data['date_modified'] = $post_data->post_modified_gmt ??null;194 $data['date_modified'] = isset($post_data->post_modified_gmt) ? $post_data->post_modified_gmt : null; 195 195 break; 196 196 case 'description': -
muchat-ai/tags/2.0.45/muchat-ai.php
r3332960 r3357955 5 5 * Plugin URI: https://mu.chat 6 6 * Description: Muchat, a powerful tool for customer support using artificial intelligence 7 * Version: 2.0.4 47 * Version: 2.0.45 8 8 * Author: Muchat 9 9 * Text Domain: muchat-ai 10 10 * Domain Path: /languages 11 11 * Requires at least: 5.0 12 * Requires PHP: 7. 412 * Requires PHP: 7.3 13 13 * Author: Muchat Team 14 14 * Author URI: https://mu.chat/about-us … … 27 27 28 28 // Define plugin constants with unique prefix 29 define('MUCHAT_AI_CHATBOT_PLUGIN_VERSION', '2.0.4 4');29 define('MUCHAT_AI_CHATBOT_PLUGIN_VERSION', '2.0.45'); 30 30 // define('MUCHAT_AI_CHATBOT_CACHE_DURATION', HOUR_IN_SECONDS); 31 31 define('MUCHAT_AI_CHATBOT_PLUGIN_FILE', __FILE__); 32 32 define('MUCHAT_AI_CHATBOT_PLUGIN_PATH', plugin_dir_path(__FILE__)); 33 33 define('MUCHAT_AI_CHATBOT_PLUGIN_URL', plugin_dir_url(__FILE__)); 34 35 /** 36 * Setup API isolation to prevent other plugin errors from affecting our API 37 */ 38 function muchat_ai_setup_api_isolation() 39 { 40 // Set up error handler that prevents fatal errors from showing 41 set_error_handler(function($severity, $message, $file, $line) { 42 // Log the error but don't output it 43 error_log("Muchat API Error Caught: $message in $file on line $line"); 44 return true; // Prevent the error from being displayed 45 }); 46 47 // Set up exception handler 48 set_exception_handler(function($exception) { 49 error_log("Muchat API Exception Caught: " . $exception->getMessage()); 50 51 // Send clean JSON error response 52 if (!headers_sent()) { 53 http_response_code(500); 54 header('Content-Type: application/json'); 55 echo json_encode([ 56 'error' => 'Internal server error', 57 'message' => 'A plugin conflict occurred', 58 'timestamp' => current_time('c') 59 ]); 60 } 61 exit; 62 }); 63 64 // Register shutdown function to catch fatal errors 65 register_shutdown_function(function() { 66 $error = error_get_last(); 67 if ($error && in_array($error['type'], [E_ERROR, E_PARSE, E_CORE_ERROR, E_COMPILE_ERROR])) { 68 // Check if this is our API request 69 if (isset($_SERVER['REQUEST_URI']) && strpos($_SERVER['REQUEST_URI'], '/wp-json/muchat-api/') !== false) { 70 if (!headers_sent()) { 71 http_response_code(500); 72 header('Content-Type: application/json'); 73 echo json_encode([ 74 'error' => 'Fatal error occurred', 75 'message' => 'Plugin conflict detected', 76 'debug' => WP_DEBUG ? $error['message'] : 'Enable WP_DEBUG for details', 77 'timestamp' => current_time('c') 78 ]); 79 } 80 } 81 } 82 }); 83 84 // Disable plugin error display 85 ini_set('display_errors', 0); 86 ini_set('log_errors', 1); 87 } 34 88 35 89 // Simple Autoloader … … 83 137 }); 84 138 139 // Isolate our API from other plugin errors 140 if (isset($_SERVER['REQUEST_URI']) && strpos($_SERVER['REQUEST_URI'], '/wp-json/muchat-api/') !== false) { 141 // Set up error isolation for our API 142 muchat_ai_setup_api_isolation(); 143 } 144 85 145 // Run the plugin 86 146 muchat_ai_chatbot_run_plugin(); -
muchat-ai/tags/2.0.45/readme.txt
r3332960 r3357955 4 4 Requires at least: 5.0 5 5 Tested up to: 6.8 6 Stable tag: 2.0.4 47 Requires PHP: 7. 46 Stable tag: 2.0.45 7 Requires PHP: 7.3 8 8 License: GPLv2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 75 75 76 76 == Changelog == 77 78 = 2.0.45 = 79 * Compatibility: Added PHP 7.3 compatibility - replaced null coalescing operators with isset/ternary for better backward compatibility. 80 * Performance: Implemented error isolation system to prevent other plugin errors from affecting API endpoints. 81 77 82 78 83 = 2.0.44 = -
muchat-ai/trunk/includes/Models/BaseModel.php
r3300525 r3357955 75 75 $args = [ 76 76 'post_status' => 'publish', 77 'posts_per_page' => $params['per_page'] ??10,78 'paged' => $params['page'] ??1,79 'orderby' => $params['orderby'] ??'modified',80 'order' => $params['order'] ??'ASC',77 'posts_per_page' => isset($params['per_page']) ? $params['per_page'] : 10, 78 'paged' => isset($params['page']) ? $params['page'] : 1, 79 'orderby' => isset($params['orderby']) ? $params['orderby'] : 'modified', 80 'order' => isset($params['order']) ? $params['order'] : 'ASC', 81 81 'fields' => 'ids' 82 82 ]; -
muchat-ai/trunk/includes/Models/Page.php
r3330977 r3357955 27 27 $orderby_array = []; 28 28 foreach ($orderby_fields as $field) { 29 $orderby_array[$field] = $params['order'] ??'ASC';29 $orderby_array[$field] = isset($params['order']) ? $params['order'] : 'ASC'; 30 30 } 31 31 … … 38 38 } else { 39 39 // Single field ordering - always add ID as secondary sort 40 $primary_order = $params['order'] ??'ASC';40 $primary_order = isset($params['order']) ? $params['order'] : 'ASC'; 41 41 $args['orderby'] = [ 42 42 $params['order_by'] => $primary_order, … … 49 49 } 50 50 51 $args['order'] = $params['order'] ??'ASC';51 $args['order'] = isset($params['order']) ? $params['order'] : 'ASC'; 52 52 53 53 // Add date filters if provided … … 70 70 71 71 // Set pagination parameters 72 $requested_offset = $params['skip'] ??0;73 $requested_limit = $params['take'] ??10;72 $requested_offset = isset($params['skip']) ? $params['skip'] : 0; 73 $requested_limit = isset($params['take']) ? $params['take'] : 10; 74 74 75 75 $args['posts_per_page'] = $requested_limit; … … 199 199 case 'modified_date': 200 200 $post_data = get_post($page->ID); 201 $data['date_modified'] = $post_data->post_modified_gmt ??null;201 $data['date_modified'] = isset($post_data->post_modified_gmt) ? $post_data->post_modified_gmt : null; 202 202 break; 203 203 case 'permalink': -
muchat-ai/trunk/includes/Models/Post.php
r3330977 r3357955 27 27 $orderby_array = []; 28 28 foreach ($orderby_fields as $field) { 29 $orderby_array[$field] = $params['order'] ??'ASC';29 $orderby_array[$field] = isset($params['order']) ? $params['order'] : 'ASC'; 30 30 } 31 31 … … 38 38 } else { 39 39 // Single field ordering - always add ID as secondary sort 40 $primary_order = $params['order'] ??'ASC';40 $primary_order = isset($params['order']) ? $params['order'] : 'ASC'; 41 41 $args['orderby'] = [ 42 42 $params['order_by'] => $primary_order, … … 49 49 } 50 50 51 $args['order'] = $params['order'] ??'ASC';51 $args['order'] = isset($params['order']) ? $params['order'] : 'ASC'; 52 52 53 53 // Add date filters if provided … … 64 64 65 65 // Set pagination parameters 66 $requested_offset = $params['skip'] ??0;67 $requested_limit = $params['take'] ??10;66 $requested_offset = isset($params['skip']) ? $params['skip'] : 0; 67 $requested_limit = isset($params['take']) ? $params['take'] : 10; 68 68 69 69 // Update the query with pagination parameters … … 139 139 case 'modified_date': 140 140 $post_data = get_post($post->ID); 141 $data['date_modified'] = $post_data->post_modified_gmt ??null;141 $data['date_modified'] = isset($post_data->post_modified_gmt) ? $post_data->post_modified_gmt : null; 142 142 break; 143 143 case 'permalink': -
muchat-ai/trunk/includes/Models/Product.php
r3330738 r3357955 36 36 $orderby_array = []; 37 37 foreach ($orderby_fields as $field) { 38 $orderby_array[$field] = $params['order'] ??'ASC';38 $orderby_array[$field] = isset($params['order']) ? $params['order'] : 'ASC'; 39 39 } 40 40 … … 47 47 } else { 48 48 // Single field ordering - always add ID as secondary sort 49 $primary_order = $params['order'] ??'ASC';49 $primary_order = isset($params['order']) ? $params['order'] : 'ASC'; 50 50 $args['orderby'] = [ 51 51 $params['order_by'] => $primary_order, … … 58 58 } 59 59 60 $args['order'] = $params['order'] ??'ASC';60 $args['order'] = isset($params['order']) ? $params['order'] : 'ASC'; 61 61 62 62 // Add date filters if provided … … 82 82 83 83 // Set pagination parameters 84 $requested_offset = $params['skip'] ??0;85 $requested_limit = $params['take'] ??30;84 $requested_offset = isset($params['skip']) ? $params['skip'] : 0; 85 $requested_limit = isset($params['take']) ? $params['take'] : 30; 86 86 87 87 // Update the query with pagination parameters … … 192 192 case 'date_modified': 193 193 $post_data = get_post($product->get_id()); 194 $data['date_modified'] = $post_data->post_modified_gmt ??null;194 $data['date_modified'] = isset($post_data->post_modified_gmt) ? $post_data->post_modified_gmt : null; 195 195 break; 196 196 case 'description': -
muchat-ai/trunk/muchat-ai.php
r3332960 r3357955 5 5 * Plugin URI: https://mu.chat 6 6 * Description: Muchat, a powerful tool for customer support using artificial intelligence 7 * Version: 2.0.4 47 * Version: 2.0.45 8 8 * Author: Muchat 9 9 * Text Domain: muchat-ai 10 10 * Domain Path: /languages 11 11 * Requires at least: 5.0 12 * Requires PHP: 7. 412 * Requires PHP: 7.3 13 13 * Author: Muchat Team 14 14 * Author URI: https://mu.chat/about-us … … 27 27 28 28 // Define plugin constants with unique prefix 29 define('MUCHAT_AI_CHATBOT_PLUGIN_VERSION', '2.0.4 4');29 define('MUCHAT_AI_CHATBOT_PLUGIN_VERSION', '2.0.45'); 30 30 // define('MUCHAT_AI_CHATBOT_CACHE_DURATION', HOUR_IN_SECONDS); 31 31 define('MUCHAT_AI_CHATBOT_PLUGIN_FILE', __FILE__); 32 32 define('MUCHAT_AI_CHATBOT_PLUGIN_PATH', plugin_dir_path(__FILE__)); 33 33 define('MUCHAT_AI_CHATBOT_PLUGIN_URL', plugin_dir_url(__FILE__)); 34 35 /** 36 * Setup API isolation to prevent other plugin errors from affecting our API 37 */ 38 function muchat_ai_setup_api_isolation() 39 { 40 // Set up error handler that prevents fatal errors from showing 41 set_error_handler(function($severity, $message, $file, $line) { 42 // Log the error but don't output it 43 error_log("Muchat API Error Caught: $message in $file on line $line"); 44 return true; // Prevent the error from being displayed 45 }); 46 47 // Set up exception handler 48 set_exception_handler(function($exception) { 49 error_log("Muchat API Exception Caught: " . $exception->getMessage()); 50 51 // Send clean JSON error response 52 if (!headers_sent()) { 53 http_response_code(500); 54 header('Content-Type: application/json'); 55 echo json_encode([ 56 'error' => 'Internal server error', 57 'message' => 'A plugin conflict occurred', 58 'timestamp' => current_time('c') 59 ]); 60 } 61 exit; 62 }); 63 64 // Register shutdown function to catch fatal errors 65 register_shutdown_function(function() { 66 $error = error_get_last(); 67 if ($error && in_array($error['type'], [E_ERROR, E_PARSE, E_CORE_ERROR, E_COMPILE_ERROR])) { 68 // Check if this is our API request 69 if (isset($_SERVER['REQUEST_URI']) && strpos($_SERVER['REQUEST_URI'], '/wp-json/muchat-api/') !== false) { 70 if (!headers_sent()) { 71 http_response_code(500); 72 header('Content-Type: application/json'); 73 echo json_encode([ 74 'error' => 'Fatal error occurred', 75 'message' => 'Plugin conflict detected', 76 'debug' => WP_DEBUG ? $error['message'] : 'Enable WP_DEBUG for details', 77 'timestamp' => current_time('c') 78 ]); 79 } 80 } 81 } 82 }); 83 84 // Disable plugin error display 85 ini_set('display_errors', 0); 86 ini_set('log_errors', 1); 87 } 34 88 35 89 // Simple Autoloader … … 83 137 }); 84 138 139 // Isolate our API from other plugin errors 140 if (isset($_SERVER['REQUEST_URI']) && strpos($_SERVER['REQUEST_URI'], '/wp-json/muchat-api/') !== false) { 141 // Set up error isolation for our API 142 muchat_ai_setup_api_isolation(); 143 } 144 85 145 // Run the plugin 86 146 muchat_ai_chatbot_run_plugin(); -
muchat-ai/trunk/readme.txt
r3332960 r3357955 4 4 Requires at least: 5.0 5 5 Tested up to: 6.8 6 Stable tag: 2.0.4 47 Requires PHP: 7. 46 Stable tag: 2.0.45 7 Requires PHP: 7.3 8 8 License: GPLv2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 75 75 76 76 == Changelog == 77 78 = 2.0.45 = 79 * Compatibility: Added PHP 7.3 compatibility - replaced null coalescing operators with isset/ternary for better backward compatibility. 80 * Performance: Implemented error isolation system to prevent other plugin errors from affecting API endpoints. 81 77 82 78 83 = 2.0.44 =
Note: See TracChangeset
for help on using the changeset viewer.