mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-15 05:53:13 +00:00
[SearchEngine] Fix build on 32bit systems
This commit is contained in:
@@ -15,7 +15,7 @@ before_script:
|
||||
- tar xzf sphinx-2.0.6-release.tar.gz
|
||||
- sh -c "cd sphinx-2.0.6-release && wget http://snowball.tartarus.org/dist/libstemmer_c.tgz && tar xzf libstemmer_c.tgz && ./configure --with-libstemmer --with-iconv --with-mysql --enable-id64 --quiet && make --quiet && sudo make install"
|
||||
- sudo mkdir -p /var/sphinx/datas
|
||||
- sudo chmod 0777 /var/sphinx
|
||||
- sudo chmod -R 0777 /var/sphinx
|
||||
- mysql -e 'create database ab_test;create database db_test; create database ab_unitTests; create database db_unitTests;'
|
||||
- sudo mysql -e "GRANT ALL PRIVILEGES ON ab_unitTests.* TO 'phraseaUnitTests'@'localhost' IDENTIFIED BY 'iWvGxPE8' WITH GRANT OPTION"
|
||||
- sudo mysql -e "GRANT ALL PRIVILEGES ON db_unitTests.* TO 'phraseaUnitTests'@'localhost' IDENTIFIED BY 'iWvGxPE8' WITH GRANT OPTION"
|
||||
|
@@ -340,8 +340,7 @@ class Manager
|
||||
}
|
||||
break;
|
||||
case AttributeInterface::NAME_STATUS:
|
||||
|
||||
$element->set_binary_status($element->get_status() | $attribute->getValue());
|
||||
$element->set_binary_status(decbin(bindec($element->get_status()) | bindec($attribute->getValue())));
|
||||
|
||||
break;
|
||||
case AttributeInterface::NAME_STORY:
|
||||
|
@@ -489,8 +489,8 @@ searchd
|
||||
# listen = 192.168.0.1:9312
|
||||
# listen = 9312
|
||||
# listen = /var/run/searchd.sock
|
||||
listen = 9306
|
||||
listen = 9308:mysql41
|
||||
listen = 127.0.0.1:19306
|
||||
listen = 127.0.0.1:19308:mysql41
|
||||
|
||||
# log file, searchd run info is logged here
|
||||
# optional, default is \'searchd.log\'
|
||||
|
@@ -117,7 +117,7 @@ class SphinxSearchEngine implements SearchEngineInterface
|
||||
|
||||
for ($i = 4; $i < 32; $i++) {
|
||||
if ($binStatus[$i]) {
|
||||
$status[] = crc32($record->get_databox()->get_sbas_id() . '_' . $i);
|
||||
$status[] = sprintf("%u", crc32($record->get_databox()->get_sbas_id() . '_' . $i));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,8 +131,7 @@ class SphinxSearchEngine implements SearchEngineInterface
|
||||
}
|
||||
|
||||
foreach ($field->get_values() as $value) {
|
||||
|
||||
$sql = "REPLACE INTO "
|
||||
$this->rt_conn->exec("REPLACE INTO "
|
||||
. "metas_realtime" . $this->CRCdatabox($record->get_databox()) . " VALUES (
|
||||
'" . $value->getId() . "'
|
||||
,'" . str_replace("'", "\'", $value->getValue()) . "'
|
||||
@@ -141,21 +140,19 @@ class SphinxSearchEngine implements SearchEngineInterface
|
||||
," . $record->get_sbas_id() . "
|
||||
," . $record->get_collection()->get_coll_id() . "
|
||||
," . (int) $record->is_grouping() . "
|
||||
," . crc32($record->get_sbas_id() . '_' . $value->getDatabox_field()->get_id()) . "
|
||||
," . crc32($record->get_sbas_id() . '_' . $record->get_collection()->get_coll_id()) . "
|
||||
," . crc32($record->get_sbas_id() . '_' . $record->get_record_id()) . "
|
||||
," . crc32($record->get_type()) . "
|
||||
," . sprintf("%u", crc32($record->get_sbas_id() . '_' . $value->getDatabox_field()->get_id())) . "
|
||||
," . sprintf("%u", crc32($record->get_sbas_id() . '_' . $record->get_collection()->get_coll_id())) . "
|
||||
," . sprintf("%u", crc32($record->get_sbas_id() . '_' . $record->get_record_id())) . "
|
||||
," . sprintf("%u", crc32($record->get_type())) . "
|
||||
,0
|
||||
," . (int) $value->getDatabox_field()->isBusiness() . "
|
||||
," . crc32($record->get_collection()->get_coll_id() . '_' . (int) $value->getDatabox_field()->isBusiness()) . "
|
||||
," . sprintf("%u", crc32($record->get_collection()->get_coll_id() . '_' . (int) $value->getDatabox_field()->isBusiness())) . "
|
||||
," . $record->get_creation_date()->format('U') . "
|
||||
,(" . implode(',', $status) . ") )";
|
||||
|
||||
$this->rt_conn->exec($sql);
|
||||
,(" . implode(',', $status) . ") )");
|
||||
}
|
||||
}
|
||||
|
||||
$this->rt_conn->exec("REPLACE INTO "
|
||||
$sql = "REPLACE INTO "
|
||||
. "docs_realtime" . $this->CRCdatabox($record->get_databox()) . " VALUES (
|
||||
'" . $record->get_record_id() . "'
|
||||
,'" . str_replace("'", "\'", implode(' ', $all_datas)) . "'
|
||||
@@ -163,12 +160,14 @@ class SphinxSearchEngine implements SearchEngineInterface
|
||||
," . $record->get_sbas_id() . "
|
||||
," . $record->get_collection()->get_coll_id() . "
|
||||
," . (int) $record->is_grouping() . "
|
||||
," . crc32($record->get_sbas_id() . '_' . $record->get_collection()->get_coll_id()) . "
|
||||
," . crc32($record->get_sbas_id() . '_' . $record->get_record_id()) . "
|
||||
," . crc32($record->get_type()) . "
|
||||
," . sprintf("%u", crc32($record->get_sbas_id() . '_' . $record->get_collection()->get_coll_id())) . "
|
||||
," . sprintf("%u", crc32($record->get_sbas_id() . '_' . $record->get_record_id())) . "
|
||||
," . sprintf("%u", crc32($record->get_type())) . "
|
||||
,0
|
||||
," . $record->get_creation_date()->format('U') . "
|
||||
,(" . implode(',', $status) . ") )");
|
||||
,(" . implode(',', $status) . ") )";
|
||||
|
||||
$this->rt_conn->exec($sql);
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -388,13 +387,13 @@ class SphinxSearchEngine implements SearchEngineInterface
|
||||
*/
|
||||
public function CRCdatabox(\databox $databox)
|
||||
{
|
||||
return crc32(
|
||||
return sprintf("%u", crc32(
|
||||
str_replace(
|
||||
array('.', '%')
|
||||
, '_'
|
||||
, sprintf('%s_%s_%s_%s', $databox->get_host(), $databox->get_port(), $databox->get_user(), $databox->get_dbname())
|
||||
)
|
||||
);
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -412,7 +411,7 @@ class SphinxSearchEngine implements SearchEngineInterface
|
||||
$filters = array();
|
||||
|
||||
foreach ($options->collections() as $collection) {
|
||||
$filters[] = crc32($collection->get_databox()->get_sbas_id() . '_' . $collection->get_coll_id());
|
||||
$filters[] = sprintf("%u", crc32($collection->get_databox()->get_sbas_id() . '_' . $collection->get_coll_id()));
|
||||
}
|
||||
|
||||
$this->sphinx->SetFilter('crc_sbas_coll', $filters);
|
||||
@@ -425,7 +424,7 @@ class SphinxSearchEngine implements SearchEngineInterface
|
||||
|
||||
$filters = array();
|
||||
foreach ($options->fields() as $field) {
|
||||
$filters[] = crc32($field->get_databox()->get_sbas_id() . '_' . $field->get_id());
|
||||
$filters[] = sprintf("%u", crc32($field->get_databox()->get_sbas_id() . '_' . $field->get_id()));
|
||||
}
|
||||
|
||||
$this->sphinx->SetFilter('crc_struct_id', $filters);
|
||||
@@ -436,8 +435,8 @@ class SphinxSearchEngine implements SearchEngineInterface
|
||||
$crc_coll_business = array();
|
||||
|
||||
foreach ($options->businessFieldsOn() as $collection) {
|
||||
$crc_coll_business[] = crc32($collection->get_coll_id() . '_1');
|
||||
$crc_coll_business[] = crc32($collection->get_coll_id() . '_0');
|
||||
$crc_coll_business[] = sprintf("%u", crc32($collection->get_coll_id() . '_1'));
|
||||
$crc_coll_business[] = sprintf("%u", crc32($collection->get_coll_id() . '_0'));
|
||||
}
|
||||
|
||||
$non_business = array();
|
||||
@@ -452,7 +451,7 @@ class SphinxSearchEngine implements SearchEngineInterface
|
||||
}
|
||||
|
||||
foreach ($non_business as $collection) {
|
||||
$crc_coll_business[] = crc32($collection->get_coll_id() . '_0');
|
||||
$crc_coll_business[] = sprintf("%u", crc32($collection->get_coll_id() . '_0'));
|
||||
}
|
||||
|
||||
$this->sphinx->SetFilter('crc_coll_business', $crc_coll_business);
|
||||
@@ -470,14 +469,14 @@ class SphinxSearchEngine implements SearchEngineInterface
|
||||
continue;
|
||||
if (!array_key_exists($databox->get_sbas_id(), $status_opts[$n]))
|
||||
continue;
|
||||
$crc = crc32($databox->get_sbas_id() . '_' . $n);
|
||||
$crc = sprintf("%u", crc32($databox->get_sbas_id() . '_' . $n));
|
||||
$this->sphinx->SetFilter('status', array($crc), ($status_opts[$n][$databox->get_sbas_id()] == '0'));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($options->getRecordType()) {
|
||||
$this->sphinx->SetFilter('crc_type', array(crc32($options->getRecordType())));
|
||||
$this->sphinx->SetFilter('crc_type', array(sprintf("%u", crc32($options->getRecordType()))));
|
||||
}
|
||||
|
||||
|
||||
|
@@ -41,13 +41,13 @@ class module_console_sphinxGenerateSuggestion extends Command
|
||||
$params = phrasea::sbas_params($this->container);
|
||||
|
||||
foreach ($params as $sbas_id => $p) {
|
||||
$index = crc32(
|
||||
$index = sprintf("%u", crc32(
|
||||
str_replace(
|
||||
array('.', '%')
|
||||
, '_'
|
||||
, sprintf('%s_%s_%s_%s', $p['host'], $p['port'], $p['user'], $p['dbname'])
|
||||
)
|
||||
);
|
||||
));
|
||||
|
||||
$tmp_file = $this->container['phraseanet.registry']->get('GV_RootPath') . 'tmp/dict' . $index . '.txt';
|
||||
|
||||
|
@@ -137,7 +137,7 @@ class sphinx_configuration
|
||||
foreach ($lb as $id => $params) {
|
||||
|
||||
$serialized = str_replace(array('.', '%'), '_', sprintf('%s_%s_%s_%s', $params['host'], $params['port'], $params['user'], $params['dbname']));
|
||||
$index_crc = crc32($serialized);
|
||||
$index_crc = sprintf("%u", crc32($serialized));
|
||||
|
||||
$conf .= '
|
||||
|
||||
|
@@ -118,7 +118,7 @@
|
||||
</field>
|
||||
<field>
|
||||
<name>server_coll_id</name>
|
||||
<type>bigint(20)</type>
|
||||
<type>int(11) unsigned</type>
|
||||
<null></null>
|
||||
<extra></extra>
|
||||
<default>0</default>
|
||||
@@ -1076,7 +1076,7 @@
|
||||
<fields>
|
||||
<field>
|
||||
<name>id</name>
|
||||
<type>bigint(11) unsigned</type>
|
||||
<type>int(11) unsigned</type>
|
||||
<null></null>
|
||||
<extra>auto_increment</extra>
|
||||
<default></default>
|
||||
@@ -1211,7 +1211,7 @@
|
||||
</field>
|
||||
<field>
|
||||
<name>mask_and</name>
|
||||
<type>bigint(20) unsigned</type>
|
||||
<type>int(11) unsigned</type>
|
||||
|
||||
<null></null>
|
||||
<extra></extra>
|
||||
@@ -1222,7 +1222,7 @@
|
||||
<field>
|
||||
<name>mask_xor</name>
|
||||
|
||||
<type>bigint(20) unsigned</type>
|
||||
<type>int(11) unsigned</type>
|
||||
<null></null>
|
||||
<extra></extra>
|
||||
|
||||
@@ -1903,7 +1903,7 @@
|
||||
</field>
|
||||
<field>
|
||||
<name>sbas_id</name>
|
||||
<type>bigint(11) unsigned</type>
|
||||
<type>int(11) unsigned</type>
|
||||
<null></null>
|
||||
<extra></extra>
|
||||
<default></default>
|
||||
@@ -1911,7 +1911,7 @@
|
||||
</field>
|
||||
<field>
|
||||
<name>usr_id</name>
|
||||
<type>bigint(11) unsigned</type>
|
||||
<type>int(11) unsigned</type>
|
||||
<null></null>
|
||||
<extra></extra>
|
||||
<default></default>
|
||||
@@ -3541,7 +3541,7 @@
|
||||
</field>
|
||||
<field>
|
||||
<name>ord</name>
|
||||
<type>bigint(11) unsigned</type>
|
||||
<type>int(11) unsigned</type>
|
||||
<null></null>
|
||||
<extra></extra>
|
||||
|
||||
@@ -4088,7 +4088,7 @@
|
||||
</field>
|
||||
<field>
|
||||
<name>defaultftpdatasent</name>
|
||||
<type>bigint(20) unsigned</type>
|
||||
<type>int(11) unsigned</type>
|
||||
|
||||
<null></null>
|
||||
<extra></extra>
|
||||
@@ -4498,7 +4498,7 @@
|
||||
</field>
|
||||
<field>
|
||||
<name>mask_and</name>
|
||||
<type>bigint(20) unsigned</type>
|
||||
<type>int(11) unsigned</type>
|
||||
<null></null>
|
||||
<extra></extra>
|
||||
<default>0</default>
|
||||
@@ -4506,7 +4506,7 @@
|
||||
</field>
|
||||
<field>
|
||||
<name>mask_xor</name>
|
||||
<type>bigint(20) unsigned</type>
|
||||
<type>int(11) unsigned</type>
|
||||
<null></null>
|
||||
<extra></extra>
|
||||
<default>0</default>
|
||||
@@ -6070,7 +6070,7 @@
|
||||
<field>
|
||||
|
||||
<name>status</name>
|
||||
<type>bigint(20) unsigned</type>
|
||||
<type>int(10) unsigned</type>
|
||||
<null></null>
|
||||
<extra></extra>
|
||||
|
||||
|
@@ -81,6 +81,9 @@ abstract class SearchEngineAbstractTest extends \PhraseanetPHPUnitAuthenticatedA
|
||||
$record = self::$DI['record_24'];
|
||||
$query_string = 'recordid=' . $record->get_record_id();
|
||||
|
||||
self::$searchEngine->addRecord($record);
|
||||
$this->updateIndex();
|
||||
|
||||
self::$searchEngine->resetCache();
|
||||
$results = self::$searchEngine->query($query_string, 0, 1);
|
||||
$this->assertEquals(1, $results->total());
|
||||
@@ -96,6 +99,9 @@ abstract class SearchEngineAbstractTest extends \PhraseanetPHPUnitAuthenticatedA
|
||||
$record = self::$DI['record_24'];
|
||||
$query_string = 'storyid=' . $record->get_record_id();
|
||||
|
||||
self::$searchEngine->addRecord($record);
|
||||
$this->updateIndex();
|
||||
|
||||
self::$searchEngine->resetCache();
|
||||
$results = self::$searchEngine->query($query_string, 0, 1);
|
||||
$this->assertEquals(1, $results->total());
|
||||
@@ -243,7 +249,8 @@ abstract class SearchEngineAbstractTest extends \PhraseanetPHPUnitAuthenticatedA
|
||||
|
||||
$query_string = 'boomboklot' . $record->get_record_id() . 'onfield';
|
||||
|
||||
$options->setFields(array($this->editRecord($query_string, $record)));
|
||||
$field = $this->editRecord($query_string, $record);
|
||||
$options->setFields(array($field));
|
||||
|
||||
self::$searchEngine->setOptions($options);
|
||||
|
||||
|
@@ -20,7 +20,7 @@ class SphinxSearchEngineTest extends SearchEngineAbstractTest
|
||||
|
||||
$app = new Application('test');
|
||||
$appbox = $app['phraseanet.appbox'];
|
||||
self::$searchEngine = new SphinxSearchEngine($app, '127.0.0.1', 9306, '127.0.0.1', 9308);
|
||||
self::$searchEngine = new SphinxSearchEngine($app, '127.0.0.1', 19306, '127.0.0.1', 19308);
|
||||
|
||||
self::$config = tempnam(sys_get_temp_dir(), 'tmp_sphinx.conf');
|
||||
$configFile = self::$searchEngine->configurationPanel()->generateSphinxConf($appbox->get_databoxes(), self::$searchEngine->configurationPanel()->getConfiguration());
|
||||
@@ -38,7 +38,14 @@ class SphinxSearchEngineTest extends SearchEngineAbstractTest
|
||||
self::$searchd = new Process($searchd . ' -c ' . self::$config);
|
||||
self::$searchd->run();
|
||||
|
||||
self::$searchEngine = new SphinxSearchEngine($app, '127.0.0.1', 9306, '127.0.0.1', 9308);
|
||||
self::$searchEngine = new SphinxSearchEngine($app, '127.0.0.1', 19306, '127.0.0.1', 19308);
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
{
|
||||
self::$searchEngine->removeRecord(self::$DI['record_24']);
|
||||
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
public function initialize()
|
||||
|
Reference in New Issue
Block a user