diff --git a/src/Search/Extensions/SearchUpdater_ObjectHandler.php b/src/Search/Extensions/SearchUpdater_ObjectHandler.php index 5e1c33c..c202bea 100644 --- a/src/Search/Extensions/SearchUpdater_ObjectHandler.php +++ b/src/Search/Extensions/SearchUpdater_ObjectHandler.php @@ -61,7 +61,7 @@ class SearchUpdater_ObjectHandler extends DataExtension $class = $this->owner->ClassName; $state = SearchVariant::current_state($class); $base = DataObject::getSchema()->baseDataClass($class); - $key = "$id:$base:".serialize($state); + $key = "$id:$base:" . serialize($state); $statefulids = array(array( 'id' => $id, diff --git a/src/Search/Indexes/SearchIndex.php b/src/Search/Indexes/SearchIndex.php index e3cbb75..cbcaa89 100644 --- a/src/Search/Indexes/SearchIndex.php +++ b/src/Search/Indexes/SearchIndex.php @@ -438,7 +438,7 @@ abstract class SearchIndex extends ViewableData continue; } - $key = sha1($field['base'].serialize($field['lookup_chain'])); + $key = sha1($field['base'] . serialize($field['lookup_chain'])); $fieldname = "{$field['class']}:{$field['field']}"; if (isset($this->derivedFields[$key])) { @@ -619,7 +619,7 @@ abstract class SearchIndex extends ViewableData $tableName = DataObject::getSchema()->tableName($step['class']); if ($step['through'] == 'has_one') { - $sql = new SQLSelect('"ID"', '"'.$tableName.'"', '"'.$step['foreignkey'].'" IN ('.implode(',', $ids).')'); + $sql = new SQLSelect('"ID"', '"' . $tableName . '"', '"' . $step['foreignkey'] . '" IN (' . implode(',', $ids) . ')'); singleton($step['class'])->extend('augmentSQL', $sql); $ids = $sql->execute()->column(); @@ -627,8 +627,8 @@ abstract class SearchIndex extends ViewableData // Use TableName for queries $otherTableName = DataObject::getSchema()->tableName($step['otherclass']); - $sql = new SQLSelect('"'.$tableName.'"."ID"', '"'.$tableName.'"', '"'.$otherTableName.'"."ID" IN ('.implode(',', $ids).')'); - $sql->addInnerJoin($otherTableName, '"'.$tableName.'"."ID" = "'.$otherTableName.'"."'.$step['foreignkey'].'"'); + $sql = new SQLSelect('"' . $tableName . '"."ID"', '"' . $tableName . '"', '"' . $otherTableName . '"."ID" IN (' . implode(',', $ids) . ')'); + $sql->addInnerJoin($otherTableName, '"' . $tableName . '"."ID" = "' . $otherTableName . '"."' . $step['foreignkey'] . '"'); singleton($step['class'])->extend('augmentSQL', $sql); $ids = $sql->execute()->column(); diff --git a/src/Search/Processors/SearchUpdateCommitJobProcessor.php b/src/Search/Processors/SearchUpdateCommitJobProcessor.php index 64015fb..00d23e0 100644 --- a/src/Search/Processors/SearchUpdateCommitJobProcessor.php +++ b/src/Search/Processors/SearchUpdateCommitJobProcessor.php @@ -170,7 +170,7 @@ class SearchUpdateCommitJobProcessor implements QueuedJob // the current request $cooldown = Config::inst()->get(__CLASS__, 'cooldown'); $now = new DateTime(DBDatetime::now()->getValue()); - $now->add(new DateInterval('PT'.$cooldown.'S')); + $now->add(new DateInterval('PT' . $cooldown . 'S')); $runat = $now->Format('Y-m-d H:i:s'); $this->addMessage("Indexing already run this request, but incomplete. Re-scheduling for {$runat}"); diff --git a/src/Search/Updaters/SearchUpdater.php b/src/Search/Updaters/SearchUpdater.php index 5d3d614..f3a8b45 100644 --- a/src/Search/Updaters/SearchUpdater.php +++ b/src/Search/Updaters/SearchUpdater.php @@ -91,7 +91,7 @@ class SearchUpdater $fields = isset($details['fields']) ? $details['fields'] : array(); $base = DataObject::getSchema()->baseDataClass($class); - $key = "$id:$base:".serialize($state); + $key = "$id:$base:" . serialize($state); $statefulids = array(array('id' => $id, 'state' => $state)); @@ -105,8 +105,8 @@ class SearchUpdater 'command' => $command, 'fields' => array() ); - } // Otherwise update the class label if it's more specific than the currently recorded one - elseif (is_subclass_of($class, $writes[$key]['class'])) { + } elseif (is_subclass_of($class, $writes[$key]['class'])) { + // Otherwise update the class label if it's more specific than the currently recorded one $writes[$key]['class'] = $class; } diff --git a/src/Solr/Reindex/Handlers/SolrReindexBase.php b/src/Solr/Reindex/Handlers/SolrReindexBase.php index 6db01c1..ed36bcc 100644 --- a/src/Solr/Reindex/Handlers/SolrReindexBase.php +++ b/src/Solr/Reindex/Handlers/SolrReindexBase.php @@ -44,7 +44,7 @@ abstract class SolrReindexBase implements SolrReindexHandler $indexClasses = $this->getClassesForIndex($indexInstance, $classes); // Clear all records in this index which do not contain the given classes - $logger->info("Clearing obsolete classes from ".$indexInstance->getIndexName()); + $logger->info("Clearing obsolete classes from " . $indexInstance->getIndexName()); $indexInstance->clearObsoleteClasses($indexClasses); // Build queue for each class @@ -185,7 +185,7 @@ abstract class SolrReindexBase implements SolrReindexHandler $indexInstance->add($item); $item->destroy(); } - $logger->info("Updated ".implode(',', $processed)); + $logger->info("Updated " . implode(',', $processed)); // 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'); diff --git a/src/Solr/Reindex/Handlers/SolrReindexImmediateHandler.php b/src/Solr/Reindex/Handlers/SolrReindexImmediateHandler.php index 745c94c..91a7afa 100644 --- a/src/Solr/Reindex/Handlers/SolrReindexImmediateHandler.php +++ b/src/Solr/Reindex/Handlers/SolrReindexImmediateHandler.php @@ -67,9 +67,9 @@ class SolrReindexImmediateHandler extends SolrReindexBase $statevar = json_encode($state); if (strpos(PHP_OS, "WIN") !== false) { - $statevar = '"'.str_replace('"', '\\"', $statevar).'"'; + $statevar = '"' . str_replace('"', '\\"', $statevar) . '"'; } else { - $statevar = "'".$statevar."'"; + $statevar = "'" . $statevar . "'"; $class = addslashes($class); $indexClassEscaped = addslashes($indexClass); } diff --git a/src/Solr/SolrIndex.php b/src/Solr/SolrIndex.php index fcf3f51..4b6e33c 100644 --- a/src/Solr/SolrIndex.php +++ b/src/Solr/SolrIndex.php @@ -2,6 +2,7 @@ namespace SilverStripe\FullTextSearch\Solr; +use Exception; use SilverStripe\Control\Director; use SilverStripe\Core\Environment; use SilverStripe\FulltextSearch\Search\Indexes\SearchIndex; @@ -334,7 +335,7 @@ abstract class SolrIndex extends SearchIndex public function setFieldBoosting($field, $level) { if (!isset($this->fulltextFields[$field])) { - throw new \InvalidArgumentException("No fulltext field $field exists on ".$this->getIndexName()); + throw new \InvalidArgumentException("No fulltext field $field exists on " . $this->getIndexName()); } if ($level === null) { unset($this->boostedFields[$field]); @@ -714,7 +715,7 @@ abstract class SolrIndex extends SearchIndex } } if ($classq) { - $fq[] = '+('.implode(' ', $classq).')'; + $fq[] = '+(' . implode(' ', $classq) . ')'; } // Filter by filters @@ -735,13 +736,13 @@ abstract class SolrIndex extends SearchIndex if (!headers_sent() && Director::isDev()) { if ($q) { - header('X-Query: '.implode(' ', $q)); + header('X-Query: ' . implode(' ', $q)); } if ($fq) { - header('X-Filters: "'.implode('", "', $fq).'"'); + header('X-Filters: "' . implode('", "', $fq) . '"'); } if ($qf) { - header('X-QueryFields: '.$qf); + header('X-QueryFields: ' . $qf); } } @@ -898,11 +899,11 @@ abstract class SolrIndex extends SearchIndex $field = $this->sanitiseClassName($field); $boost = (isset($search['boost'][$field])) ? '^' . $search['boost'][$field] : ''; - $searchq[] = "{$field}:".$part.$fuzzy.$boost; + $searchq[] = "{$field}:" . $part . $fuzzy . $boost; } - $q[] = '+('.implode(' OR ', $searchq).')'; + $q[] = '+(' . implode(' OR ', $searchq) . ')'; } else { - $q[] = '+'.$part.$fuzzy; + $q[] = '+' . $part . $fuzzy; } $hlq[] = $part; } @@ -938,11 +939,11 @@ abstract class SolrIndex extends SearchIndex } $requireq[] = "$field:[$start TO $end]"; } else { - $requireq[] = $field.':"'.$value.'"'; + $requireq[] = $field . ':"' . $value . '"'; } } - $fq[] = '+('.implode(' ', $requireq).')'; + $fq[] = '+(' . implode(' ', $requireq) . ')'; } return $fq; } @@ -979,11 +980,11 @@ abstract class SolrIndex extends SearchIndex } $excludeq[] = "$field:[$start TO $end]"; } else { - $excludeq[] = $field.':"'.$value.'"'; + $excludeq[] = $field . ':"' . $value . '"'; } } - $fq[] = ($missing ? "+{$field}:[* TO *] " : '') . '-('.implode(' ', $excludeq).')'; + $fq[] = ($missing ? "+{$field}:[* TO *] " : '') . '-(' . implode(' ', $excludeq) . ')'; } return $fq; } @@ -1036,7 +1037,7 @@ abstract class SolrIndex extends SearchIndex ); // Upload additional files - foreach (glob($this->getExtrasPath().'/*') as $file) { + foreach (glob($this->getExtrasPath() . '/*') as $file) { if (is_file($file)) { $store->uploadFile($this->getIndexName(), $file); } diff --git a/src/Solr/Stores/SolrConfigStore_File.php b/src/Solr/Stores/SolrConfigStore_File.php index e9f7883..df8494a 100644 --- a/src/Solr/Stores/SolrConfigStore_File.php +++ b/src/Solr/Stores/SolrConfigStore_File.php @@ -36,7 +36,7 @@ class SolrConfigStore_File implements SolrConfigStore public function uploadFile($index, $file) { $targetDir = $this->getTargetDir($index); - copy($file, $targetDir.'/'.basename($file)); + copy($file, $targetDir . '/' . basename($file)); } public function uploadString($index, $filename, $string) @@ -47,6 +47,6 @@ class SolrConfigStore_File implements SolrConfigStore public function instanceDir($index) { - return $this->remote.'/'.$index; + return $this->remote . '/' . $index; } } diff --git a/src/Solr/Stores/SolrConfigStore_WebDAV.php b/src/Solr/Stores/SolrConfigStore_WebDAV.php index 3701f16..3d2bbd8 100644 --- a/src/Solr/Stores/SolrConfigStore_WebDAV.php +++ b/src/Solr/Stores/SolrConfigStore_WebDAV.php @@ -18,8 +18,8 @@ class SolrConfigStore_WebDAV implements SolrConfigStore $this->url = implode('', array( 'http://', - isset($config['auth']) ? $config['auth'].'@' : '', - $options['host'].':'.(isset($config['port']) ? $config['port'] : $options['port']), + isset($config['auth']) ? $config['auth'] . '@' : '', + $options['host'] . ':' . (isset($config['port']) ? $config['port'] : $options['port']), $config['path'] )); $this->remote = $config['remotepath']; @@ -43,7 +43,7 @@ class SolrConfigStore_WebDAV implements SolrConfigStore public function uploadFile($index, $file) { $targetDir = $this->getTargetDir($index); - WebDAV::upload_from_file($file, $targetDir.'/'.basename($file)); + WebDAV::upload_from_file($file, $targetDir . '/' . basename($file)); } public function uploadString($index, $filename, $string) diff --git a/src/Solr/Tasks/Solr_Configure.php b/src/Solr/Tasks/Solr_Configure.php index 6e00259..28afc98 100644 --- a/src/Solr/Tasks/Solr_Configure.php +++ b/src/Solr/Tasks/Solr_Configure.php @@ -92,7 +92,7 @@ class Solr_Configure extends Solr_BuildTask } 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); + user_error('Unknown Solr index mode ' . $indexstore['mode'], E_USER_ERROR); } } } diff --git a/src/Utils/WebDAV.php b/src/Utils/WebDAV.php index 5c657c7..1b4bf1e 100644 --- a/src/Utils/WebDAV.php +++ b/src/Utils/WebDAV.php @@ -33,12 +33,12 @@ class WebDAV return true; } - user_error("Got error from webdav server - ".$code, E_USER_ERROR); + user_error("Got error from webdav server - " . $code, E_USER_ERROR); } public static function mkdir($url) { - $ch = self::curl_init(rtrim($url, '/').'/', 'MKCOL'); + $ch = self::curl_init(rtrim($url, '/') . '/', 'MKCOL'); $res = curl_exec($ch); $code = curl_getinfo($ch, CURLINFO_HTTP_CODE); diff --git a/tests/SolrIndexSubsitesTest.php b/tests/SolrIndexSubsitesTest.php index 7d31019..d5c292a 100644 --- a/tests/SolrIndexSubsitesTest.php +++ b/tests/SolrIndexSubsitesTest.php @@ -95,7 +95,7 @@ class SolrIndexSubsitesTest extends SapphireTest if (class_exists(Subsite::class) && DataObject::getSchema()->hasOneComponent($object->getClassName(), 'Subsite') ) { - $variants[] = '"SearchVariantSubsites":"' . $subsiteID. '"'; + $variants[] = '"SearchVariantSubsites":"' . $subsiteID . '"'; } // Check versioned diff --git a/tests/SolrIndexVersionedTest.php b/tests/SolrIndexVersionedTest.php index 6940b4e..f0fdcfb 100644 --- a/tests/SolrIndexVersionedTest.php +++ b/tests/SolrIndexVersionedTest.php @@ -85,7 +85,7 @@ class SolrIndexVersionedTest extends SapphireTest { $id = $object->ID; $class = DataObject::getSchema()->baseDataClass($object); - return $id.'-'.$class.'-{'.json_encode(SearchVariantVersioned::class).':"'.$stage.'"}'; + return $id . '-' . $class . '-{' . json_encode(SearchVariantVersioned::class) . ':"' . $stage . '"}'; } /**