Skip to content

v1.9.0 — search finds post content again

Latest

Choose a tag to compare

@ivanusto ivanusto released this 05 Aug 09:02

Two search defaults change. Existing sites need one manual step — see below.

Constant Was Now
PH_SEARCH_TITLE_ONLY true false
PH_SEARCH_MAX_PAGES 3 10

Matching titles and excerpts only is a large saving, but it makes search results depend on whether an editor happened to put the word in the headline. A keyword that appears in the body of a post was simply unfindable, and nothing on the results page suggested why — visitors just concluded the site had no such article. Coverage now wins by default.

The trade-off is real and unchanged: turning it back on avoids the LIKE '%keyword%' scan over post_content that this plugin exists to contain. If search load is a genuine problem on your site and your keywords tend to live in titles, tick it — the setting is still there, and everything else in search hardening is untouched either way.

The 3-page cap made sense while v1.8.0 was still hiding pagination links. Now that the links are back, a low cap puts visible links in front of visitors that lead to empty pages. 0 removes the cap entirely.

Existing sites: saving the settings screen even once writes every field to the database, and stored values always beat defaults. So this release changes nothing on a site you have already configured. To pick the new behaviour up, go to Settings → Omni Performance Hardening and untick Match titles and excerpts only, then set Result pages limit to 10. Or define the constants in wp-config.php, which overrides both. Fresh installs get the new defaults directly.

Also in this release, from the settings screen:

  • Every field now has a description. Six were bare number boxes with no explanation — both keyword length limits, results per page, archive posts per page and the two Heartbeat intervals. The limits applied on save are stated too: per-page minimum 1, Heartbeat clamped to 15–300. Neither was visible anywhere in the UI before.
  • The three count-related settings are written in plain language rather than SQL_CALC_FOUND_ROWS and found_posts, which meant nothing to the person deciding whether to tick a box. The archive one now also states that tag and taxonomy archives keep their pagination while author and date archives do not — a difference that until now lived only in README.md.

Verified on WordPress 7.0.2: both defaults on a fresh install, an existing option row surviving the upgrade untouched, the constants overriding both, and search results now matching keywords that appear only in post content. Plugin Check clean.

If you want body-text search without the table scan, the real answer is a dedicated search index — Relevanssi, Elasticsearch or similar. This plugin can only keep native LIKE search from getting out of hand; it cannot make it both fast and complete.


兩項搜尋預設值變更。既有站台需要手動操作一步,見下方。

常數 原本 現在
PH_SEARCH_TITLE_ONLY true false
PH_SEARCH_MAX_PAGES 3 10

只比對標題與摘要省下的成本相當可觀,但它會讓搜尋結果取決於編輯有沒有剛好把那個詞寫進標題。只出現在文章內文的關鍵字一律搜尋不到,而結果頁上沒有任何線索指出原因——訪客只會認為站上沒有這篇文章。現在改為涵蓋率優先。

取捨本身沒有變:把它開回去,就能避免對 post_contentLIKE '%關鍵字%' 的全表掃描,而那正是這支外掛存在的理由。若搜尋負載在你的站上確實造成問題、且關鍵字多半落在標題,就勾起來——設定仍在,且不論哪種取捨,搜尋防護的其餘部分都不受影響。

3 頁的上限是在 v1.8.0 仍隱藏分頁連結的前提下才合理。分頁連結恢復後,過低的上限等於把看得到卻通往空白頁的連結放在訪客面前。設為 0 則完全解除上限。

既有站台請注意:後台設定只要儲存過一次,所有欄位都會寫進資料庫,而已儲存的值永遠優先於預設值。 因此這一版對你已經設定過的站台不會有任何改變。要套用新行為,請至「設定 → Omni 效能強化」取消勾選只比對標題與摘要,並將結果頁數上限改為 10;或於 wp-config.php 定義對應常數,其優先序高於兩者。全新安裝則直接適用新預設。

本版另外針對後台設定頁:

  • 每個欄位都有說明文字了。 原本有六個是沒有任何提示的數字框——兩個關鍵字長度限制、每頁筆數、封存頁每頁筆數,以及兩個 Heartbeat 間隔。儲存時套用的夾限也一併寫明:每頁筆數最小 1、Heartbeat 限制在 15–300,這兩項先前在介面上完全看不到。
  • 三個與筆數計算有關的設定改用白話撰寫,不再是 SQL_CALC_FOUND_ROWSfound_posts 這類對「正在決定要不要勾選」的人毫無意義的詞。封存頁那條另外寫明標籤/分類法頁的分頁會保留、作者頁與日期頁不會——此差異先前只記載於 README.md。

已於 WordPress 7.0.2 驗證:全新安裝的兩項新預設、既有 options 於升級後維持不變、常數覆寫兩者,以及搜尋確實能找到只出現在內文的關鍵字。Plugin Check 通過。

若你要的是「內文搜得到又不要全表掃描」,正解是改用專用搜尋索引(Relevanssi、Elasticsearch 等)。本外掛只能把原生 LIKE 搜尋的成本壓住,無法讓它同時又快又完整。

安裝:後台「外掛 → 安裝外掛 → 上傳外掛」上傳附件 ZIP。

完整變更紀錄見 CHANGELOG.md