mirror of
https://github.com/silverstripe/silverstripe-fulltextsearch
synced 2024-10-22 12:05:29 +00:00
Merge branch 'compat/4' into compat4/btasker
This commit is contained in:
commit
a8588b2fd8
@ -1,4 +1,4 @@
|
||||
<?php
|
||||
|
||||
use SilverStripe\FullTextSearch\Search\Updaters\SearchUpdater;
|
||||
global $databaseConfig;
|
||||
if (isset($databaseConfig['type'])) SearchUpdater::bind_manipulation_capture();
|
||||
|
@ -1,3 +1,3 @@
|
||||
SilverStripe\ORM\DataObject:
|
||||
extensions:
|
||||
- SilverStripe\FullTextSearch\Search\Updaters\SearchUpdater_ObjectHandler
|
||||
- 'SilverStripe\FullTextSearch\Search\Updaters\SearchUpdater_ObjectHandler'
|
||||
|
@ -7,7 +7,7 @@ SilverStripe\Core\Injector\Injector:
|
||||
SilverStripe\FullTextSearch\Solr\Reindex\Handlers\SolrReindexHandler:
|
||||
class: SilverStripe\FullTextSearch\Solr\Reindex\Handlers\SolrReindexImmediateHandler
|
||||
SilverStripe\FullTextSearch\Utils\Logging\SearchLogFactory:
|
||||
class: 'MonologFactory'
|
||||
class: SilverStripe\FullTextSearch\Utils\Logging\MonologFactory
|
||||
---
|
||||
Name: queuedjobprocessor
|
||||
Only:
|
||||
|
@ -1,10 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\FullTextSearch\Search;
|
||||
|
||||
use SilverStripe\Core\ClassInfo;
|
||||
use SilverStripe\Core\Config\Config;
|
||||
use SilverStripe\ORM\DataObject;
|
||||
use SilverStripe\Core\ClassInfo;
|
||||
use SilverStripe\FullTextSearch\Search\Indexes\SearchIndex;
|
||||
use ReflectionClass;
|
||||
|
||||
/**
|
||||
@ -44,7 +44,7 @@ class FullTextSearch
|
||||
if (self::$all_indexes === null) {
|
||||
// Get declared indexes, or otherwise default to all subclasses of SearchIndex
|
||||
$classes = Config::inst()->get(__CLASS__, 'indexes')
|
||||
?: ClassInfo::subclassesFor('SearchIndex');
|
||||
?: ClassInfo::subclassesFor(SearchIndex::class);
|
||||
|
||||
$hidden = array();
|
||||
$candidates = array();
|
||||
|
@ -2,9 +2,10 @@
|
||||
|
||||
namespace SilverStripe\FullTextSearch\Search\Indexes;
|
||||
|
||||
use Exception;
|
||||
use InvalidArgumentException;
|
||||
use SilverStripe\View\ViewableData;
|
||||
use SilverStripe\ORM\DataObject;
|
||||
use SilverStripe\ORM\DataObjectSchema;
|
||||
use SilverStripe\Core\Object;
|
||||
use SilverStripe\Core\ClassInfo;
|
||||
use SilverStripe\FullTextSearch\Search\SearchIntrospection;
|
||||
@ -476,9 +477,8 @@ abstract class SearchIndex extends ViewableData
|
||||
}
|
||||
|
||||
$object = $next;
|
||||
}
|
||||
// Otherwise, just call
|
||||
else {
|
||||
} else {
|
||||
// Otherwise, just call
|
||||
if ($step['call'] == 'method') {
|
||||
$method = $step['method'];
|
||||
$object = $object->$method();
|
||||
@ -508,9 +508,10 @@ abstract class SearchIndex extends ViewableData
|
||||
* @param Exception $e
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function warn($e) {
|
||||
public static function warn($e)
|
||||
{
|
||||
// Noisy errors during testing
|
||||
if(class_exists('SapphireTest', false) && SapphireTest::is_running_test()) {
|
||||
if (class_exists('SapphireTest', false) && SapphireTest::is_running_test()) {
|
||||
throw $e;
|
||||
}
|
||||
SS_Log::log($e, SS_Log::WARN);
|
||||
@ -609,8 +610,8 @@ abstract class SearchIndex extends ViewableData
|
||||
|
||||
/** !! These should be implemented by the full text search engine */
|
||||
|
||||
abstract public function add($object) ;
|
||||
abstract public function delete($base, $id, $state) ;
|
||||
abstract public function add($object);
|
||||
abstract public function delete($base, $id, $state);
|
||||
|
||||
abstract public function commit();
|
||||
|
||||
|
@ -2,17 +2,17 @@
|
||||
|
||||
namespace SilverStripe\FullTextSearch\Search\Updaters;
|
||||
|
||||
use SilverStripe\ORM\DB;
|
||||
use SilverStripe\Core\Injector\Injector;
|
||||
use SilverStripe\Core\Object;
|
||||
use SilverStripe\FullTextSearch\Search\Variants\SearchVariant;
|
||||
use SilverStripe\ORM\DataObject;
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
use SilverStripe\ORM\DataObject;
|
||||
use SilverStripe\ORM\DB;
|
||||
use SilverStripe\FullTextSearch\Search\FullTextSearch;
|
||||
use SilverStripe\FullTextSearch\Search\SearchIntrospection;
|
||||
use SilverStripe\Core\Injector\Injector;
|
||||
use SilverStripe\FullTextSearch\Search\Variants\SearchVariant;
|
||||
use SilverStripe\FullTextSearch\Search\Processors\SearchUpdateImmediateProcessor;
|
||||
use SilverStripe\FullTextSearch\Captures\SearchManipulateCapture_MySQLDatabase;
|
||||
use ReflectionClass;
|
||||
|
||||
/**
|
||||
* This class is responsible for capturing changes to DataObjects and triggering index updates of the resulting dirty index
|
||||
* items.
|
||||
@ -36,6 +36,7 @@ class SearchUpdater extends Object
|
||||
global $databaseConfig;
|
||||
|
||||
$current = DB::get_conn();
|
||||
|
||||
if (!$current || !$current->getSelectedDatabase() || @$current->isManipulationCapture) {
|
||||
return;
|
||||
} // If not yet set, or its already captured, just return
|
||||
|
@ -1,10 +1,4 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: elliot
|
||||
* Date: 21/04/17
|
||||
* Time: 1:13 PM
|
||||
*/
|
||||
|
||||
namespace SilverStripe\FullTextSearch\Search\Variants;
|
||||
|
||||
|
@ -3,10 +3,10 @@
|
||||
namespace SilverStripe\FullTextSearch\Solr\Reindex\Handlers;
|
||||
|
||||
use Psr\Log\LoggerInterface;
|
||||
use SilverStripe\FullTextSearch\Solr\SolrIndex;
|
||||
use SilverStripe\FullTextSearch\Solr\Solr;
|
||||
use SilverStripe\ORM\DB;
|
||||
use SilverStripe\Control\Director;
|
||||
use SilverStripe\FullTextSearch\Solr\Solr;
|
||||
use SilverStripe\FullTextSearch\Solr\SolrIndex;
|
||||
use SilverStripe\ORM\DB;
|
||||
|
||||
/**
|
||||
* Invokes an immediate reindex
|
||||
|
@ -3,5 +3,5 @@ namespace SilverStripe\FullTextSearch\Solr\Services;
|
||||
|
||||
class Solr3Service extends SolrService
|
||||
{
|
||||
private static $core_class = 'SilverStripe\FullTextSearch\Solr\Services\Solr3Service_Core';
|
||||
private static $core_class = Solr3Service_Core::class;
|
||||
}
|
||||
|
@ -3,5 +3,5 @@ namespace SilverStripe\FullTextSearch\Solr\Services;
|
||||
|
||||
class Solr4Service extends SolrService
|
||||
{
|
||||
private static $core_class = 'SilverStripe\FullTextSearch\Solr\Services\Solr4Service_Core';
|
||||
private static $core_class = Solr4Service_Core::class;
|
||||
}
|
||||
|
@ -52,4 +52,4 @@ class Solr4Service_Core extends SolrService_Core
|
||||
|
||||
return $this->add($rawPost);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\FullTextSearch\Solr\Services;
|
||||
|
||||
use SilverStripe\Core\Config\Config;
|
||||
use SilverStripe\FullTextSearch\Solr\Solr;
|
||||
|
||||
Solr::include_client_api();
|
||||
/**
|
||||
* The API for accessing the primary Solr installation, which includes both SolrService_Core,
|
||||
@ -10,12 +13,12 @@ Solr::include_client_api();
|
||||
*/
|
||||
class SolrService extends SolrService_Core
|
||||
{
|
||||
private static $core_class = 'SilverStripe\FullTextSearch\Solr\Services\SolrService_Core';
|
||||
private static $core_class = SolrService_Core::class;
|
||||
|
||||
/**
|
||||
* Handle encoding the GET parameters and making the HTTP call to execute a core command
|
||||
*/
|
||||
protected function coreCommand($command, $core, $params=array())
|
||||
protected function coreCommand($command, $core, $params = array())
|
||||
{
|
||||
$command = strtoupper($command);
|
||||
|
||||
@ -45,7 +48,7 @@ class SolrService extends SolrService_Core
|
||||
* @param $datadir string - The path to store data for this core on the server. Default depends on solrconfig.xml
|
||||
* @return Apache_Solr_Response
|
||||
*/
|
||||
public function coreCreate($core, $instancedir, $config=null, $schema=null, $datadir=null)
|
||||
public function coreCreate($core, $instancedir, $config = null, $schema = null, $datadir = null)
|
||||
{
|
||||
$args = array('instanceDir' => $instancedir);
|
||||
if ($config) {
|
||||
|
@ -1,10 +1,4 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: elliot
|
||||
* Date: 21/04/17
|
||||
* Time: 12:45 PM
|
||||
*/
|
||||
|
||||
namespace SilverStripe\FullTextSearch\Solr\Services;
|
||||
|
||||
|
@ -2,8 +2,8 @@
|
||||
|
||||
namespace SilverStripe\FullTextSearch\Solr\Stores;
|
||||
|
||||
use SilverStripe\FullTextSearch\Utils\WebDAV;
|
||||
use SilverStripe\FullTextSearch\Solr\Solr;
|
||||
use SilverStripe\FullTextSearch\Utils\WebDAV;
|
||||
|
||||
/**
|
||||
* Class SolrConfigStore_WebDAV
|
||||
@ -56,4 +56,4 @@ class SolrConfigStore_WebDAV implements SolrConfigStore
|
||||
{
|
||||
return $this->remote ? "{$this->remote}/$index" : $index;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,9 @@
|
||||
<?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
|
||||
*/
|
||||
@ -22,7 +25,9 @@ class Solr_BuildTask extends BuildTask
|
||||
*/
|
||||
public function getLogger()
|
||||
{
|
||||
return Injector::inst()->get('Logger');
|
||||
//@todo left commented after a confusing merge conflict. Revisit if further testing is required
|
||||
//return Injector::inst()->get('Logger');
|
||||
return Injector::inst()->get(LoggerInterface::class);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -40,7 +45,9 @@ class Solr_BuildTask extends BuildTask
|
||||
*/
|
||||
protected function getLoggerFactory()
|
||||
{
|
||||
// return Injector::inst()->get('SearchLogFactory');
|
||||
//@todo left commented after a confusing merge conflict. Revisit if further testing is required
|
||||
//return Injector::inst()->get('SearchLogFactory');
|
||||
return Injector::inst()->get(SearchLogFactory::class);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -55,9 +62,8 @@ class Solr_BuildTask extends BuildTask
|
||||
|
||||
// Set new logger
|
||||
$logger = $this
|
||||
->getLoggerFactory();
|
||||
//@todo: Cannot instantiate interface SearchLogFactory
|
||||
// ->getOutputLogger($name, $verbose);
|
||||
->getLoggerFactory()
|
||||
->getOutputLogger($name, $verbose);
|
||||
$this->setLogger($logger);
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,15 @@
|
||||
<?php
|
||||
namespace SilverStripe\FullTextSearch\Solr\Tasks;
|
||||
use Exception;
|
||||
use SilverStripe\Core\ClassInfo;
|
||||
use SilverStripe\FullTextSearch\Solr\Solr;
|
||||
use SilverStripe\FullTextSearch\Solr\Stores\SolrConfigStore_File;
|
||||
use SilverStripe\FullTextSearch\Solr\Stores\SolrConfigStore_WebDAV;
|
||||
use SilverStripe\FullTextSearch\Solr\Stores\SolrConfigStore;
|
||||
|
||||
class Solr_Configure extends Solr_BuildTask
|
||||
{
|
||||
private static $segment = 'Solr_Configure';
|
||||
protected $enabled = true;
|
||||
|
||||
public function run($request)
|
||||
@ -72,10 +80,13 @@ class Solr_Configure extends Solr_BuildTask
|
||||
return new SolrConfigStore_File($indexstore);
|
||||
} elseif ($mode == 'webdav') {
|
||||
return new SolrConfigStore_WebDAV($indexstore);
|
||||
} elseif (ClassInfo::exists($mode) && ClassInfo::classImplements($mode, 'SolrConfigStore')) {
|
||||
//@todo left commented after confusing merge conflict. Revisit if further testing is required
|
||||
//} elseif (ClassInfo::exists($mode) && ClassInfo::classImplements($mode, 'SolrConfigStore')) {
|
||||
} elseif (ClassInfo::exists($mode) && ClassInfo::classImplements($mode, SolrConfigStore::class)) {
|
||||
return new $mode($indexstore);
|
||||
} else {
|
||||
user_error('Unknown Solr index mode '.$indexstore['mode'], E_USER_ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,13 @@
|
||||
<?php
|
||||
namespace SilverStripe\FullTextSearch\Solr\Tasks;
|
||||
use ReflectionClass;
|
||||
use SilverStripe\Core\ClassInfo;
|
||||
use SilverStripe\Core\Injector\Injector;
|
||||
use SilverStripe\FullTextSearch\Search\Variants\SearchVariant;
|
||||
use SilverStripe\ORM\DataList;
|
||||
use SilverStripe\FullTextSearch\Solr\Reindex\Handlers\SolrReindexHandler;
|
||||
use SilverStripe\FullTextSearch\Solr\SolrIndex;
|
||||
|
||||
/**
|
||||
* Task used for both initiating a new reindex, as well as for processing incremental batches
|
||||
* within a reindex.
|
||||
@ -17,6 +25,8 @@ namespace SilverStripe\FullTextSearch\Solr\Tasks;
|
||||
*/
|
||||
class Solr_Reindex extends Solr_BuildTask
|
||||
{
|
||||
private static $segment = 'Solr_Reindex';
|
||||
|
||||
protected $enabled = true;
|
||||
|
||||
/**
|
||||
@ -34,9 +44,12 @@ class Solr_Reindex extends Solr_BuildTask
|
||||
*/
|
||||
protected function getHandler()
|
||||
{
|
||||
|
||||
//@todo: this needs to determine the best class from a Factory implementation
|
||||
//@todo: it was 'SolrReindexHandler' but that doesn't work on 4.0
|
||||
return Injector::inst()->get('SolrReindexImmediateHandler');
|
||||
//@todo left commented after a confusing merge conflict. Revisit if further investigation /testing is needed
|
||||
//return Injector::inst()->get('SolrReindexImmediateHandler');
|
||||
return Injector::inst()->get(SolrReindexHandler::class);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -65,7 +78,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') as $solrIndexClass) {
|
||||
foreach(ClassInfo::subclassesFor(SolrIndex::class) as $solrIndexClass) {
|
||||
$reflection = new ReflectionClass($solrIndexClass);
|
||||
//skip over abstract classes
|
||||
if (!$reflection->isInstantiable()) {
|
||||
|
@ -56,16 +56,16 @@ All possible parameters incl optional ones with example values:
|
||||
Solr::configure_server(array(
|
||||
'host' => 'localhost', // default: localhost | The host or IP Solr is listening on
|
||||
'port' => '8983', // default: 8983 | The port Solr is listening on
|
||||
'path' => '/solr' // default: /solr | The suburl the solr service is available on
|
||||
'version' => '4' // default: 4 | Solr server version - currently only 3 and 4 supported
|
||||
'service' => 'Solr4Service' // default: depends on version, Solr3Service for 3, Solr4Service for 4 | the class that provides actual communcation to the Solr server
|
||||
'extraspath' => BASE_PATH .'/fulltextsearch/conf/solr/4/extras/' // default: <basefolder>/fulltextsearch/conf/solr/{version}/extras/ | Absolute path to the folder containing templates which are used for generating the schema and field definitions.
|
||||
'templates' => BASE_PATH . '/fulltextsearch/conf/solr/4/templates/' // default: <basefolder>/fulltextsearch/conf/solr/{version}/templates/ | Absolute path to the configuration default files, e.g. solrconfig.xml
|
||||
'path' => '/solr', // default: /solr | The suburl the solr service is available on
|
||||
'version' => '4', // default: 4 | Solr server version - currently only 3 and 4 supported
|
||||
'service' => 'Solr4Service', // default: depends on version, Solr3Service for 3, Solr4Service for 4 | the class that provides actual communcation to the Solr server
|
||||
'extraspath' => BASE_PATH .'/fulltextsearch/conf/solr/4/extras/', // default: <basefolder>/fulltextsearch/conf/solr/{version}/extras/ | Absolute path to the folder containing templates which are used for generating the schema and field definitions.
|
||||
'templates' => BASE_PATH . '/fulltextsearch/conf/solr/4/templates/', // default: <basefolder>/fulltextsearch/conf/solr/{version}/templates/ | Absolute path to the configuration default files, e.g. solrconfig.xml
|
||||
'indexstore' => array(
|
||||
'mode' => 'file', // a classname which implements SolrConfigStore, or 'file' or 'webdav'
|
||||
'path' => BASE_PATH . '/.solr' // The (locally accessible) path to write the index configurations to OR The suburl on the solr host that is set up to accept index configurations via webdav
|
||||
'remotepath' => '/opt/solr/config' // default (file mode only): same as 'path' above | The path that the Solr server will read the index configurations from
|
||||
'auth' => 'solr:solr' // default: none | Webdav only - A username:password pair string to use to auth against the webdav server
|
||||
'path' => BASE_PATH . '/.solr', // The (locally accessible) path to write the index configurations to OR The suburl on the solr host that is set up to accept index configurations via webdav
|
||||
'remotepath' => '/opt/solr/config', // default (file mode only): same as 'path' above | The path that the Solr server will read the index configurations from
|
||||
'auth' => 'solr:solr', // default: none | Webdav only - A username:password pair string to use to auth against the webdav server
|
||||
'port' => '80' // default: same as solr port | The port for WebDAV if different from the Solr port
|
||||
)
|
||||
));
|
||||
|
@ -185,7 +185,7 @@ class SolrReindexQueuedTest extends SapphireTest
|
||||
$this->assertEquals(1, $logger->countMessages('Completed init of reindex'));
|
||||
|
||||
// Test that invalid classes are removed
|
||||
$this->assertNotEmpty($logger->getMessages('Clearing obsolete classes from SolrReindexTest_Index'));
|
||||
$this->assertNotEmpty($logger->getMessages('Clearing obsolete classes from ' . SolrReindexTest_Index::class));
|
||||
|
||||
// Test that valid classes in invalid variants are removed
|
||||
$this->assertNotEmpty($logger->getMessages(
|
||||
|
@ -8,6 +8,7 @@ use SilverStripe\FullTextSearch\Tests\SolrReindexTest\SolrReindexTest_Index;
|
||||
use SilverStripe\FullTextSearch\Tests\SolrReindexTest\SolrReindexTest_TestHandler;
|
||||
use SilverStripe\FullTextSearch\Tests\SolrReindexTest\SolrReindexTest_Item;
|
||||
use SilverStripe\FullTextSearch\Tests\SolrReindexTest\SolrReindexTest_RecordingLogger;
|
||||
use SilverStripe\FullTextSearch\Solr\Reindex\Handlers\SolrReindexHandler;
|
||||
use SilverStripe\FullTextSearch\Solr\Services\Solr4Service;
|
||||
use SilverStripe\FullTextSearch\Solr\Tasks\Solr_Reindex;
|
||||
use SilverStripe\Core\Config\Config;
|
||||
@ -42,10 +43,10 @@ class SolrReindexTest extends SapphireTest
|
||||
parent::setUp();
|
||||
|
||||
// Set test handler for reindex
|
||||
Config::modify()->set('Injector', 'SolrReindexHandler', array(
|
||||
Config::modify()->set('Injector', SolrReindexHandler::class, array(
|
||||
'class' => SolrReindexTest_TestHandler::class
|
||||
));
|
||||
Injector::inst()->registerService(new SolrReindexTest_TestHandler(), 'SolrReindexHandler');
|
||||
Injector::inst()->registerService(new SolrReindexTest_TestHandler(), SolrReindexHandler::class);
|
||||
|
||||
// Set test variant
|
||||
SolrReindexTest_Variant::enable();
|
||||
@ -105,7 +106,7 @@ class SolrReindexTest extends SapphireTest
|
||||
*/
|
||||
protected function getHandler()
|
||||
{
|
||||
return Injector::inst()->get('SolrReindexHandler');
|
||||
return Injector::inst()->get(SolrReindexHandler::class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user