mirror of
https://github.com/silverstripe/silverstripe-fulltextsearch
synced 2024-10-22 14:05:29 +02:00
FIX Run phpcbf automated linting to fix PSR-2 code styles, add PSR-4 autoloader
This commit is contained in:
parent
1080d6444a
commit
e590132967
@ -1,7 +1,9 @@
|
||||
<?php
|
||||
namespace SilverStripe\FullTextSearch\Search;
|
||||
|
||||
use SilverStripe\Core\ClassInfo;
|
||||
use SilverStripe\ORM\DataObject;
|
||||
|
||||
/**
|
||||
* Some additional introspection tools that are used often by the fulltext search code
|
||||
*/
|
||||
@ -48,13 +50,13 @@ class SearchIntrospection
|
||||
array_splice($classes, 0, $idx+1);
|
||||
}
|
||||
|
||||
if ($dataOnly) {
|
||||
foreach ($classes as $i => $class) {
|
||||
if (!DataObject::getSchema()->classHasTable($class)) {
|
||||
unset($classes[$i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($dataOnly) {
|
||||
foreach ($classes as $i => $class) {
|
||||
if (!DataObject::getSchema()->classHasTable($class)) {
|
||||
unset($classes[$i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
self::$hierarchy[$key] = $classes;
|
||||
}
|
||||
|
@ -5,11 +5,13 @@ namespace SilverStripe\FullTextSearch\Captures;
|
||||
use SilverStripe\ORM\Connect\MySQLDatabase;
|
||||
use SilverStripe\FullTextSearch\Search\Updaters\SearchUpdater;
|
||||
|
||||
class SearchManipulateCapture_MySQLDatabase extends MySQLDatabase {
|
||||
class SearchManipulateCapture_MySQLDatabase extends MySQLDatabase
|
||||
{
|
||||
|
||||
public $isManipulationCapture = true;
|
||||
|
||||
public function manipulate($manipulation) {
|
||||
public function manipulate($manipulation)
|
||||
{
|
||||
$res = parent::manipulate($manipulation);
|
||||
SearchUpdater::handle_manipulation($manipulation);
|
||||
return $res;
|
||||
|
@ -9,11 +9,13 @@ if (!class_exists('PostgreSQLDatabase')) {
|
||||
return;
|
||||
}
|
||||
|
||||
class SearchManipulateCapture_PostgreSQLDatabase extends PostgreSQLDatabase {
|
||||
class SearchManipulateCapture_PostgreSQLDatabase extends PostgreSQLDatabase
|
||||
{
|
||||
|
||||
public $isManipulationCapture = true;
|
||||
|
||||
public function manipulate($manipulation) {
|
||||
public function manipulate($manipulation)
|
||||
{
|
||||
$res = parent::manipulate($manipulation);
|
||||
SearchUpdater::handle_manipulation($manipulation);
|
||||
return $res;
|
||||
|
@ -9,11 +9,13 @@ if (!class_exists('SQLite3Database')) {
|
||||
return;
|
||||
}
|
||||
|
||||
class SearchManipulateCapture_SQLite3Database extends SQLite3Database {
|
||||
class SearchManipulateCapture_SQLite3Database extends SQLite3Database
|
||||
{
|
||||
|
||||
public $isManipulationCapture = true;
|
||||
|
||||
public function manipulate($manipulation) {
|
||||
public function manipulate($manipulation)
|
||||
{
|
||||
$res = parent::manipulate($manipulation);
|
||||
SearchUpdater::handle_manipulation($manipulation);
|
||||
return $res;
|
||||
|
@ -26,7 +26,7 @@ abstract class SearchUpdateBatchedProcessor extends SearchUpdateProcessor
|
||||
|
||||
/**
|
||||
* List of indexes successfully comitted in the current batch
|
||||
*
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $completedIndexes;
|
||||
@ -43,7 +43,7 @@ abstract class SearchUpdateBatchedProcessor extends SearchUpdateProcessor
|
||||
/**
|
||||
* Up to this number of additional ids can be added to any batch in order to reduce the number
|
||||
* of batches
|
||||
*
|
||||
*
|
||||
* @config
|
||||
* @var int
|
||||
*/
|
||||
@ -59,7 +59,7 @@ abstract class SearchUpdateBatchedProcessor extends SearchUpdateProcessor
|
||||
|
||||
/**
|
||||
* Set the current batch index
|
||||
*
|
||||
*
|
||||
* @param int $batch Index of the batch
|
||||
*/
|
||||
protected function setBatch($batch)
|
||||
@ -76,7 +76,7 @@ abstract class SearchUpdateBatchedProcessor extends SearchUpdateProcessor
|
||||
|
||||
/**
|
||||
* Process the current queue
|
||||
*
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function process()
|
||||
@ -101,7 +101,7 @@ abstract class SearchUpdateBatchedProcessor extends SearchUpdateProcessor
|
||||
|
||||
/**
|
||||
* Segments batches acording to the specified rules
|
||||
*
|
||||
*
|
||||
* @param array $source Source input
|
||||
* @return array Batches
|
||||
*/
|
||||
|
@ -266,7 +266,7 @@ class SearchUpdateCommitJobProcessor implements QueuedJob
|
||||
$this->indexes = $jobData->indexes;
|
||||
}
|
||||
|
||||
public function addMessage($message, $severity='INFO')
|
||||
public function addMessage($message, $severity = 'INFO')
|
||||
{
|
||||
$severity = strtoupper($severity);
|
||||
$this->messages[] = '[' . date('Y-m-d H:i:s') . "][$severity] $message";
|
||||
|
@ -10,7 +10,7 @@ abstract class SearchUpdateProcessor
|
||||
{
|
||||
/**
|
||||
* List of dirty records to process in format
|
||||
*
|
||||
*
|
||||
* array(
|
||||
* '$BaseClass' => array(
|
||||
* '$State Key' => array(
|
||||
@ -62,7 +62,7 @@ abstract class SearchUpdateProcessor
|
||||
|
||||
/**
|
||||
* Generates the list of indexes to process for the dirty items
|
||||
*
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function prepareIndexes()
|
||||
@ -112,7 +112,7 @@ abstract class SearchUpdateProcessor
|
||||
|
||||
/**
|
||||
* Commits the specified index to the Solr service
|
||||
*
|
||||
*
|
||||
* @param SolrIndex $index Index object
|
||||
* @return bool Flag indicating success
|
||||
*/
|
||||
@ -123,7 +123,7 @@ abstract class SearchUpdateProcessor
|
||||
|
||||
/**
|
||||
* Gets the record data source to process
|
||||
*
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getSource()
|
||||
@ -133,7 +133,7 @@ abstract class SearchUpdateProcessor
|
||||
|
||||
/**
|
||||
* Process all indexes, returning true if successful
|
||||
*
|
||||
*
|
||||
* @return bool Flag indicating success
|
||||
*/
|
||||
public function process()
|
||||
|
@ -90,7 +90,7 @@ class SearchUpdateQueuedJobProcessor extends SearchUpdateBatchedProcessor implem
|
||||
$this->currentBatch = $jobData->currentBatch;
|
||||
}
|
||||
|
||||
public function addMessage($message, $severity='INFO')
|
||||
public function addMessage($message, $severity = 'INFO')
|
||||
{
|
||||
$severity = strtoupper($severity);
|
||||
$this->messages[] = '[' . date('Y-m-d H:i:s') . "][$severity] $message";
|
||||
|
@ -56,7 +56,7 @@ class SearchQuery extends ViewableData
|
||||
* Similar to {@link search()}, but uses stemming and other similarity algorithms
|
||||
* to find the searched terms. For example, a term "fishing" would also likely find results
|
||||
* containing "fish" or "fisher". Depends on search implementation.
|
||||
*
|
||||
*
|
||||
* @param String $text See {@link search()}
|
||||
* @param array $fields See {@link search()}
|
||||
* @param array $boost See {@link search()}
|
||||
@ -74,7 +74,7 @@ class SearchQuery extends ViewableData
|
||||
/**
|
||||
* Similar to {@link search()}, but typically used to further narrow down
|
||||
* based on other facets which don't influence the field relevancy.
|
||||
*
|
||||
*
|
||||
* @param String $field Composite name of the field
|
||||
* @param Mixed $values Scalar value, array of values, or an instance of SearchQuery_Range
|
||||
*/
|
||||
@ -87,7 +87,7 @@ class SearchQuery extends ViewableData
|
||||
|
||||
/**
|
||||
* Excludes results which match these criteria, inverse of {@link filter()}.
|
||||
*
|
||||
*
|
||||
* @param String $field
|
||||
* @param mixed $values
|
||||
*/
|
||||
@ -124,5 +124,3 @@ class SearchQuery extends ViewableData
|
||||
return "Search Query\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -31,4 +31,4 @@ class SearchQuery_Range
|
||||
{
|
||||
return $this->start !== null || $this->end !== null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -127,8 +127,7 @@ class SearchUpdater
|
||||
'command' => $command,
|
||||
'fields' => array()
|
||||
);
|
||||
}
|
||||
// Otherwise update the class label if it's more specific than the currently recorded one
|
||||
} // Otherwise update the class label if it's more specific than the currently recorded one
|
||||
elseif (is_subclass_of($class, $writes[$key]['class'])) {
|
||||
$writes[$key]['class'] = $class;
|
||||
}
|
||||
|
@ -152,7 +152,7 @@ abstract class SearchVariant
|
||||
*
|
||||
* SearchVariant::call(...) ==== SearchVariant::with()->call(...);
|
||||
*/
|
||||
public static function call($method, &$a1=null, &$a2=null, &$a3=null, &$a4=null, &$a5=null, &$a6=null, &$a7=null)
|
||||
public static function call($method, &$a1 = null, &$a2 = null, &$a3 = null, &$a4 = null, &$a5 = null, &$a6 = null, &$a7 = null)
|
||||
{
|
||||
return self::with()->call($method, $a1, $a2, $a3, $a4, $a5, $a6, $a7);
|
||||
}
|
||||
@ -219,9 +219,10 @@ abstract class SearchVariant
|
||||
* @param string $name Field name
|
||||
* @param array $field Field spec
|
||||
*/
|
||||
protected function addFilterField($index, $name, $field) {
|
||||
protected function addFilterField($index, $name, $field)
|
||||
{
|
||||
// If field already exists, make sure to merge origin / base fields
|
||||
if(isset($index->filterFields[$name])) {
|
||||
if (isset($index->filterFields[$name])) {
|
||||
$field['base'] = $this->mergeClasses(
|
||||
$index->filterFields[$name]['base'],
|
||||
$field['base']
|
||||
@ -244,21 +245,21 @@ abstract class SearchVariant
|
||||
* @param array|string $right Right class(es)
|
||||
* @return array|string List of classes, or single class
|
||||
*/
|
||||
protected function mergeClasses($left, $right) {
|
||||
protected function mergeClasses($left, $right)
|
||||
{
|
||||
// Merge together and remove dupes
|
||||
if(!is_array($left)) {
|
||||
if (!is_array($left)) {
|
||||
$left = array($left);
|
||||
}
|
||||
if(!is_array($right)) {
|
||||
if (!is_array($right)) {
|
||||
$right = array($right);
|
||||
}
|
||||
$merged = array_values(array_unique(array_merge($left, $right)));
|
||||
|
||||
// If there is only one item, return it as a single string
|
||||
if(count($merged) === 1) {
|
||||
if (count($merged) === 1) {
|
||||
return reset($merged);
|
||||
}
|
||||
return $merged;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -109,12 +109,10 @@ class SearchVariantSubsites extends SearchVariant
|
||||
|
||||
if (isset($write['fields']['SiteTree:SubsiteID'])) {
|
||||
$subsitesForWrite = array($write['fields']['SiteTree:SubsiteID']);
|
||||
}
|
||||
// files in subsite 0 should be in all subsites as they are global
|
||||
} // files in subsite 0 should be in all subsites as they are global
|
||||
elseif (isset($write['fields']['File:SubsiteID']) && intval($write['fields']['File:SubsiteID']) !== 0) {
|
||||
$subsitesForWrite = array($write['fields']['File:SubsiteID']);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$subsitesForWrite = $subsites;
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,7 @@ class SearchVariant_Caller
|
||||
$this->variants = $variants;
|
||||
}
|
||||
|
||||
public function call($method, &$a1=null, &$a2=null, &$a3=null, &$a4=null, &$a5=null, &$a6=null, &$a7=null)
|
||||
public function call($method, &$a1 = null, &$a2 = null, &$a3 = null, &$a4 = null, &$a5 = null, &$a6 = null, &$a7 = null)
|
||||
{
|
||||
$values = array();
|
||||
|
||||
@ -29,4 +29,4 @@ class SearchVariant_Caller
|
||||
|
||||
return $values;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -121,7 +121,10 @@ class Solr
|
||||
|
||||
if (!self::$service_singleton) {
|
||||
self::$service_singleton = Object::create(
|
||||
$options['service'], $options['host'], $options['port'], $options['path']
|
||||
$options['service'],
|
||||
$options['host'],
|
||||
$options['port'],
|
||||
$options['path']
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\FullTextSearch\Solr;
|
||||
|
||||
Solr::include_client_api();
|
||||
|
||||
use SilverStripe\Control\Director;
|
||||
@ -109,11 +110,11 @@ abstract class SolrIndex extends SearchIndex
|
||||
{
|
||||
$name = get_class($this);
|
||||
|
||||
if(defined('SS_SOLR_INDEX_PREFIX')) {
|
||||
if (defined('SS_SOLR_INDEX_PREFIX')) {
|
||||
$name = SS_SOLR_INDEX_PREFIX . ''. $name;
|
||||
}
|
||||
|
||||
if(defined('SS_SOLR_INDEX_SUFFIX')) {
|
||||
if (defined('SS_SOLR_INDEX_SUFFIX')) {
|
||||
$name = $name . '' . SS_SOLR_INDEX_SUFFIX;
|
||||
}
|
||||
|
||||
@ -493,10 +494,11 @@ abstract class SolrIndex extends SearchIndex
|
||||
* @param array|string $base Class or list of base classes
|
||||
* @return bool
|
||||
*/
|
||||
protected function classIs($class, $base) {
|
||||
if(is_array($base)) {
|
||||
foreach($base as $nextBase) {
|
||||
if($this->classIs($class, $nextBase)) {
|
||||
protected function classIs($class, $base)
|
||||
{
|
||||
if (is_array($base)) {
|
||||
foreach ($base as $nextBase) {
|
||||
if ($this->classIs($class, $nextBase)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -510,7 +512,7 @@ abstract class SolrIndex extends SearchIndex
|
||||
protected function _addField($doc, $object, $field)
|
||||
{
|
||||
$class = get_class($object);
|
||||
if(!$this->classIs($class, $field['origin'])) {
|
||||
if (!$this->classIs($class, $field['origin'])) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,11 @@ abstract class SolrReindexBase implements SolrReindexHandler
|
||||
* @param string $classes
|
||||
*/
|
||||
protected function processIndex(
|
||||
LoggerInterface $logger, SolrIndex $indexInstance, $batchSize, $taskName, $classes = null
|
||||
LoggerInterface $logger,
|
||||
SolrIndex $indexInstance,
|
||||
$batchSize,
|
||||
$taskName,
|
||||
$classes = null
|
||||
) {
|
||||
// Filter classes for this index
|
||||
$indexClasses = $this->getClassesForIndex($indexInstance, $classes);
|
||||
@ -87,8 +91,13 @@ abstract class SolrReindexBase implements SolrReindexHandler
|
||||
* @param string $taskName
|
||||
*/
|
||||
protected function processVariant(
|
||||
LoggerInterface $logger, SolrIndex $indexInstance, $state,
|
||||
$class, $includeSubclasses, $batchSize, $taskName
|
||||
LoggerInterface $logger,
|
||||
SolrIndex $indexInstance,
|
||||
$state,
|
||||
$class,
|
||||
$includeSubclasses,
|
||||
$batchSize,
|
||||
$taskName
|
||||
) {
|
||||
// Set state
|
||||
SearchVariant::activate_state($state);
|
||||
@ -127,7 +136,13 @@ abstract class SolrReindexBase implements SolrReindexHandler
|
||||
* @param string $taskName Name of task script to run
|
||||
*/
|
||||
abstract protected function processGroup(
|
||||
LoggerInterface $logger, SolrIndex $indexInstance, $state, $class, $groups, $group, $taskName
|
||||
LoggerInterface $logger,
|
||||
SolrIndex $indexInstance,
|
||||
$state,
|
||||
$class,
|
||||
$groups,
|
||||
$group,
|
||||
$taskName
|
||||
);
|
||||
|
||||
/**
|
||||
@ -144,7 +159,12 @@ abstract class SolrReindexBase implements SolrReindexHandler
|
||||
* @param int $group
|
||||
*/
|
||||
public function runGroup(
|
||||
LoggerInterface $logger, SolrIndex $indexInstance, $state, $class, $groups, $group
|
||||
LoggerInterface $logger,
|
||||
SolrIndex $indexInstance,
|
||||
$state,
|
||||
$class,
|
||||
$groups,
|
||||
$group
|
||||
) {
|
||||
// Set time limit and state
|
||||
Environment::increaseTimeLimitTo();
|
||||
|
@ -21,7 +21,11 @@ class SolrReindexImmediateHandler extends SolrReindexBase
|
||||
}
|
||||
|
||||
protected function processIndex(
|
||||
LoggerInterface $logger, SolrIndex $indexInstance, $batchSize, $taskName, $classes = null
|
||||
LoggerInterface $logger,
|
||||
SolrIndex $indexInstance,
|
||||
$batchSize,
|
||||
$taskName,
|
||||
$classes = null
|
||||
) {
|
||||
parent::processIndex($logger, $indexInstance, $batchSize, $taskName, $classes);
|
||||
|
||||
@ -46,7 +50,13 @@ class SolrReindexImmediateHandler extends SolrReindexBase
|
||||
* @param string $taskName Name of task script to run
|
||||
*/
|
||||
protected function processGroup(
|
||||
LoggerInterface $logger, SolrIndex $indexInstance, $state, $class, $groups, $group, $taskName
|
||||
LoggerInterface $logger,
|
||||
SolrIndex $indexInstance,
|
||||
$state,
|
||||
$class,
|
||||
$groups,
|
||||
$group,
|
||||
$taskName
|
||||
) {
|
||||
// Build state
|
||||
$statevar = json_encode($state);
|
||||
|
@ -85,12 +85,22 @@ class SolrReindexQueuedHandler extends SolrReindexBase
|
||||
}
|
||||
|
||||
protected function processGroup(
|
||||
LoggerInterface $logger, SolrIndex $indexInstance, $state, $class, $groups, $group, $taskName
|
||||
LoggerInterface $logger,
|
||||
SolrIndex $indexInstance,
|
||||
$state,
|
||||
$class,
|
||||
$groups,
|
||||
$group,
|
||||
$taskName
|
||||
) {
|
||||
// Trigger another job for this group
|
||||
$job = Injector::inst()->create(
|
||||
SolrReindexGroupQueuedJob::class,
|
||||
get_class($indexInstance), $state, $class, $groups, $group
|
||||
get_class($indexInstance),
|
||||
$state,
|
||||
$class,
|
||||
$groups,
|
||||
$group
|
||||
);
|
||||
$this
|
||||
->getQueuedJobService()
|
||||
@ -101,7 +111,12 @@ class SolrReindexQueuedHandler extends SolrReindexBase
|
||||
}
|
||||
|
||||
public function runGroup(
|
||||
LoggerInterface $logger, SolrIndex $indexInstance, $state, $class, $groups, $group
|
||||
LoggerInterface $logger,
|
||||
SolrIndex $indexInstance,
|
||||
$state,
|
||||
$class,
|
||||
$groups,
|
||||
$group
|
||||
) {
|
||||
parent::runGroup($logger, $indexInstance, $state, $class, $groups, $group);
|
||||
|
||||
|
@ -2,7 +2,6 @@
|
||||
|
||||
namespace SilverStripe\FullTextSearch\Solr\Services;
|
||||
|
||||
|
||||
class Solr3Service_Core extends SolrService_Core
|
||||
{
|
||||
}
|
||||
|
@ -25,8 +25,12 @@ class Solr4Service_Core extends SolrService_Core
|
||||
* @inheritdoc
|
||||
* @see Solr4Service_Core::addDocuments
|
||||
*/
|
||||
public function addDocument(\Apache_Solr_Document $document, $allowDups = false,
|
||||
$overwritePending = true, $overwriteCommitted = true, $commitWithin = 0
|
||||
public function addDocument(
|
||||
\Apache_Solr_Document $document,
|
||||
$allowDups = false,
|
||||
$overwritePending = true,
|
||||
$overwriteCommitted = true,
|
||||
$commitWithin = 0
|
||||
) {
|
||||
return $this->addDocuments(array($document), $allowDups, $overwritePending, $overwriteCommitted, $commitWithin);
|
||||
}
|
||||
@ -35,8 +39,12 @@ class Solr4Service_Core extends SolrService_Core
|
||||
* Solr 4.0 compat http://wiki.apache.org/solr/UpdateXmlMessages#Optional_attributes_for_.22add.22
|
||||
* Remove allowDups, overwritePending and overwriteComitted
|
||||
*/
|
||||
public function addDocuments($documents, $allowDups = false, $overwritePending = true,
|
||||
$overwriteCommitted = true, $commitWithin = 0
|
||||
public function addDocuments(
|
||||
$documents,
|
||||
$allowDups = false,
|
||||
$overwritePending = true,
|
||||
$overwriteCommitted = true,
|
||||
$commitWithin = 0
|
||||
) {
|
||||
$overwriteVal = $allowDups ? 'false' : 'true';
|
||||
$commitWithin = (int) $commitWithin;
|
||||
|
@ -1,5 +1,6 @@
|
||||
<?php
|
||||
namespace SilverStripe\FullTextSearch\Solr\Stores;
|
||||
|
||||
/**
|
||||
* Class SolrConfigStore
|
||||
*
|
||||
@ -30,7 +31,3 @@ interface SolrConfigStore
|
||||
*/
|
||||
public function instanceDir($index);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -2,7 +2,6 @@
|
||||
|
||||
namespace SilverStripe\FullTextSearch\Solr\Stores;
|
||||
|
||||
|
||||
/**
|
||||
* Class SolrConfigStore_File
|
||||
*
|
||||
@ -50,4 +49,4 @@ class SolrConfigStore_File implements SolrConfigStore
|
||||
{
|
||||
return $this->remote.'/'.$index;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,11 @@
|
||||
<?php
|
||||
namespace SilverStripe\FullTextSearch\Solr\Tasks;
|
||||
|
||||
use SilverStripe\Core\Injector\Injector;
|
||||
use SilverStripe\Dev\BuildTask;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use SilverStripe\FullTextSearch\Utils\Logging\SearchLogFactory;
|
||||
|
||||
/**
|
||||
* Abstract class for build tasks
|
||||
*/
|
||||
|
@ -1,5 +1,6 @@
|
||||
<?php
|
||||
namespace SilverStripe\FullTextSearch\Solr\Tasks;
|
||||
|
||||
use Exception;
|
||||
use SilverStripe\Core\ClassInfo;
|
||||
use SilverStripe\FullTextSearch\Solr\Solr;
|
||||
|
@ -1,5 +1,6 @@
|
||||
<?php
|
||||
namespace SilverStripe\FullTextSearch\Solr\Tasks;
|
||||
|
||||
use ReflectionClass;
|
||||
use SilverStripe\Core\ClassInfo;
|
||||
use SilverStripe\Core\Injector\Injector;
|
||||
@ -74,7 +75,7 @@ class Solr_Reindex extends Solr_BuildTask
|
||||
// this is for when index names do not match the class name (this can be done by overloading getIndexName() on
|
||||
// indexes
|
||||
if ($index && !ClassInfo::exists($index)) {
|
||||
foreach(ClassInfo::subclassesFor(SolrIndex::class) as $solrIndexClass) {
|
||||
foreach (ClassInfo::subclassesFor(SolrIndex::class) as $solrIndexClass) {
|
||||
$reflection = new ReflectionClass($solrIndexClass);
|
||||
//skip over abstract classes
|
||||
if (!$reflection->isInstantiable()) {
|
||||
|
@ -1,6 +1,8 @@
|
||||
<?php
|
||||
namespace SilverStripe\FullTextSearch\Utils;
|
||||
|
||||
use Iterator;
|
||||
|
||||
class MultipleArrayIterator implements Iterator
|
||||
{
|
||||
protected $arrays;
|
||||
|
@ -1,5 +1,6 @@
|
||||
<?php
|
||||
namespace SilverStripe\FullTextSearch\Utils;
|
||||
|
||||
class WebDAV
|
||||
{
|
||||
public static function curl_init($url, $method)
|
||||
|
@ -29,6 +29,12 @@
|
||||
"phpunit/phpunit": "^5.7",
|
||||
"squizlabs/php_codesniffer": "^3.0"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"SilverStripe\\FullTextSearch\\": "code/",
|
||||
"SilverStripe\\FullTextSearch\\Tests\\": "tests/"
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "3.x-dev"
|
||||
@ -38,5 +44,5 @@
|
||||
"silverstripe/fulltextsearch-localsolr": "Adds a ready-to-use local Solr server for initial development"
|
||||
},
|
||||
"minimum-stability": "dev",
|
||||
"prefer-stable": "true"
|
||||
"prefer-stable": true
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ use SilverStripe\Dev\TestOnly;
|
||||
|
||||
class BatchedProcessorTest_Object extends SiteTree implements TestOnly
|
||||
{
|
||||
private static $table_name = 'BatchedProcessorTest_Object';
|
||||
private static $table_name = 'BatchedProcessorTest_Object';
|
||||
|
||||
private static $db = array(
|
||||
'TestText' => 'Varchar'
|
||||
|
@ -1,16 +1,18 @@
|
||||
<?php
|
||||
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
use SilverStripe\FullTextSearch\Search\Updaters\SearchUpdater;
|
||||
namespace SilverStripe\FullTextSearch\Tests;
|
||||
|
||||
use SilverStripe\Core\Config\Config;
|
||||
use SilverStripe\Core\Injector\Injector;
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
use SilverStripe\FullTextSearch\Search\FullTextSearch;
|
||||
use SilverStripe\FullTextSearch\Search\Processors\SearchUpdateProcessor;
|
||||
use SilverStripe\FullTextSearch\Search\Processors\SearchUpdateImmediateProcessor;
|
||||
use SilverStripe\FullTextSearch\Search\Updaters\SearchUpdater;
|
||||
use SilverStripe\FullTextSearch\Tests\SearchUpdaterTest\SearchUpdaterTest_Container;
|
||||
use SilverStripe\FullTextSearch\Tests\SearchUpdaterTest\SearchUpdaterTest_HasOne;
|
||||
use SilverStripe\FullTextSearch\Tests\SearchUpdaterTest\SearchUpdaterTest_HasMany;
|
||||
use SilverStripe\FullTextSearch\Tests\SearchUpdaterTest\SearchUpdaterTest_Index;
|
||||
use SilverStripe\FullTextSearch\Search\Processors\SearchUpdateProcessor;
|
||||
use SilverStripe\FullTextSearch\Search\Processors\SearchUpdateImmediateProcessor;
|
||||
|
||||
class SearchUpdaterTest extends SapphireTest
|
||||
{
|
||||
@ -74,7 +76,9 @@ class SearchUpdaterTest extends SapphireTest
|
||||
|
||||
$added = self::$index->getAdded(array('ID'));
|
||||
// Some databases don't output $added in a consistent order; that's okay
|
||||
usort($added, function ($a, $b) {return $a['ID']-$b['ID']; });
|
||||
usort($added, function ($a, $b) {
|
||||
return $a['ID']-$b['ID'];
|
||||
});
|
||||
|
||||
$this->assertEquals($added, array(
|
||||
array('ID' => $container1->ID),
|
||||
@ -93,7 +97,9 @@ class SearchUpdaterTest extends SapphireTest
|
||||
$added = self::$index->getAdded(array('ID'));
|
||||
|
||||
// Some databases don't output $added in a consistent order; that's okay
|
||||
usort($added, function ($a, $b) {return $a['ID']-$b['ID']; });
|
||||
usort($added, function ($a, $b) {
|
||||
return $a['ID']-$b['ID'];
|
||||
});
|
||||
|
||||
$this->assertEquals($added, array(
|
||||
array('ID' => $container1->ID),
|
||||
|
@ -1,13 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\FullTextSearch\Tests;
|
||||
|
||||
use SilverStripe\CMS\Model\SiteTree;
|
||||
use SilverStripe\FullTextSearch\Search\Indexes\SearchIndex_Recording;
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
use SilverStripe\FullTextSearch\Search\Indexes\SearchIndex_Recording;
|
||||
use SilverStripe\FullTextSearch\Tests\SearchVariantSiteTreeSubsitesPolyhomeTest\SearchVariantSiteTreeSubsitesPolyhomeTest_Index;
|
||||
use SilverStripe\FullTextSearch\Tests\SearchVariantSiteTreeSubsitesPolyhomeTest\SearchVariantSiteTreeSubsitesPolyhomeTest_Item;
|
||||
|
||||
|
||||
|
||||
class SearchVariantSiteTreeSubsitesPolyhomeTest extends SapphireTest
|
||||
{
|
||||
private static $index = null;
|
||||
|
@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\FullTextSearch\Tests;
|
||||
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
|
||||
class SearchVariantSubsiteTest extends SapphireTest
|
||||
@ -86,7 +88,5 @@ class SearchVariantSubsiteTest extends SapphireTest
|
||||
//subsite filter has been modified with our arbitrary test value. The second value is not set
|
||||
//this proves that the query has not been altered by the variant
|
||||
$this->assertEquals(2, $query->require['_subsite'][0]);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,8 +1,10 @@
|
||||
<?php
|
||||
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
namespace SilverStripe\FullTextSearch\Tests;
|
||||
|
||||
use SilverStripe\Core\Config\Config;
|
||||
use SilverStripe\CMS\Model\SiteTree;
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
use SilverStripe\FullTextSearch\Search\FullTextSearch;
|
||||
use SilverStripe\FullTextSearch\Search\Indexes\SearchIndex_Recording;
|
||||
use SilverStripe\FullTextSearch\Search\Variants\SearchVariantVersioned;
|
||||
|
@ -11,7 +11,7 @@ use SilverStripe\Dev\SapphireTest;
|
||||
class Solr4ServiceTest extends SapphireTest
|
||||
{
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @return Solr4ServiceTest_RecordingService
|
||||
*/
|
||||
protected function getMockService()
|
||||
|
@ -16,4 +16,3 @@ class Solr4ServiceTest_RecordingService extends Solr4Service_Core
|
||||
return $url;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\FullTextSearch\Tests;
|
||||
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
use SilverStripe\FullTextSearch\Tests\SolrIndexSubsitesTest\SolrIndexSubsitesTest_Index;
|
||||
|
||||
@ -10,7 +12,8 @@ if (class_exists('\Phockito')) {
|
||||
/**
|
||||
* Subsite specific solr testing
|
||||
*/
|
||||
class SolrIndexSubsitesTest extends SapphireTest {
|
||||
class SolrIndexSubsitesTest extends SapphireTest
|
||||
{
|
||||
// @todo
|
||||
// protected static $fixture_file = 'SolrIndexSubsitesTest/SolrIndexSubsitesTest.yml';
|
||||
|
||||
@ -80,15 +83,15 @@ class SolrIndexSubsitesTest extends SapphireTest {
|
||||
$variants = array();
|
||||
|
||||
// Check subsite
|
||||
if(class_exists('Subsite') && DataObject::getSchema()->hasOneComponent($object->getClassName(), 'Subsite')) {
|
||||
if (class_exists('Subsite') && DataObject::getSchema()->hasOneComponent($object->getClassName(), 'Subsite')) {
|
||||
$variants[] = '"SearchVariantSubsites":"' . $subsiteID. '"';
|
||||
}
|
||||
|
||||
// Check versioned
|
||||
if($stage) {
|
||||
if ($stage) {
|
||||
$variants[] = '"SearchVariantVersioned":"' . $stage . '"';
|
||||
}
|
||||
return $id.'-'.$class.'-{'.implode(',',$variants).'}';
|
||||
return $id.'-'.$class.'-{'.implode(',', $variants).'}';
|
||||
}
|
||||
|
||||
public function testPublishing()
|
||||
@ -127,10 +130,10 @@ class SolrIndexSubsitesTest extends SapphireTest {
|
||||
));
|
||||
\Phockito::verify($serviceMock)->addDocument($doc1);
|
||||
\Phockito::verify($serviceMock)->addDocument($doc2);
|
||||
|
||||
}
|
||||
|
||||
public function testCorrectSubsiteIDOnPageWrite() {
|
||||
public function testCorrectSubsiteIDOnPageWrite()
|
||||
{
|
||||
$mockWrites = array(
|
||||
'3367:SiteTree:a:1:{s:22:"SearchVariantVersioned";s:4:"Live";}' => array(
|
||||
'base' => 'SiteTree',
|
||||
@ -169,7 +172,7 @@ class SolrIndexSubsitesTest extends SapphireTest {
|
||||
$variant = new SearchVariantSubsites();
|
||||
$tmpMockWrites = $mockWrites;
|
||||
$variant->extractManipulationWriteState($tmpMockWrites);
|
||||
foreach($tmpMockWrites as $mockWrite) {
|
||||
foreach ($tmpMockWrites as $mockWrite) {
|
||||
$this->assertCount(1, $mockWrite['statefulids']);
|
||||
$statefulIDs = array_shift($mockWrite['statefulids']);
|
||||
$this->assertEquals(0, $statefulIDs['state']['SearchVariantSubsites']);
|
||||
@ -180,14 +183,15 @@ class SolrIndexSubsitesTest extends SapphireTest {
|
||||
$tmpMockWrites['3367:SiteTree:a:1:{s:22:"SearchVariantVersioned";s:4:"Live";}']['fields']['SiteTree:SubsiteID'] = $subsite->ID;
|
||||
|
||||
$variant->extractManipulationWriteState($tmpMockWrites);
|
||||
foreach($tmpMockWrites as $mockWrite) {
|
||||
foreach ($tmpMockWrites as $mockWrite) {
|
||||
$this->assertCount(1, $mockWrite['statefulids']);
|
||||
$statefulIDs = array_shift($mockWrite['statefulids']);
|
||||
$this->assertEquals($subsite->ID, $statefulIDs['state']['SearchVariantSubsites']);
|
||||
}
|
||||
}
|
||||
|
||||
public function testCorrectSubsiteIDOnFileWrite() {
|
||||
public function testCorrectSubsiteIDOnFileWrite()
|
||||
{
|
||||
$subsiteIDs = array('0') + $this->allFixtureIDs('Subsite');
|
||||
$mockWrites = array(
|
||||
'35910:File:a:0:{}' => array(
|
||||
@ -217,7 +221,7 @@ class SolrIndexSubsitesTest extends SapphireTest {
|
||||
$variant = new SearchVariantSubsites();
|
||||
$tmpMockWrites = $mockWrites;
|
||||
$variant->extractManipulationWriteState($tmpMockWrites);
|
||||
foreach($tmpMockWrites as $mockWrite) {
|
||||
foreach ($tmpMockWrites as $mockWrite) {
|
||||
$this->assertCount(count($subsiteIDs), $mockWrite['statefulids']);
|
||||
foreach ($mockWrite['statefulids'] as $statefulIDs) {
|
||||
$this->assertTrue(
|
||||
@ -232,11 +236,10 @@ class SolrIndexSubsitesTest extends SapphireTest {
|
||||
$tmpMockWrites['35910:File:a:0:{}']['fields']['File:SubsiteID'] = $subsite->ID;
|
||||
|
||||
$variant->extractManipulationWriteState($tmpMockWrites);
|
||||
foreach($tmpMockWrites as $mockWrite) {
|
||||
foreach ($tmpMockWrites as $mockWrite) {
|
||||
$this->assertCount(1, $mockWrite['statefulids']);
|
||||
$statefulIDs = array_shift($mockWrite['statefulids']);
|
||||
$this->assertEquals($subsite->ID, $statefulIDs['state']['SearchVariantSubsites']);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\FullTextSearch\Tests;
|
||||
|
||||
use SilverStripe\Core\Config\Config;
|
||||
use SilverStripe\Core\Injector\Injector;
|
||||
use SilverStripe\Core\Kernel;
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
@ -8,14 +11,13 @@ use SilverStripe\FullTextSearch\Tests\SolrIndexTest\SolrIndexTest_AmbiguousRelat
|
||||
use SilverStripe\FullTextSearch\Tests\SolrIndexTest\SolrIndexTest_FakeIndex;
|
||||
use SilverStripe\FullTextSearch\Tests\SolrIndexTest\SolrIndexTest_FakeIndex2;
|
||||
use SilverStripe\FullTextSearch\Tests\SolrIndexTest\SolrIndexTest_BoostedIndex;
|
||||
use SilverStripe\FullTextSearch\Solr\Services\Solr3Service;
|
||||
use SilverStripe\FullTextSearch\Tests\SearchUpdaterTest\SearchUpdaterTest_Container;
|
||||
use SilverStripe\FullTextSearch\Tests\SearchUpdaterTest\SearchUpdaterTest_HasOne;
|
||||
use SilverStripe\FullTextSearch\Tests\SearchUpdaterTest\SearchUpdaterTest_HasMany;
|
||||
use SilverStripe\FullTextSearch\Tests\SearchUpdaterTest\SearchUpdaterTest_ManyMany;
|
||||
use SilverStripe\FullTextSearch\Tests\SearchUpdaterTest\SearchUpdaterTest_OtherContainer;
|
||||
use SilverStripe\Core\Config\Config;
|
||||
use SilverStripe\FullTextSearch\Search\Queries\SearchQuery;
|
||||
use SilverStripe\FullTextSearch\Solr\Services\Solr3Service;
|
||||
|
||||
class SolrIndexTest extends SapphireTest
|
||||
{
|
||||
@ -181,7 +183,8 @@ class SolrIndexTest extends SapphireTest
|
||||
|
||||
$serviceMock->expects($this->exactly(2))
|
||||
->method('search')
|
||||
->withConsecutive([
|
||||
->withConsecutive(
|
||||
[
|
||||
$this->equalTo('+(Field1:term^1.5 OR HasOneObject_Field1:term^3)'),
|
||||
$this->anything(),
|
||||
$this->anything(),
|
||||
|
@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\FullTextSearch\Tests;
|
||||
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
use SilverStripe\Core\Config\Config;
|
||||
use SilverStripe\ORM\DataObject;
|
||||
@ -81,7 +83,7 @@ class SolrIndexVersionedTest extends SapphireTest
|
||||
// Prevent subsites from breaking tests
|
||||
// TODO: Subsites currently isn't migrated. This needs to be fixed when subsites is fixed.
|
||||
$subsites = '';
|
||||
if(class_exists('Subsite') && DataObject::getSchema()->hasOneComponent($object->getClassName(), 'Subsite')) {
|
||||
if (class_exists('Subsite') && DataObject::getSchema()->hasOneComponent($object->getClassName(), 'Subsite')) {
|
||||
$subsites = '"SearchVariantSubsites":"0",';
|
||||
}
|
||||
return $id.'-'.$class.'-{'.$subsites. json_encode(SearchVariantVersioned::class) . ':"'.$stage.'"}';
|
||||
|
@ -9,7 +9,8 @@ use SilverStripe\Versioned\Versioned;
|
||||
/**
|
||||
* Non-sitetree versioned dataobject
|
||||
*/
|
||||
class SolrIndexVersionedTest_Object extends DataObject implements TestOnly {
|
||||
class SolrIndexVersionedTest_Object extends DataObject implements TestOnly
|
||||
{
|
||||
|
||||
private static $table_name = 'SolrIndexVersionedTest_Object';
|
||||
|
||||
|
@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\FullTextSearch\Tests;
|
||||
|
||||
use SilverStripe\Core\Config\Config;
|
||||
use SilverStripe\Core\Injector\Injector;
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
|
@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\FullTextSearch\Tests;
|
||||
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
use SilverStripe\FullTextSearch\Search\FullTextSearch;
|
||||
use SilverStripe\FullTextSearch\Search\Updaters\SearchUpdater;
|
||||
|
@ -20,7 +20,7 @@ class SolrReindexTest_ItemExtension extends DataExtension implements TestOnly
|
||||
* @param SQLSelect $query
|
||||
* @param DataQuery $dataQuery
|
||||
*/
|
||||
public function augmentSQL(SQLSelect $query, DataQuery $dataQuery = NULL)
|
||||
public function augmentSQL(SQLSelect $query, DataQuery $dataQuery = null)
|
||||
{
|
||||
$variant = SolrReindexTest_Variant::get_current();
|
||||
if ($variant !== null && !$query->filtersOnID()) {
|
||||
|
@ -12,7 +12,13 @@ use SilverStripe\FullTextSearch\Solr\SolrIndex;
|
||||
class SolrReindexTest_TestHandler extends SolrReindexBase
|
||||
{
|
||||
public function processGroup(
|
||||
LoggerInterface $logger, SolrIndex $indexInstance, $state, $class, $groups, $group, $taskName
|
||||
LoggerInterface $logger,
|
||||
SolrIndex $indexInstance,
|
||||
$state,
|
||||
$class,
|
||||
$groups,
|
||||
$group,
|
||||
$taskName
|
||||
) {
|
||||
$indexName = $indexInstance->getIndexName();
|
||||
$stateName = json_encode($state);
|
||||
|
Loading…
Reference in New Issue
Block a user