Merge pull request #208 from creative-commoners/pulls/3.1/proxification

NEW Update to use proxied DB instead of self-proxied
This commit is contained in:
Robbie Averill 2018-03-15 10:50:01 +13:00 committed by GitHub
commit 990c996c97
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 54 additions and 32 deletions

View File

@ -1,5 +1,11 @@
inherit: true
build:
nodes:
analysis:
tests:
override: [php-scrutinizer-run]
checks:
php:
code_rating: true

View File

@ -1,32 +1,6 @@
---
Name: fulltextsearchmysql
After:
- 'databaseconnectors'
Name: fulltextsearchproxydb
---
SilverStripe\Core\Injector\Injector:
MySQLDatabase:
class: SilverStripe\FullTextSearch\Search\Captures\SearchManipulateCapture_MySQLDatabase
MySQLPDODatabase:
class: SilverStripe\FullTextSearch\Search\Captures\SearchManipulateCapture_MySQLDatabase
---
Name: fulltextsearchpostgresql
After:
- 'postgresqlconnectors'
---
SilverStripe\Core\Injector\Injector:
PostgrePDODatabase:
class: SilverStripe\FullTextSearch\Search\Captures\SearchManipulateCapture_PostgreSQLDatabase
PostgreSQLDatabase:
class: SilverStripe\FullTextSearch\Search\Captures\SearchManipulateCapture_PostgreSQLDatabase
---
Name: fulltextsearchsqlite
After:
- 'sqlite3connectors'
---
SilverStripe\Core\Injector\Injector:
SQLite3PDODatabase:
class: SilverStripe\FullTextSearch\Search\Captures\SearchManipulateCapture_SQLite3Database
SQLite3Database:
class: SilverStripe\FullTextSearch\Search\Captures\SearchManipulateCapture_SQLite3Database
TractorCow\SilverStripeProxyDB\ProxyDBFactory:
extensions:
- SilverStripe\FullTextSearch\Search\Extensions\ProxyDBExtension

View File

@ -24,7 +24,8 @@
"silverstripe/framework": "^4.0",
"monolog/monolog": "~1.15",
"ptcinc/solr-php-client": "^1.0",
"symfony/process": "^3.2"
"symfony/process": "^3.2",
"tractorcow/silverstripe-proxy-db" : "~0.1"
},
"require-dev": {
"silverstripe/cms": "^4.0",

View File

@ -5,6 +5,10 @@ namespace SilverStripe\FullTextSearch\Search\Captures;
use SilverStripe\ORM\Connect\MySQLDatabase;
use SilverStripe\FullTextSearch\Search\Updaters\SearchUpdater;
/**
* @deprecated 3.1...4.0 Please use tractorcow/silverstripe-proxy-db to proxy the database connector instead
*/
class SearchManipulateCapture_MySQLDatabase extends MySQLDatabase
{

View File

@ -9,6 +9,10 @@ if (!class_exists(PostgreSQLDatabase::class)) {
return;
}
/**
* @deprecated 3.1...4.0 Please use tractorcow/silverstripe-proxy-db to proxy the database connector instead
*/
class SearchManipulateCapture_PostgreSQLDatabase extends PostgreSQLDatabase
{
public $isManipulationCapture = true;

View File

@ -9,6 +9,10 @@ if (!class_exists(SQLite3Database::class)) {
return;
}
/**
* @deprecated 3.1...4.0 Please use tractorcow/silverstripe-proxy-db to proxy the database connector instead
*/
class SearchManipulateCapture_SQLite3Database extends SQLite3Database
{

View File

@ -0,0 +1,29 @@
<?php
namespace SilverStripe\FullTextSearch\Search\Extensions;
use SilverStripe\Core\Extension;
use TractorCow\ClassProxy\Generators\ProxyGenerator;
use SilverStripe\FullTextSearch\Search\Updaters\SearchUpdater;
/**
* This database connector proxy will allow {@link SearchUpdater::handle_manipulation} to monitor database schema
* changes that may need to be propagated through to search indexes.
*
*/
class ProxyDBExtension extends Extension
{
/**
* @param ProxyGenerator $proxy
*
* Ensure the search index is kept up to date by monitoring SilverStripe database manipulations
*/
public function updateProxy(ProxyGenerator &$proxy)
{
$proxy = $proxy->addMethod('manipulate', function ($args, $next) {
$manipulation = $args[0];
SearchUpdater::handle_manipulation($manipulation);
return $next(...$args);
});
}
}

View File

@ -42,7 +42,7 @@ class SearchUpdater
public static $processor = null;
/**
* Called by the SearchManiplateCapture database adapter with every manipulation made against the database.
* Called by the ProxyDBExtension database connector with every manipulation made against the database.
*
* Check every index to see what objects need re-inserting into what indexes to keep the index fresh,
* but doesn't actually do it yet.