mirror of
https://github.com/phpbb/phpbb.git
synced 2025-03-24 17:40:43 +01:00
Merge pull request #4675 from marc1706/ticket/15044
[ticket/15044] Create search index during installation
This commit is contained in:
commit
16e79d00d1
@ -29,6 +29,16 @@ services:
|
||||
tags:
|
||||
- { name: install_data_install, order: 30 }
|
||||
|
||||
installer.install_data.create_search_index:
|
||||
class: phpbb\install\module\install_data\task\create_search_index
|
||||
arguments:
|
||||
- '@config'
|
||||
- '@installer.helper.container_factory'
|
||||
- '%core.root_path%'
|
||||
- '%core.php_ext%'
|
||||
tags:
|
||||
- { name: install_data_install, order: 40 }
|
||||
|
||||
installer.module.data_install_collection:
|
||||
class: phpbb\di\ordered_service_collection
|
||||
arguments:
|
||||
|
@ -297,9 +297,10 @@ $lang = array_merge($lang, array(
|
||||
'TASK_CREATE_TABLES' => 'Creating tables',
|
||||
|
||||
// Install data
|
||||
'TASK_ADD_BOTS' => 'Registering bots',
|
||||
'TASK_ADD_LANGUAGES' => 'Installing available languages',
|
||||
'TASK_ADD_MODULES' => 'Installing modules',
|
||||
'TASK_ADD_BOTS' => 'Registering bots',
|
||||
'TASK_ADD_LANGUAGES' => 'Installing available languages',
|
||||
'TASK_ADD_MODULES' => 'Installing modules',
|
||||
'TASK_CREATE_SEARCH_INDEX' => 'Creating search index',
|
||||
|
||||
// Install finish tasks
|
||||
'TASK_INSTALL_EXTENSIONS' => 'Installing packaged extensions',
|
||||
|
@ -0,0 +1,134 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpbb\install\module\install_data\task;
|
||||
|
||||
use phpbb\auth\auth;
|
||||
use phpbb\db\driver\driver_interface;
|
||||
use phpbb\event\dispatcher;
|
||||
use phpbb\config\config;
|
||||
use phpbb\install\helper\container_factory;
|
||||
use phpbb\language\language;
|
||||
use phpbb\search\fulltext_native;
|
||||
use phpbb\user;
|
||||
|
||||
class create_search_index extends \phpbb\install\task_base
|
||||
{
|
||||
/**
|
||||
* @var auth
|
||||
*/
|
||||
protected $auth;
|
||||
|
||||
/**
|
||||
* @var config
|
||||
*/
|
||||
protected $config;
|
||||
|
||||
/**
|
||||
* @var driver_interface
|
||||
*/
|
||||
protected $db;
|
||||
|
||||
/**
|
||||
* @var dispatcher
|
||||
*/
|
||||
protected $phpbb_dispatcher;
|
||||
|
||||
/**
|
||||
* @var language
|
||||
*/
|
||||
protected $language;
|
||||
|
||||
/**
|
||||
* @var user
|
||||
*/
|
||||
protected $user;
|
||||
|
||||
/**
|
||||
* @var string phpBB root path
|
||||
*/
|
||||
protected $phpbb_root_path;
|
||||
|
||||
/**
|
||||
* @var string PHP file extension
|
||||
*/
|
||||
protected $php_ext;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param config $config phpBB config
|
||||
* @param container_factory $container Installer's DI container
|
||||
* @param string $phpbb_root_path phpBB root path
|
||||
* @param string $php_ext PHP file extension
|
||||
*/
|
||||
public function __construct(config $config, container_factory $container,
|
||||
$phpbb_root_path, $php_ext)
|
||||
{
|
||||
$this->auth = $container->get('auth');
|
||||
$this->config = $config;
|
||||
$this->db = $container->get('dbal.conn');
|
||||
$this->language = $container->get('language');
|
||||
$this->phpbb_dispatcher = $container->get('dispatcher');
|
||||
$this->user = $container->get('user');
|
||||
|
||||
parent::__construct(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
// Make sure fulltext native load update is set
|
||||
$this->config->set('fulltext_native_load_upd', 1);
|
||||
|
||||
$error = false;
|
||||
$search = new fulltext_native(
|
||||
$error,
|
||||
$this->phpbb_root_path,
|
||||
$this->php_ext,
|
||||
$this->auth,
|
||||
$this->config,
|
||||
$this->db,
|
||||
$this->user,
|
||||
$this->phpbb_dispatcher
|
||||
);
|
||||
|
||||
$sql = 'SELECT post_id, post_subject, post_text, poster_id, forum_id
|
||||
FROM ' . POSTS_TABLE;
|
||||
$result = $this->db->sql_query($sql);
|
||||
|
||||
while ($row = $this->db->sql_fetchrow($result))
|
||||
{
|
||||
$search->index('post', $row['post_id'], $row['post_text'], $row['post_subject'], $row['poster_id'], $row['forum_id']);
|
||||
}
|
||||
$this->db->sql_freeresult($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
static public function get_step_count()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function get_task_lang_name()
|
||||
{
|
||||
return 'TASK_CREATE_SEARCH_INDEX';
|
||||
}
|
||||
}
|
@ -120,7 +120,7 @@ class fulltext_native extends \phpbb\search\base
|
||||
$this->phpbb_dispatcher = $phpbb_dispatcher;
|
||||
$this->user = $user;
|
||||
|
||||
$this->word_length = array('min' => $this->config['fulltext_native_min_chars'], 'max' => $this->config['fulltext_native_max_chars']);
|
||||
$this->word_length = array('min' => (int) $this->config['fulltext_native_min_chars'], 'max' => (int) $this->config['fulltext_native_max_chars']);
|
||||
|
||||
/**
|
||||
* Load the UTF tools
|
||||
|
Loading…
x
Reference in New Issue
Block a user