PluginProbe
WCPOS – Point of Sale (POS) plugin for WooCommerce / 1.10.21
WCPOS – Point of Sale (POS) plugin for WooCommerce v1.10.21
1.10.22 1.10.21 1.10.20 1.10.19 1.10.18 1.10.17 1.10.16 1.10.15 1.10.13 1.10.14 1.10.12 1.10.11 1.10.10 1.10.9 1.10.8 untagged-3d9b7ccddc54df87c672 1.10.7 1.10.6 1.10.5 1.10.3 1.10.4 1.10.2 1.10.1 1.10.0 1.9.17 All 166 releases
← All changes | includes/API/V1/Traits/WCPOS_REST_API.php +6 -22 1.10.18 → 1.10.21 View file →
@@ -14,12 +14,12 @@
14 14 use WCPOS\WooCommercePOS\Services\Pos_Order_Audit;
15 15 use WCPOS\WooCommercePOS\Services\Settings;
16 16 use WCPOS\WooCommercePOS\Sync\Meta_Normalizer;
17 17 use WCPOS\WooCommercePOS\Sync\Pos_Uuid;
18 +use WCPOS\WooCommercePOS\Sync\Response_Telemetry;
18 19 use WP_Error;
19 20 use WP_REST_Request;
20 21 use WP_REST_Response;
21 -use Exception;
22 22
23 23 /**
24 24 * Shared helpers for all WCPOS REST API controllers.
25 25 */
@@ -461,30 +461,14 @@
461 461
462 462 /**
463 463 * Get server load average.
464 464 *
465 + * Same source as the v2 lane's `X-Server-Load`. The former Windows branch
466 + * tested `stristr( PHP_OS, 'win' )`, which also matches `Darwin`, so every
467 + * macOS host shelled out to `wmic` on each bulk-ID request.
468 + *
465 469 * @return array The load average.
466 470 */
467 471 public function get_server_load() {
468 - try {
469 - if ( stristr( PHP_OS, 'win' ) ) {
470 - // Use WMIC to get load percentage from Windows.
471 - $load = @shell_exec( 'wmic cpu get loadpercentage /all' ); // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged
472 - if ( $load ) {
473 - $load = explode( "\n", $load );
474 - if ( isset( $load[1] ) ) {
475 - $load = intval( $load[1] );
476 - return array( $load, $load, $load ); // Mimic the array structure of sys_getloadavg().
477 - }
478 - }
479 - } elseif ( function_exists( 'sys_getloadavg' ) ) {
480 - return sys_getloadavg();
481 - }
482 - } catch ( Exception $e ) {
483 - // Log the error for debugging purposes.
484 - Logger::log( 'Error getting server load: ' . $e->getMessage() );
485 - }
486 -
487 - // Fallback if no method is available or an error occurs.
488 - return array( 0, 0, 0 );
472 + return Response_Telemetry::server_load();
489 473 }
490 474 }