mirror of
https://github.com/phpbb/phpbb.git
synced 2025-08-09 02:06:32 +02:00
[ticket/12683] Add progress bar to create_index
PHPBB3-12683
This commit is contained in:
@@ -1,15 +1,15 @@
|
||||
<?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.
|
||||
*
|
||||
*/
|
||||
*
|
||||
* 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\search\backend;
|
||||
|
||||
@@ -19,9 +19,9 @@ use phpbb\db\driver\driver_interface;
|
||||
use phpbb\user;
|
||||
|
||||
/**
|
||||
* optional base class for search plugins providing simple caching based on ACM
|
||||
* and functions to retrieve ignore_words and synonyms
|
||||
*/
|
||||
* optional base class for search plugins providing simple caching based on ACM
|
||||
* and functions to retrieve ignore_words and synonyms
|
||||
*/
|
||||
abstract class base implements search_backend_interface
|
||||
{
|
||||
public const SEARCH_RESULT_NOT_IN_CACHE = 0;
|
||||
@@ -348,8 +348,17 @@ abstract class base implements search_backend_interface
|
||||
$row_count++;
|
||||
$post_counter = $row['post_id'];
|
||||
}
|
||||
|
||||
// With cli process only one batch each time to be able to track progress
|
||||
if (PHP_SAPI === 'cli')
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: With cli if the previous bucle have stoped because of lack of time, launch an exception, because is an error
|
||||
// cli commands should be executed in one step
|
||||
|
||||
// pretend the number of posts was as big as the number of ids we indexed so far
|
||||
// just an estimation as it includes deleted posts
|
||||
$num_posts = $this->config['num_posts'];
|
||||
@@ -399,6 +408,12 @@ abstract class base implements search_backend_interface
|
||||
$this->index_remove($ids, $posters, $forum_ids);
|
||||
$post_counter = $ids[count($ids) - 1];
|
||||
}
|
||||
|
||||
// With cli process only one batch each time to be able to track progress
|
||||
if (PHP_SAPI === 'cli')
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($post_counter < $max_post_id)
|
||||
|
@@ -0,0 +1,19 @@
|
||||
<?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\search\exception;
|
||||
|
||||
class no_search_backend_found_exception extends search_exception
|
||||
{
|
||||
|
||||
}
|
21
phpBB/phpbb/search/exception/search_exception.php
Normal file
21
phpBB/phpbb/search/exception/search_exception.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?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\search\exception;
|
||||
|
||||
use phpbb\exception\runtime_exception;
|
||||
|
||||
class search_exception extends runtime_exception
|
||||
{
|
||||
// TODO: Launch this exception from search instead of RuntimeException
|
||||
}
|
@@ -16,6 +16,8 @@ namespace phpbb\search;
|
||||
use phpbb\config\config;
|
||||
use phpbb\di\service_collection;
|
||||
use phpbb\search\backend\search_backend_interface;
|
||||
use phpbb\search\exception\no_search_backend_found_exception;
|
||||
use RuntimeException;
|
||||
|
||||
class search_backend_factory
|
||||
{
|
||||
@@ -46,16 +48,36 @@ class search_backend_factory
|
||||
*
|
||||
* @param string $class
|
||||
*
|
||||
* @throws no_search_backend_found_exception
|
||||
*
|
||||
* @return search_backend_interface
|
||||
*/
|
||||
public function get(string $class): search_backend_interface
|
||||
{
|
||||
return $this->search_backends->get_by_class($class);
|
||||
try
|
||||
{
|
||||
$search = $this->search_backends->get_by_class($class);
|
||||
}
|
||||
catch (RuntimeException $e)
|
||||
{
|
||||
if (strpos($e->getMessage(), 'No service found') === 0)
|
||||
{
|
||||
throw new no_search_backend_found_exception();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
return $search;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtains active search backend
|
||||
*
|
||||
* @throws no_search_backend_found_exception
|
||||
*
|
||||
* @return search_backend_interface
|
||||
*/
|
||||
public function get_active(): search_backend_interface
|
||||
|
Reference in New Issue
Block a user