Merge branch '3'

This commit is contained in:
Dan Hensby 2020-04-07 09:01:35 +01:00
commit 57ebfabf17
No known key found for this signature in database
GPG Key ID: F76D6B5FE0626A99
12 changed files with 60 additions and 16 deletions

3
.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
/vendor/
/resources/
composer.lock

View File

@ -25,10 +25,10 @@ before_script:
- echo 'memory_limit=2G' >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
- composer validate
- composer require --no-update symbiote/silverstripe-queuedjobs ^4.0
- if [[ $SUBSITES ]]; then composer require --no-update silverstripe/subsites 2.3.x-dev; fi
- if [[ $DB == "PGSQL" ]]; then composer require --no-update silverstripe/postgresql 2.3.x-dev; fi
- composer require --no-update silverstripe/installer "$INSTALLER_VERSION"
- composer require symbiote/silverstripe-queuedjobs:^4.0 --no-update
- if [[ $SUBSITES ]]; then composer require silverstripe/subsites:2.3.x-dev --no-update; fi
- if [[ $DB == "PGSQL" ]]; then composer require silverstripe/postgresql:2.3.x-dev --no-update; fi
- composer require silverstripe/installer "$INSTALLER_VERSION" --no-update
- composer install --prefer-dist --no-interaction --no-progress --no-suggest --optimize-autoloader --verbose --profile
script:

View File

