# woocommerce-pos/1.10.18/includes/Sync/Health.php

WCPOS – Point of Sale (POS) plugin for WooCommerce, version 1.10.18. 85 lines.

- Page: https://pluginprobe.com/plugins/woocommerce-pos/1.10.18/code/includes/Sync/Health.php
- Raw: https://pluginprobe.com/plugins/woocommerce-pos/1.10.18/raw/includes/Sync/Health.php
- Modified: 2026-08-25T07:52:20+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/woocommerce-pos/1.10.18/code/includes/Sync/Health.php#L10-L20`.

```php
<?php
/**
 * Sync store health checks.
 *
 * @package WCPOS\WooCommercePOS\Sync
 */

namespace WCPOS\WooCommercePOS\Sync;

/**
 * Checks whether the sync store tables are installed.
 */
final class Health {
	public const SYNC_JOURNAL_TABLE  = 'wcpos_sync_journal';
	public const STORED_DIGEST_TABLE = 'wcpos_sync_stored_digest';
	public const MUTATIONS_TABLE     = 'wcpos_sync_mutations';
	/** Schema-install retry hint exposed to WCPOS clients. */
	public const RETRY_AFTER_SECONDS = 30;

	/**
	 * Check whether a database table exists.
	 *
	 * @param string $table Fully qualified table name.
	 */
	public static function table_exists( string $table ): bool {
		global $wpdb;

		// phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared -- The known table name is escaped for LIKE and must not be double-escaped by prepare().
		return $table === $wpdb->get_var( "SHOW TABLES LIKE '" . $wpdb->esc_like( $table ) . "'" );
	}

	/**
	 * Get the fully qualified sync store table names.
	 *
	 * @return string[] Sync store table names.
	 */
	public static function required_tables(): array {
		global $wpdb;

		return array(
			$wpdb->prefix . self::SYNC_JOURNAL_TABLE,
			$wpdb->prefix . self::STORED_DIGEST_TABLE,
			$wpdb->prefix . self::MUTATIONS_TABLE,
		);
	}

	/**
	 * Get sync store tables that have not been installed.
	 *
	 * @return string[] Missing sync store table names.
	 */
	public static function missing_tables(): array {
		$missing_tables = array();

		foreach ( self::required_tables() as $table ) {
			if ( ! self::table_exists( $table ) ) {
				$missing_tables[] = $table;
			}
		}

		return $missing_tables;
	}

	/**
	 * Check whether all required sync store tables exist.
	 */
	public static function is_healthy(): bool {
		return 0 === \count( self::missing_tables() );
	}

	/**
	 * Get the error returned when the sync store is unavailable.
	 */
	public static function unhealthy_error(): \WP_Error {
		return new \WP_Error(
			'wcpos_sync_unavailable',
			__( 'The WCPOS sync store is not installed yet (initialising or a schema install failed). Retry shortly.', 'woocommerce-pos' ),
			array(
				'status'              => 503,
				'retry_after_seconds' => self::RETRY_AFTER_SECONDS,
			)
		);
	}
}

```
