mirror of
https://github.com/silverstripe/silverstripe-fulltextsearch
synced 2024-10-22 12:05:29 +00:00
Merge pull request #114 from tractorcow/pulls/fix-versioned-writes
BUG Fix versioned writes where subtables have no fields key
This commit is contained in:
commit
2067786e7f
@ -90,14 +90,14 @@ class SearchUpdater extends Object
|
||||
$writes = array();
|
||||
|
||||
foreach ($manipulation as $table => $details) {
|
||||
if (!isset($details['id']) || !isset($details['fields'])) {
|
||||
if (!isset($details['id'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$id = $details['id'];
|
||||
$state = $details['state'];
|
||||
$class = $details['class'];
|
||||
$fields = $details['fields'];
|
||||
$fields = isset($details['fields']) ? $details['fields'] : array();
|
||||
|
||||
$base = ClassInfo::baseDataClass($class);
|
||||
$key = "$id:$base:".serialize($state);
|
||||
@ -125,6 +125,13 @@ class SearchUpdater extends Object
|
||||
}
|
||||
}
|
||||
|
||||
// Trim records without fields
|
||||
foreach(array_keys($writes) as $key) {
|
||||
if(empty($writes[$key]['fields'])) {
|
||||
unset($writes[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
// Then extract any state that is needed for the writes
|
||||
|
||||
SearchVariant::call('extractManipulationWriteState', $writes);
|
||||
|
@ -66,7 +66,6 @@ class BatchedProcessorTest extends SapphireTest
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
Config::nest();
|
||||
|
||||
if (!interface_exists('QueuedJob')) {
|
||||
$this->skipTest = true;
|
||||
@ -102,8 +101,6 @@ class BatchedProcessorTest extends SapphireTest
|
||||
if ($this->oldProcessor) {
|
||||
SearchUpdater::$processor = $this->oldProcessor;
|
||||
}
|
||||
Config::unnest();
|
||||
Injector::inst()->unregisterNamedObject('QueuedJobService');
|
||||
FullTextSearch::force_index_list();
|
||||
parent::tearDown();
|
||||
}
|
||||
|
@ -87,8 +87,6 @@ class SearchUpdaterTest extends SapphireTest
|
||||
|
||||
SearchUpdater::bind_manipulation_capture();
|
||||
|
||||
Config::nest();
|
||||
|
||||
Config::inst()->update('Injector', 'SearchUpdateProcessor', array(
|
||||
'class' => 'SearchUpdateImmediateProcessor'
|
||||
));
|
||||
@ -97,13 +95,6 @@ class SearchUpdaterTest extends SapphireTest
|
||||
SearchUpdater::clear_dirty_indexes();
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
{
|
||||
Config::unnest();
|
||||
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
public function testBasic()
|
||||
{
|
||||
$item = new SearchUpdaterTest_Container();
|
||||
|
@ -2,6 +2,9 @@
|
||||
|
||||
class SearchVariantVersionedTest extends SapphireTest
|
||||
{
|
||||
/**
|
||||
* @var SearchVariantVersionedTest_Index
|
||||
*/
|
||||
private static $index = null;
|
||||
|
||||
protected $extraDataObjects = array(
|
||||
@ -23,8 +26,6 @@ class SearchVariantVersionedTest extends SapphireTest
|
||||
|
||||
SearchUpdater::bind_manipulation_capture();
|
||||
|
||||
Config::nest();
|
||||
|
||||
Config::inst()->update('Injector', 'SearchUpdateProcessor', array(
|
||||
'class' => 'SearchUpdateImmediateProcessor'
|
||||
));
|
||||
@ -33,13 +34,6 @@ class SearchVariantVersionedTest extends SapphireTest
|
||||
SearchUpdater::clear_dirty_indexes();
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
{
|
||||
Config::unnest();
|
||||
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
public function testPublishing()
|
||||
{
|
||||
// Check that write updates Stage
|
||||
@ -71,9 +65,13 @@ class SearchVariantVersionedTest extends SapphireTest
|
||||
$item->write();
|
||||
|
||||
SearchUpdater::flush_dirty_indexes();
|
||||
$this->assertEquals(self::$index->getAdded(array('ID', '_versionedstage')), array(
|
||||
array('ID' => $item->ID, '_versionedstage' => 'Stage')
|
||||
|
||||
$expected = array(array(
|
||||
'ID' => $item->ID,
|
||||
'_versionedstage' => 'Stage'
|
||||
));
|
||||
$added = self::$index->getAdded(array('ID', '_versionedstage'));
|
||||
$this->assertEquals($expected, $added);
|
||||
}
|
||||
|
||||
public function testExcludeVariantState()
|
||||
|
@ -12,12 +12,12 @@ class SolrIndexTest extends SapphireTest
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
if (!class_exists('Phockito')) {
|
||||
$this->markTestSkipped("These tests need the Phockito module installed to run");
|
||||
$this->skipTest = true;
|
||||
}
|
||||
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
public function testFieldDataHasOne()
|
||||
|
@ -35,8 +35,6 @@ class SolrIndexVersionedTest extends SapphireTest
|
||||
|
||||
SearchUpdater::bind_manipulation_capture();
|
||||
|
||||
Config::nest();
|
||||
|
||||
Config::inst()->update('Injector', 'SearchUpdateProcessor', array(
|
||||
'class' => 'SearchUpdateImmediateProcessor'
|
||||
));
|
||||
@ -51,7 +49,6 @@ class SolrIndexVersionedTest extends SapphireTest
|
||||
public function tearDown()
|
||||
{
|
||||
Versioned::set_reading_mode($this->oldMode);
|
||||
Config::unnest();
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user