hardening 2.0: 2meet-data-optimizer (staged rollout, dev22 first) #3
Reference in New Issue
Block a user
Delete Branch "hardening/2.0"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Hardening 2.0 for
2meet-data-optimizer— the backlog PRs committed onhardening/2.0(seedev30/notes/pr-backlog.md, Completed Log).Commits
Rollout
評估 NinjaFirewall (WP Edition) 4.9 的相容性,結論是兩者可共存且 不需要開發 AddOn(該外掛全 codebase 零個 apply_filters('nfw_*') / do_action('nfw_*'),官方相容手段全在部署層)。但核心有一個隱患必須補。 TMDO_Options_Manager::register_settings_group() 以 pre_update_option_{key} 回傳 $old_value,讓選項不再落地 wp_options、改存專屬設定表。而 NinjaFirewall 的 Full WAF 走 auto_prepend_file,在 WordPress 載入前就以 原生 mysqli 直查 wp_options 取 nfw_options / nfw_rules。一旦這些鍵被 重導向,WAF 會讀不到設定而靜默停止防護 —— 不報錯、不寫 log。 nfw_rules 約 77KB 且 autoload=auto,正是 autoload 瘦身最誘人的目標, 因此這條路徑並非理論風險。 Added - PROTECTED_OPTIONS 常數與註冊守衛(nfw_options / nfw_rules / nfw_checked), 命中時發出 _doing_it_wrong()。守衛置於方法開頭,全部鍵都被擋時提前返回, 不再建立空的設定表。 - tests/unit/OptionsManagerProtectedTest.php(4 tests / 10 assertions), 鎖住「受保護鍵絕不會被掛上 pre_option_* / pre_update_option_* 攔截」。 - docs/WAF-COMPATIBILITY.md:模式差異、symlink 多租戶部署、WP SaaS 開站 流程與驗證清單、三條開發約束、實測風險矩陣。 Changed - Migration Wizard 輪詢 500ms → 2s,與四個 stress-test 面板一致。 原本 2 req/s 打同一 REST endpoint,易觸發 WAF rate-limit 與 bot 偵測。 autoload 最佳化不受影響:optimize_autoload() 只改 autoload 欄位、不刪列, 而 Full WAF 的 SELECT * 不看 autoload。 驗證:591 tests / 1166 assertions 通過,PHPCS 零違規,版本一致性 1.0.2。 dev30 於 Full WAF 與 WP WAF 兩種模式下實測,firewall log 中 TMDO 相關 攔截 0 筆。 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SdjXAU473eekjPBB8vPVRS- TMDO_Post_Status_Sync: post group tables get post_status / post_date columns (posts' collation) and an (post_status, post_date) index. Brand-new empty tables get them on creation; existing tables only via `wp tmdo post-status-sync [--dry-run] [--batch]`, never as DDL on a populated table in a web request. Per-group state in tmdo_post_status_columns ('columns' | 'ready'). - transition_post_status refreshes the copies; Hook Bus upserts that create a post row fill them in (existing rows keep theirs). - Bench (1M rows): add columns 0.05 s, index 5.3 s, batched backfill 32 s, 0 mismatches afterwards. - Verify: core unit 659 / integration 466 green, phpcs clean - PR: PR-028- CI PHPStan (level 6, baseline for pre-existing debt) failed on 35 errors in code added on hardening/2.0: missing iterable value types (PHPDoc only), a redundant method_exists() in uninstall.php, and the new WP-CLI commands registered as array('Class', 'instanceMethod') — now array(new Class(), ...) - Local runs had been masked by a PHPStan tmpDir shared with the act CI runner (cached container pointing at a removed phar); use a private tmpDir - Verify: phpstan (private tmpDir) no errors, phpcs clean on changed files, phpunit Unit 658 OK; dev22 (running this branch) CLI post-status-sync / bridge-restore-native dry runs OK