ENHANCEMENT: Added further check in SearchVariant calling routines, to ensure variants can be loaded
This commit is contained in:
parent
a609c60f18
commit
48e95637cd
|
@ -33,6 +33,12 @@ abstract class SearchVariant {
|
|||
*/
|
||||
abstract function activateState($state);
|
||||
|
||||
/** Holds the class dependencies of each variant **/
|
||||
protected static $dependentClasses = array(
|
||||
'Subsite',
|
||||
'Versioned'
|
||||
);
|
||||
|
||||
/*** OVERRIDES end here*/
|
||||
|
||||
/** Holds a cache of all variants */
|
||||
|
@ -60,10 +66,14 @@ abstract class SearchVariant {
|
|||
|
||||
$concrete = array();
|
||||
foreach ($classes as $variantclass) {
|
||||
$ref = new ReflectionClass($variantclass);
|
||||
if ($ref->isInstantiable()) $concrete[$variantclass] = singleton($variantclass);
|
||||
foreach(self::$dependentClasses as $dependency) {
|
||||
// Rather relies on variants being named similalrly to their dependencies
|
||||
if(preg_match("#$dependency#i",$variantclass) && class_exists($dependency)) {
|
||||
$ref = new ReflectionClass($variantclass);
|
||||
if ($ref->isInstantiable()) $concrete[$variantclass] = singleton($variantclass);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
self::$variants = $concrete;
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ class SearchVariantSiteTreeSubsitesPolyhome extends SearchVariant {
|
|||
|
||||
function alterDefinition($base, $index) {
|
||||
$self = get_class($this);
|
||||
|
||||
|
||||
$index->filterFields['_subsite'] = array(
|
||||
'name' => '_subsite',
|
||||
'field' => '_subsite',
|
||||
|
|
|
@ -28,10 +28,10 @@ class SearchVariantVersioned extends SearchVariant {
|
|||
$stage = Versioned::current_stage();
|
||||
$query->filter('_versionedstage', array($stage, SearchQuery::$missing));
|
||||
}
|
||||
|
||||
|
||||
function extractManipulationState(&$manipulation) {
|
||||
$self = get_class($this);
|
||||
|
||||
|
||||
foreach ($manipulation as $table => $details) {
|
||||
$class = $details['class'];
|
||||
$stage = 'Stage';
|
||||
|
|
Loading…
Reference in New Issue