Compare commits
11 Commits
f6b8323e17
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 3c30c613da | |||
| 95f3114127 | |||
| fef2152fe7 | |||
| 99e724323e | |||
| c2c6d90f0c | |||
| 5bd24b1e03 | |||
| d6258eeb00 | |||
| 46d5de9c8c | |||
| d0723c5d0a | |||
| c9378e9c9f | |||
| 8393b213ae |
@@ -3,7 +3,7 @@
|
||||
* Plugin Name: 2meet Data Optimizer — Latepoint AddOn
|
||||
* Plugin URI: https://2meet.io/2meet-data-optimizer/latepoint
|
||||
* Description: LatePoint 預約系統 booking 索引同步(4 hook → wp_hpct_latepoint_idx)
|
||||
* Version: 0.1.0
|
||||
* Version: 0.1.4
|
||||
* Requires at least: 6.0
|
||||
* Tested up to: 6.9.4
|
||||
* Requires PHP: 8.1
|
||||
@@ -24,7 +24,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
define( 'TMDO_LATEPOINT_VERSION', '0.1.0' );
|
||||
define( 'TMDO_LATEPOINT_VERSION', '0.1.4' );
|
||||
define( 'TMDO_LATEPOINT_PATH', plugin_dir_path( __FILE__ ) );
|
||||
define( 'TMDO_LATEPOINT_URL', plugin_dir_url( __FILE__ ) );
|
||||
define( 'TMDO_LATEPOINT_FILE', __FILE__ );
|
||||
|
||||
@@ -13,6 +13,65 @@ Versioning follows [Semantic Versioning](https://semver.org/).
|
||||
|
||||
---
|
||||
|
||||
## [0.1.4] — 2026-10-02 — 重新打包
|
||||
|
||||
### Changed
|
||||
- 重新打包(無功能變更):與 WP-MVB v8 樞紐站(dev39)一同驗收後發版;程式碼與前一版相同。
|
||||
|
||||
---
|
||||
|
||||
## [0.1.3] — 2026-09-27
|
||||
|
||||
Released with 2meet-data-optimizer 1.3.0 (hardening 2.3).
|
||||
|
||||
### Fixed
|
||||
|
||||
- Uninstall on a network of more than 100 sites: `get_sites()` returns 100
|
||||
sites unless `'number' => 0`, so the index table and option were left on
|
||||
the rest. (PR-100)
|
||||
|
||||
---
|
||||
|
||||
## [0.1.2] — 2026-09-26
|
||||
|
||||
### Fixed
|
||||
|
||||
- Uninstall now drops `wp_hpct_latepoint_idx` (every site on multisite) and the
|
||||
`tmdo_latepoint_db_version` option. 0.1.1 started creating the table, but
|
||||
`uninstall.php` was still the Phase 0 stub and left it behind. The table is
|
||||
an index rebuilt from LatePoint's bookings; LatePoint's own tables are kept.
|
||||
|
||||
---
|
||||
|
||||
## [0.1.1] — 2026-08-08 — 補上從未存在的 `wp_hpct_latepoint_idx` 建表流程
|
||||
|
||||
### Fixed
|
||||
|
||||
- **`wp_hpct_latepoint_idx` 從未被建立,索引同步全程靜默失敗(嚴重)。** 這張表
|
||||
在整個 `wp-data-optimizer` / `2meet-data-optimizer` 系譜中**從未有過**
|
||||
`CREATE TABLE` 定義,但 `TMDO_LatePoint_Interceptor::sync_booking()` 一直對它
|
||||
做 INSERT/UPDATE,且整段包在 try/catch 內——在乾淨站台上每一次 booking 同步都
|
||||
會失敗,索引表永遠是空的,而且沒有任何錯誤訊號可循。新增
|
||||
`TMDO_Latepoint_Bootstrap::maybe_install_table()`,以 `dbDelta()` 建立 12 欄表
|
||||
(`booking_id` UNIQUE KEY + `agent_id` / `service_id` / `customer_id` 三個 KEY),
|
||||
並以 `tmdo_latepoint_db_version` option 追蹤版本。刻意**不**只掛
|
||||
`register_activation_hook()`:本外掛多以 git pull 部署、不會經過停用/啟用循環,
|
||||
唯有版本 option 才能確保既有安裝也補建到表。
|
||||
- `TMDO_Custom_Table_Registry::register()` 的索引期望值 config key 由
|
||||
`expected_indexes` 更正為 `indexes`。該 API 以 `wp_parse_args()` 併入預設值,
|
||||
未知 key 會被**靜默丟棄**——先前索引期望值等同從未送達 registry,
|
||||
`wp wpdo doctor` 的 schema drift 只驗欄位、不驗索引。此問題橫跨全部 8 個 AddOn,
|
||||
已一併更正。
|
||||
|
||||
### Added
|
||||
|
||||
- `TMDO_Latepoint_Bootstrap::register_custom_tables()`:把 `hpct_latepoint_idx`
|
||||
註冊進 `TMDO_Custom_Table_Registry`(12 欄 `expected_columns` + 4 個 `indexes`),
|
||||
讓 `wp wpdo doctor` / `benchmark` / `cleanup` 能治理此表。此前這張表對 TMDO
|
||||
治理工具完全不可見。
|
||||
|
||||
---
|
||||
|
||||
## [0.1.0] — TBD
|
||||
|
||||
### Added (initial release, scaffold)
|
||||
|
||||
@@ -12,6 +12,9 @@ if ( ! defined( 'ABSPATH' ) ) {
|
||||
|
||||
final class TMDO_Latepoint_Bootstrap {
|
||||
|
||||
const DB_VERSION_OPTION = 'tmdo_latepoint_db_version';
|
||||
const DB_VERSION = '0.1.0';
|
||||
|
||||
public static function init(): void {
|
||||
if ( ! class_exists( 'TMDO_API' ) && ! class_exists( 'WPDO_API' ) ) {
|
||||
add_action( 'admin_notices', array( __CLASS__, 'missing_core_notice' ) );
|
||||
@@ -24,6 +27,9 @@ final class TMDO_Latepoint_Bootstrap {
|
||||
dirname( plugin_basename( TMDO_LATEPOINT_FILE ) ) . '/languages'
|
||||
);
|
||||
|
||||
self::maybe_install_table();
|
||||
add_action( 'wpdo_register_custom_tables', array( __CLASS__, 'register_custom_tables' ) );
|
||||
|
||||
require_once TMDO_LATEPOINT_PATH . 'includes/class-tmdo-latepoint-interceptor.php';
|
||||
|
||||
if ( class_exists( 'TMDO_LatePoint_Interceptor' ) ) {
|
||||
@@ -36,4 +42,86 @@ final class TMDO_Latepoint_Bootstrap {
|
||||
echo esc_html__( '2meet Data Optimizer LatePoint AddOn 需要 2meet-data-optimizer 核心外掛,請先安裝並啟用。', 'tmdo-latepoint' );
|
||||
echo '</p></div>';
|
||||
}
|
||||
|
||||
/**
|
||||
* 建立 wp_hpct_latepoint_idx 表(若尚未存在或版本落後)。
|
||||
*
|
||||
* 這張表在整個 wp-data-optimizer / 2meet-data-optimizer 系譜中從未有過
|
||||
* CREATE TABLE 定義——TMDO_LatePoint_Interceptor::sync_booking() 一直對著
|
||||
* 一張可能不存在的表做 INSERT/UPDATE(外包在 try/catch 內靜默失敗)。
|
||||
* 用 dbDelta version option(而非只掛 register_activation_hook)確保即使
|
||||
* 外掛是透過 git pull 部署、未經停用/啟用循環也能補建表。
|
||||
*/
|
||||
public static function maybe_install_table(): void {
|
||||
if ( get_option( self::DB_VERSION_OPTION ) === self::DB_VERSION ) {
|
||||
return;
|
||||
}
|
||||
global $wpdb;
|
||||
require_once ABSPATH . 'wp-admin/includes/upgrade.php';
|
||||
|
||||
$table = class_exists( 'TMDO_DB' ) ? TMDO_DB::table( 'hpct_latepoint_idx' ) : $wpdb->prefix . 'hpct_latepoint_idx';
|
||||
$charset = $wpdb->get_charset_collate();
|
||||
$sql = "CREATE TABLE {$table} (
|
||||
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
booking_id BIGINT NOT NULL,
|
||||
agent_id BIGINT NOT NULL DEFAULT 0,
|
||||
service_id BIGINT NOT NULL DEFAULT 0,
|
||||
customer_id BIGINT NOT NULL DEFAULT 0,
|
||||
status VARCHAR(50) NOT NULL DEFAULT '',
|
||||
start_date VARCHAR(20) DEFAULT NULL,
|
||||
end_date VARCHAR(20) DEFAULT NULL,
|
||||
start_time INT NOT NULL DEFAULT 0,
|
||||
end_time INT NOT NULL DEFAULT 0,
|
||||
price VARCHAR(20) NOT NULL DEFAULT '0',
|
||||
created_at DATETIME NOT NULL,
|
||||
PRIMARY KEY (id),
|
||||
UNIQUE KEY booking_id (booking_id),
|
||||
KEY agent_id (agent_id),
|
||||
KEY service_id (service_id),
|
||||
KEY customer_id (customer_id)
|
||||
) {$charset};";
|
||||
dbDelta( $sql );
|
||||
update_option( self::DB_VERSION_OPTION, self::DB_VERSION, false );
|
||||
}
|
||||
|
||||
/**
|
||||
* 註冊 wp_hpct_latepoint_idx 到 TMDO Custom Table Registry,
|
||||
* 讓 `wp wpdo doctor`/`benchmark`/`cleanup` 能治理此表。
|
||||
*
|
||||
* @param mixed $registry TMDO_Custom_Table_Registry instance(loose typing 容錯舊版別名)。
|
||||
*/
|
||||
public static function register_custom_tables( $registry ): void {
|
||||
if ( ! is_object( $registry ) || ! method_exists( $registry, 'register' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$registry->register(
|
||||
'2meet-data-optimizer-latepoint-addon',
|
||||
array(
|
||||
'table_name' => 'hpct_latepoint_idx',
|
||||
'primary_key' => 'id',
|
||||
'post_type_link' => null,
|
||||
'expected_columns' => array(
|
||||
'id' => 'BIGINT',
|
||||
'booking_id' => 'BIGINT',
|
||||
'agent_id' => 'BIGINT',
|
||||
'service_id' => 'BIGINT',
|
||||
'customer_id' => 'BIGINT',
|
||||
'status' => 'VARCHAR',
|
||||
'start_date' => 'VARCHAR',
|
||||
'end_date' => 'VARCHAR',
|
||||
'start_time' => 'INT',
|
||||
'end_time' => 'INT',
|
||||
'price' => 'VARCHAR',
|
||||
'created_at' => 'DATETIME',
|
||||
),
|
||||
'indexes' => array(
|
||||
'booking_id' => array( 'booking_id' ),
|
||||
'agent_id' => array( 'agent_id' ),
|
||||
'service_id' => array( 'service_id' ),
|
||||
'customer_id' => array( 'customer_id' ),
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
+24
-1
@@ -11,4 +11,27 @@ if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
// Phase 3 完整實作。Phase 0 stub:保留所有資料以避免誤刪。
|
||||
// wp_hpct_latepoint_idx is an index rebuilt from LatePoint's own bookings, so
|
||||
// dropping it loses no data; LatePoint's tables are left untouched.
|
||||
global $wpdb;
|
||||
|
||||
// 'number' => 0: get_sites() returns only 100 sites by default.
|
||||
$tmdo_latepoint_blogs = is_multisite()
|
||||
? get_sites(
|
||||
array(
|
||||
'fields' => 'ids',
|
||||
'number' => 0,
|
||||
)
|
||||
)
|
||||
: array( get_current_blog_id() );
|
||||
foreach ( $tmdo_latepoint_blogs as $tmdo_latepoint_blog ) {
|
||||
if ( is_multisite() ) {
|
||||
switch_to_blog( $tmdo_latepoint_blog );
|
||||
}
|
||||
$tmdo_latepoint_table = $wpdb->prefix . 'hpct_latepoint_idx';
|
||||
$wpdb->query( "DROP TABLE IF EXISTS `{$tmdo_latepoint_table}`" ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching,WordPress.DB.DirectDatabaseQuery.SchemaChange
|
||||
delete_option( 'tmdo_latepoint_db_version' );
|
||||
if ( is_multisite() ) {
|
||||
restore_current_blog();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user