mirror of
https://github.com/silverstripe/silverstripe-fulltextsearch
synced 2024-10-22 12:05:29 +00:00
FIX Throw error if trying to add a table-less DataObject class to index
Its impossible for SearchUpdater#handle_manipulation to figure out the difference between writing to a table-less class (like Page if theres no $db set) and the table-having parent (like SiteTree) because it only examines the DB manipulation This meant if you tried to index Page without setting $db fields, only subclasses that did have $db fields would be indexed We cant fix, but we can throw an error if you try to do that
This commit is contained in:
parent
f9998a2266
commit
b2098a3ebf
@ -187,6 +187,10 @@ abstract class SearchIndex extends ViewableData {
|
||||
throw new Exception('Can\'t add class to Index after fields have already been added');
|
||||
}
|
||||
|
||||
if (!DataObject::has_own_table($class)) {
|
||||
throw new InvalidArgumentException('Can\'t add classes which don\'t have data tables (no $db or $has_one set on the class)');
|
||||
}
|
||||
|
||||
$options = array_merge(array(
|
||||
'include_children' => true
|
||||
), $options);
|
||||
|
Loading…
x
Reference in New Issue
Block a user