[ticket/14445] Force refresh before schema generation

PHPBB3-14445
This commit is contained in:
Mate Bartus 2016-02-02 17:16:15 +01:00
parent 63fd2159e0
commit 8f4889da58
2 changed files with 16 additions and 3 deletions

View file

@ -157,10 +157,10 @@ class config
{ {
if ($this->system_data['max_execution_time'] <= 0) if ($this->system_data['max_execution_time'] <= 0)
{ {
return 1; return PHP_INT_MAX;
} }
return ($this->system_data['start_time'] + $this->system_data['max_execution_time']) - time(); return ($this->system_data['start_time'] + $this->system_data['max_execution_time']) - microtime(true);
} }
/** /**
@ -430,7 +430,7 @@ class config
$this->system_data['max_execution_time'] = $execution_time; $this->system_data['max_execution_time'] = $execution_time;
// Set start time // Set start time
$this->system_data['start_time'] = time(); $this->system_data['start_time'] = microtime(true);
// Get memory limit // Get memory limit
$this->system_data['memory_limit'] = $this->php_ini->getBytes('memory_limit'); $this->system_data['memory_limit'] = $this->php_ini->getBytes('memory_limit');

View file

@ -13,6 +13,8 @@
namespace phpbb\install\module\install_database\task; namespace phpbb\install\module\install_database\task;
use phpbb\install\exception\resource_limit_reached_exception;
/** /**
* Create database schema * Create database schema
*/ */
@ -106,6 +108,17 @@ class create_schema extends \phpbb\install\task_base
*/ */
public function run() public function run()
{ {
// As this task may take a large amount of time to complete refreshing the page might be necessary for some
// server configurations with limited resources
if (!$this->config->get('pre_schema_forced_refresh'))
{
if ($this->config->get_time_remaining() < 5)
{
$this->config->set('pre_schema_forced_refresh', true);
throw new resource_limit_reached_exception();
}
}
$this->db->sql_return_on_error(true); $this->db->sql_return_on_error(true);
$dbms = $this->config->get('dbms'); $dbms = $this->config->get('dbms');