@ -6,6 +6,7 @@
[![SilverStripe supported module](https://img.shields.io/badge/silverstripe-supported-0071C4.svg)](https://www.silverstripe.org/software/addons/silverstripe-commercially-supported-module-list/)
Adds support for fulltext search engines like Sphinx and Solr to SilverStripe CMS.
Compatible with PHP 7.2
## Maintainer Contact

View File

@ -46,6 +46,10 @@
"dev-master": "4.x-dev"
}
},
"scripts": {
"lint": "phpcs -s src/ tests/",
"lint-clean": "phpcbf src/ tests/"
},
"suggest": {
"symbiote/silverstripe-queuedjobs": "Add background execution of indexing tasks",
"silverstripe/fulltextsearch-localsolr": "Adds a ready-to-use local Solr server for initial development"

14
lang/fi.yml Normal file
View File

@ -0,0 +1,14 @@
fi:
SilverStripe\FullTextSearch\Solr\Forms\SearchForm:
GO: Hae
SEARCH: Haku
SolrResultsPage:
SearchQuery: 'Hakusanasi oli'
DidYouMean: 'Tarkoititko'
ReadMore: 'Lue lisää'
NoResults: 'Pahoittelut, mutta hakusi ei tuottanut yhtään osumaa.'
Page: 'Sivu'
of: '/'
ViewPreviousPage: 'Katso edellinen sivu'
View page number: 'Siirry sivulle'
ViewNextPage: 'Katso seuraava sivu'

View File

@ -40,7 +40,7 @@ class SearchUpdateQueuedJobProcessor extends SearchUpdateBatchedProcessor implem
public function getJobType()
{
return Config::inst()->get('SearchUpdateQueuedJobProcessor', 'reindex_queue');
return Config::inst()->get(__CLASS__, 'reindex_queue');
}
public function jobFinished()

View File

@ -11,7 +11,8 @@ use SilverStripe\ORM\DB;
use SilverStripe\FullTextSearch\Search\FullTextSearch;
use SilverStripe\FullTextSearch\Search\SearchIntrospection;
use SilverStripe\FullTextSearch\Search\Variants\SearchVariant;
use SilverStripe\FullTextSearch\Search\Processors\SearchUpdateImmediateProcessor;
use SilverStripe\FullTextSearch\Search\Processors\SearchUpdateProcessor;
use ReflectionClass;
/**
@ -151,7 +152,7 @@ class SearchUpdater
foreach ($dirtyids as $dirtyclass => $ids) {
if ($ids) {
if (!self::$processor) {
self::$processor = Injector::inst()->create(SearchUpdateImmediateProcessor::class);
self::$processor = Injector::inst()->create(SearchUpdateProcessor::class);
}
self::$processor->addDirtyIDs($dirtyclass, $ids, $index);
}

View File

@ -4,6 +4,7 @@ namespace SilverStripe\FullTextSearch\Search\Variants;
use ReflectionClass;
use SilverStripe\Core\ClassInfo;
use SilverStripe\Core\Extensible;
use SilverStripe\Core\Config\Configurable;
use SilverStripe\FullTextSearch\Search\Indexes\SearchIndex;
use SilverStripe\FullTextSearch\Search\Queries\SearchQuery;
@ -16,6 +17,7 @@ use SilverStripe\FullTextSearch\Utils\CombinationsArrayIterator;
abstract class SearchVariant
{
use Configurable;
use Extensible;
/**
* Whether this variant is enabled

View File

@ -36,10 +36,14 @@ class SearchVariantSubsites extends SearchVariant
// Include all DataExtensions that contain a SubsiteID.
// TODO: refactor subsites to inherit a common interface, so we can run introspection once only.
return SearchIntrospection::has_extension($class, SiteTreeSubsites::class, $includeSubclasses)
$appliesTo = SearchIntrospection::has_extension($class, SiteTreeSubsites::class, $includeSubclasses)
|| SearchIntrospection::has_extension($class, GroupSubsites::class, $includeSubclasses)
|| SearchIntrospection::has_extension($class, FileSubsites::class, $includeSubclasses)
|| SearchIntrospection::has_extension($class, SiteConfigSubsites::class, $includeSubclasses);
$this->extend('updateAppliesTo', $appliesTo, $class, $includeSubclasses);
return $appliesTo;
}
public function currentState()

View File

@ -99,6 +99,8 @@ abstract class SolrReindexBase implements SolrReindexHandler
$batchSize,
$taskName
) {
// Get current state
$originalState = SearchVariant::current_state();
// Set state
SearchVariant::activate_state($state);
@ -122,6 +124,9 @@ abstract class SolrReindexBase implements SolrReindexHandler
for ($group = 0; $group < $groups; $group++) {
$this->processGroup($logger, $indexInstance, $state, $class, $groups, $group, $taskName);
}
// Reset state to originalState
SearchVariant::activate_state($originalState);
}
/**
@ -168,7 +173,11 @@ abstract class SolrReindexBase implements SolrReindexHandler
) {
// Set time limit and state
Environment::increaseTimeLimitTo();
// Get current state
$originalState = SearchVariant::current_state();
// Set state
SearchVariant::activate_state($state);
$logger->info("Adding $class");
// Prior to adding these records to solr, delete existing solr records
@ -187,6 +196,9 @@ abstract class SolrReindexBase implements SolrReindexHandler
}
$logger->info("Updated " . implode(',', $processed));
// Reset state to originalState
SearchVariant::activate_state($originalState);
// This will slow down things a tiny bit, but it is done so that we don't timeout to the database during a reindex
DB::query('SELECT 1');

View File

@ -31,6 +31,9 @@ abstract class SolrIndex extends SearchIndex
'*' => 'string',
'Boolean' => 'boolean',
'Date' => 'tdate',
'Datetime' => 'tdate',
'DBDate' => 'tdate',
'DBDatetime' => 'tdate',
'SSDatetime' => 'tdate',
'SS_Datetime' => 'tdate',
'ForeignKey' => 'tint',

View File

@ -2,11 +2,11 @@
<h1>$Title</h1>
<% if $Query %>
<p class="searchQuery">You searched for &quot;{$Query}&quot;</p>
<p class="searchQuery"><%t SolrResultsPage.SearchQuery 'You searched for' %> &quot;{$Query}&quot;</p>
<% end_if %>
<% if $Results.Suggestion %>
<p class="spellCheck">Did you mean <a href="{$Link}SearchForm?Search=$Results.SuggestionQueryString">$Results.SuggestionNice</a>?</p>
<p class="spellCheck"><%t SolrResultsPage.DidYouMean 'Did you mean' %> <a href="{$Link}SearchForm?Search=$Results.SuggestionQueryString">$Results.SuggestionNice</a>?</p>
<% end_if %>
<% if $Results.Matches %>
@ -23,34 +23,34 @@
</a>
</h4>
<p><% if $Abstract %>$Abstract.XML<% else %>$Content.ContextSummary<% end_if %></p>
<a class="readMoreLink" href="$Link" title="Read more about &quot;{$Title}&quot;">Read more about &quot;{$Title}&quot;...</a>
<a class="readMoreLink" href="$Link" title="<%t SolrResultsPage.ReadMore 'Read more about' %> &quot;{$Title}&quot;"><%t SolrResultsPage.ReadMore 'Read more about' %> &quot;{$Title}&quot;...</a>
</li>
<% end_loop %>
</ul>
<% else %>
<p>Sorry, your search query did not return any results.</p>
<p><%t SolrResultsPage.NoResults 'Sorry, your search query did not return any results.' %></p>
<% end_if %>
<% if $Results.Matches.MoreThanOnePage %>
<div id="PageNumbers">
<div class="pagination">
<% if $Results.Matches.NotFirstPage %>
<a class="prev" href="$Results.Matches.PrevLink" title="View the previous page">&larr;</a>
<a class="prev" href="$Results.Matches.PrevLink" title="<%t SolrResultsPage.ViewPreviousPage 'View the previous page' %>">&larr;</a>
<% end_if %>
<span>
<% loop $Results.Matches.Pages %>
<% if $CurrentBool %>
$PageNum
<% else %>
<a href="$Link" title="View page number $PageNum" class="go-to-page">$PageNum</a>
<a href="$Link" title="<%t SolrResultsPage.ViewPageNumber 'View page number' %> $PageNum" class="go-to-page">$PageNum</a>
<% end_if %>
<% end_loop %>
</span>
<% if $Results.Matches.NotLastPage %>
<a class="next" href="$Results.Matches.NextLink" title="View the next page">&rarr;</a>
<a class="next" href="$Results.Matches.NextLink" title="<%t SolrResultsPage.ViewNextPage 'View the next page' %>">&rarr;</a>
<% end_if %>
</div>
<p>Page $Results.Matches.CurrentPage of $Results.Matches.TotalPages</p>
<p><%t SolrResultsPage.Page 'Page' %> $Results.Matches.CurrentPage <%t SolrResultsPage.of 'of' %> $Results.Matches.TotalPages</p>
</div>
<% end_if %>
</div>