diff options
| author | Lester Caine <lester@lsces.co.uk> | 2026-05-20 16:43:50 +0100 |
|---|---|---|
| committer | Lester Caine <lester@lsces.co.uk> | 2026-05-20 16:43:50 +0100 |
| commit | 6116768df56c3085073953e78e605752071116c4 (patch) | |
| tree | 9c0ec67e0285684e5020d478a4a603f583827a17 /includes | |
| parent | 2d9e56ca5f29c9dc1e295f534d1be18ed11df9a7 (diff) | |
| download | search-6116768df56c3085073953e78e605752071116c4.tar.gz search-6116768df56c3085073953e78e605752071116c4.tar.bz2 search-6116768df56c3085073953e78e605752071116c4.zip | |
Fix Index On Submit flag logic and session lock on save
bit_setup_inc.php: flag was previously ignored — refresh_index was
always called synchronously on save regardless of setting, and the flag
only controlled the background random refresh. Now correctly:
- Flag ON: index synchronously on every save (refresh_index)
- Flag OFF: background random refresh only, no synchronous indexing
refresh_functions.php: add session_write_close() before indexing in
refresh_index() so the session lock is released before the per-word
INSERT loop, preventing 'not found' on redirect after saving large pages.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'includes')
| -rwxr-xr-x | includes/bit_setup_inc.php | 14 | ||||
| -rwxr-xr-x | includes/refresh_functions.php | 1 |
2 files changed, 9 insertions, 6 deletions
diff --git a/includes/bit_setup_inc.php b/includes/bit_setup_inc.php index 2c8ad5e..0e6f064 100755 --- a/includes/bit_setup_inc.php +++ b/includes/bit_setup_inc.php @@ -28,13 +28,15 @@ if( $gBitSystem->isPackageActive( 'search' ) ) { $gBitSystem->registerAppMenu( $menuHash ); // ********** SEARCH ************ - // Register the search refresh function - // But only if the Index On Submit isn't set - if( ! $gBitSystem->isFeatureActive("search_index_on_submit") ) { + include_once SEARCH_PKG_INCLUDE_PATH . 'refresh_functions.php'; + if( $gBitSystem->isFeatureActive("search_index_on_submit") ) { + // Index synchronously on every save + $gLibertySystem->registerService( LIBERTY_SERVICE_SEARCH, SEARCH_PKG_NAME, + [ 'content_store_function' => 'refresh_index'] ); + } else { + // Background random refresh only — no synchronous indexing on save include_once SEARCH_PKG_INCLUDE_PATH . 'refresh.php'; register_shutdown_function("\\Bitweaver\\Liberty\\refresh_search_index"); + $gLibertySystem->registerService( LIBERTY_SERVICE_SEARCH, SEARCH_PKG_NAME, [] ); } - include_once SEARCH_PKG_INCLUDE_PATH . 'refresh_functions.php'; - $gLibertySystem->registerService( LIBERTY_SERVICE_SEARCH, SEARCH_PKG_NAME, - [ 'content_store_function' => 'refresh_index'], ); }
\ No newline at end of file diff --git a/includes/refresh_functions.php b/includes/refresh_functions.php index 5cfa144..cb5f0bd 100755 --- a/includes/refresh_functions.php +++ b/includes/refresh_functions.php @@ -69,6 +69,7 @@ function random_refresh_index($pContentType = "") { function refresh_index( $pContentObject = null ) { global $gBitSystem; if (is_object($pContentObject)) { + session_write_close(); if ( (!isset($pContentObject->mInfo["index_data"])) and method_exists($pContentObject, 'setIndexData')) { $pContentObject->setIndexData() ; } |
