BUG make bind_manipulation_capture call correctly

When the module was called solr we could call SearchUpdater::bind_manipulation_capture in _config.php, because
solr/_config.php was included after mysite/_config.php. This isnt true when the module is called fulltextsearch

Instead we hook into the new RequestProcessor in 3.0 to make the manipulation capture. We also make
bind_manipulation_capture re-callable, so you can call it any time you need to make sure.
This commit is contained in:
Hamish Friedlander 2012-07-19 12:09:15 +12:00
parent 17be5a3e63
commit 1ee50dd9ab
3 changed files with 26 additions and 2 deletions

View File

@ -1,3 +1,4 @@
<?php
SearchUpdater::bind_manipulation_capture();
global $databaseConfig;
if (isset($databaseConfig['type'])) SearchUpdater::bind_manipulation_capture();

5
_config/binding.yml Normal file
View File

@ -0,0 +1,5 @@
Injector:
RequestProcessor:
properties:
filters:
- '%$SearchUpdater_BindManipulationCaptureFilter'

View File

@ -46,12 +46,17 @@ class SearchUpdater extends Object {
static function bind_manipulation_capture() {
global $databaseConfig;
$connector = DB::getConn();
if (@$connector->isManipulationCapture) return; // If its already captured, just return
$type = $databaseConfig['type'];
$file = TEMP_FOLDER."/.cache.SMC.$type";
if (!is_file($file)) {
file_put_contents($file, "<?php
class SearchManipulateCapture_$type extends $type {
public \$isManipulationCapture = true;
function manipulate(\$manipulation) {
\$res = parent::manipulate(\$manipulation);
SearchUpdater::handle_manipulation(\$manipulation);
@ -62,7 +67,10 @@ class SearchUpdater extends Object {
}
require_once($file);
$databaseConfig['type'] = 'SearchManipulateCapture_'.$type;
$dbClass = 'SearchManipulateCapture_'.$type;
$conn = new $dbClass($databaseConfig);
DB::setConn($conn);
}
static $dirty = array(); static $dirtycount = 0;
@ -255,3 +263,13 @@ class SearchUpdater extends Object {
}
}
}
class SearchUpdater_BindManipulationCaptureFilter implements RequestFilter {
public function preRequest(SS_HTTPRequest $request, Session $session, DataModel $model) {
SearchUpdater::bind_manipulation_capture();
}
public function postRequest(SS_HTTPRequest $request, SS_HTTPResponse $response, DataModel $model) {
/* NOP */
}
}