1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-03-14 04:30:29 +01:00

Merge branch '3.2.x'

This commit is contained in:
Marc Alexander 2016-11-17 09:56:59 +01:00
commit 82960414f7
28 changed files with 11 additions and 730 deletions

View File

@ -71,11 +71,3 @@ services:
- '%core.root_path%'
- '@request'
- '@dbal.conn.driver'
dbal.extractor.extractors.sqlite_extractor:
class: phpbb\db\extractor\sqlite_extractor
shared: false
arguments:
- '%core.root_path%'
- '@request'
- '@dbal.conn.driver'

View File

@ -379,7 +379,6 @@ function mass_auth($ug_type, $forum_id, $ug_id, $acl_list, $setting)
$sql = 'VALUES ' . implode(', ', preg_replace('#^(.*?)$#', '(\1)', $sql_subary));
break;
case 'sqlite':
case 'sqlite3':
$sql = implode(' UNION ALL ', preg_replace('#^(.*?)$#', 'SELECT \1', $sql_subary));
break;

View File

@ -49,7 +49,7 @@ $classes = $finder->core_path('phpbb/')
->directory('/db/migration/data')
->get_classes();
$db = new \phpbb\db\driver\sqlite();
$db = new \phpbb\db\driver\sqlite3();
$factory = new \phpbb\db\tools\factory();
$db_tools = $factory->get($db, true);

View File

@ -142,7 +142,6 @@
<li>MySQL 3.23 or above (MySQLi supported)</li>
<li>MariaDB 5.1 or above</li>
<li>PostgreSQL 8.3+</li>
<li>SQLite 2.8.2+</li>
<li>SQLite 3.6.15+</li>
<li>MS SQL Server 2000 or above (via ODBC or the native adapter)</li>
<li>Oracle</li>

View File

@ -327,7 +327,7 @@
<p>Please remember that running any application on a development (unstable, e.g. a beta release) version of PHP can lead to strange/unexpected results which may appear to be bugs in the application. Therefore, we recommend you upgrade to the newest stable version of PHP before running phpBB. If you are running a development version of PHP please check any bugs you find on a system running a stable release before submitting.</p>
<p>This board has been developed and tested under Linux and Windows (amongst others) running Apache using MySQL 3.23, 4.x, 5.x, MariaDB 5.x, PostgreSQL 8.x, Oracle 8, SQLite 2 and SQLite 3. Versions of PHP used range from 5.4.x above 5.6.x to 7.0.x without problem.</p>
<p>This board has been developed and tested under Linux and Windows (amongst others) running Apache using MySQL 3.23, 4.x, 5.x, MariaDB 5.x, PostgreSQL 8.x, Oracle 8 and SQLite 3. Versions of PHP used range from 5.4.x above 5.6.x to 7.0.x without problem.</p>
<a name="phpsec"></a><h3>7.i. Notice on PHP security issues</h3>

View File

@ -115,7 +115,6 @@ class acp_database
// We might wanna empty out all that junk :D
switch ($db->get_sql_layer())
{
case 'sqlite':
case 'sqlite3':
$extractor->flush('DELETE FROM ' . $table_name . ";\n");
break;
@ -304,7 +303,6 @@ class acp_database
case 'mysql':
case 'mysql4':
case 'mysqli':
case 'sqlite':
case 'sqlite3':
while (($sql = $fgetd($fp, ";\n", $read, $seek, $eof)) !== false)
{

View File

@ -563,7 +563,6 @@ class acp_icons
{
switch ($db->get_sql_layer())
{
case 'sqlite':
case 'sqlite3':
$db->sql_query('DELETE FROM ' . $table);
break;

View File

@ -275,7 +275,6 @@ class acp_main
case 'db_track':
switch ($db->get_sql_layer())
{
case 'sqlite':
case 'sqlite3':
$db->sql_query('DELETE FROM ' . TOPICS_POSTED_TABLE);
break;
@ -386,7 +385,6 @@ class acp_main
{
switch ($db->get_sql_layer())
{
case 'sqlite':
case 'sqlite3':
$db->sql_query("DELETE FROM $table");
break;

View File

@ -250,7 +250,6 @@ class acp_reasons
// Teh standard
case 'postgres':
case 'oracle':
case 'sqlite':
case 'sqlite3':
// Change the reports using this reason to 'other'
$sql = 'UPDATE ' . REPORTS_TABLE . '

View File

@ -3510,7 +3510,7 @@ function obtain_guest_count($item_id = 0, $item = 'forum')
// Get number of online guests
if ($db->get_sql_layer() === 'sqlite' || $db->get_sql_layer() === 'sqlite3')
if ($db->get_sql_layer() === 'sqlite3')
{
$sql = 'SELECT COUNT(session_ip) as num_guests
FROM (

View File

@ -2364,7 +2364,6 @@ function phpbb_cache_moderators($db, $cache, $auth)
// Clear table
switch ($db->get_sql_layer())
{
case 'sqlite':
case 'sqlite3':
$db->sql_query('DELETE FROM ' . MODERATOR_CACHE_TABLE);
break;
@ -2822,7 +2821,6 @@ function get_database_size()
}
break;
case 'sqlite':
case 'sqlite3':
global $dbhost;

View File

@ -1652,7 +1652,6 @@ function mass_auth($ug_type, $forum_id, $ug_id, $acl_list, $setting = ACL_NO)
$sql = 'VALUES ' . implode(', ', preg_replace('#^(.*?)$#', '(\1)', $sql_subary));
break;
case 'sqlite':
case 'sqlite3':
case 'mssqlnative':
$sql = implode(' UNION ALL ', preg_replace('#^(.*?)$#', 'SELECT \1', $sql_subary));
@ -2040,7 +2039,6 @@ function update_topics_posted()
switch ($db->get_sql_layer())
{
case 'sqlite':
case 'sqlite3':
$db->sql_query('DELETE FROM ' . TOPICS_POSTED_TABLE);
break;

View File

@ -410,7 +410,6 @@ class convertor
switch ($this->db->get_sql_layer())
{
case 'sqlite':
case 'sqlite3':
$this->db->sql_query('DELETE FROM ' . $this->session_keys_table);
$this->db->sql_query('DELETE FROM ' . $this->session_table);

View File

@ -144,7 +144,6 @@ class convertor
$convert->mysql_convert = false;
switch ($src_db->sql_layer)
{
case 'sqlite':
case 'sqlite3':
$convert->src_truncate_statement = 'DELETE FROM ';
break;
@ -176,7 +175,6 @@ class convertor
switch ($db->get_sql_layer())
{
case 'sqlite':
case 'sqlite3':
$convert->truncate_statement = 'DELETE FROM ';
break;

View File

@ -1827,7 +1827,6 @@ function phpbb_create_userconv_table()
)';
break;
case 'sqlite':
case 'sqlite3':
$create_sql = 'CREATE TABLE ' . USERCONV_TABLE . ' (
user_id INTEGER NOT NULL DEFAULT \'0\',

View File

@ -72,7 +72,6 @@ $lang = array_merge($lang, array(
<ul>
<li>MySQL 3.23 or above (MySQLi supported)</li>
<li>PostgreSQL 8.3+</li>
<li>SQLite 2.8.2+</li>
<li>SQLite 3.6.15+</li>
<li>MS SQL Server 2000 or above (directly or via ODBC)</li>
<li>MS SQL Server 2005 or above (native)</li>
@ -191,7 +190,6 @@ $lang = array_merge($lang, array(
'DB_OPTION_MYSQLI' => 'MySQL with MySQLi Extension',
'DB_OPTION_ORACLE' => 'Oracle',
'DB_OPTION_POSTGRES' => 'PostgreSQL',
'DB_OPTION_SQLITE' => 'SQLite 2',
'DB_OPTION_SQLITE3' => 'SQLite 3',
// Errors
@ -204,7 +202,6 @@ $lang = array_merge($lang, array(
'INST_ERR_DB_NO_ERROR' => 'No error message given.',
'INST_ERR_PREFIX' => 'Tables with the specified prefix already exist, please choose an alternative.',
'INST_ERR_DB_NO_MYSQLI' => 'The version of MySQL installed on this machine is incompatible with the “MySQL with MySQLi Extension” option you have selected. Please try the “MySQL” option instead.',
'INST_ERR_DB_NO_SQLITE' => 'The version of the SQLite extension you have installed is too old, it must be upgraded to at least 2.8.2.',
'INST_ERR_DB_NO_SQLITE3' => 'The version of the SQLite extension you have installed is too old, it must be upgraded to at least 3.6.15.',
'INST_ERR_DB_NO_ORACLE' => 'The version of Oracle installed on this machine requires you to set the <var>NLS_CHARACTERSET</var> parameter to <var>UTF8</var>. Either upgrade your installation to 9.2+ or change the parameter.',
'INST_ERR_DB_NO_POSTGRES' => 'The database you have selected was not created in <var>UNICODE</var> or <var>UTF8</var> encoding. Try installing with a database in <var>UNICODE</var> or <var>UTF8</var> encoding.',

View File

@ -1,384 +0,0 @@
<?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\db\driver;
/**
* Sqlite Database Abstraction Layer
* Minimum Requirement: 2.8.2+
*/
class sqlite extends \phpbb\db\driver\driver
{
var $connect_error = '';
/**
* {@inheritDoc}
*/
function sql_connect($sqlserver, $sqluser, $sqlpassword, $database, $port = false, $persistency = false, $new_link = false)
{
$this->persistency = $persistency;
$this->user = $sqluser;
$this->server = $sqlserver . (($port) ? ':' . $port : '');
$this->dbname = $database;
$error = '';
if ($this->persistency)
{
if (!function_exists('sqlite_popen'))
{
$this->connect_error = 'sqlite_popen function does not exist, is sqlite extension installed?';
return $this->sql_error('');
}
$this->db_connect_id = @sqlite_popen($this->server, 0666, $error);
}
else
{
if (!function_exists('sqlite_open'))
{
$this->connect_error = 'sqlite_open function does not exist, is sqlite extension installed?';
return $this->sql_error('');
}
$this->db_connect_id = @sqlite_open($this->server, 0666, $error);
}
if ($this->db_connect_id)
{
@sqlite_query('PRAGMA short_column_names = 1', $this->db_connect_id);
// @sqlite_query('PRAGMA encoding = "UTF-8"', $this->db_connect_id);
}
return ($this->db_connect_id) ? true : array('message' => $error);
}
/**
* {@inheritDoc}
*/
function sql_server_info($raw = false, $use_cache = true)
{
global $cache;
if (!$use_cache || empty($cache) || ($this->sql_server_version = $cache->get('sqlite_version')) === false)
{
$result = @sqlite_query('SELECT sqlite_version() AS version', $this->db_connect_id);
if ($result)
{
$row = sqlite_fetch_array($result, SQLITE_ASSOC);
$this->sql_server_version = (!empty($row['version'])) ? $row['version'] : 0;
if (!empty($cache) && $use_cache)
{
$cache->put('sqlite_version', $this->sql_server_version);
}
}
}
return ($raw) ? $this->sql_server_version : 'SQLite ' . $this->sql_server_version;
}
/**
* SQL Transaction
* @access private
*/
function _sql_transaction($status = 'begin')
{
switch ($status)
{
case 'begin':
return @sqlite_query('BEGIN', $this->db_connect_id);
break;
case 'commit':
return @sqlite_query('COMMIT', $this->db_connect_id);
break;
case 'rollback':
return @sqlite_query('ROLLBACK', $this->db_connect_id);
break;
}
return true;
}
/**
* {@inheritDoc}
*/
function sql_query($query = '', $cache_ttl = 0)
{
if ($query != '')
{
global $cache;
// EXPLAIN only in extra debug mode
if (defined('DEBUG'))
{
$this->sql_report('start', $query);
}
else if (defined('PHPBB_DISPLAY_LOAD_TIME'))
{
$this->curtime = microtime(true);
}
$this->query_result = ($cache && $cache_ttl) ? $cache->sql_load($query) : false;
$this->sql_add_num_queries($this->query_result);
if ($this->query_result === false)
{
if (($this->query_result = @sqlite_query($query, $this->db_connect_id)) === false)
{
$this->sql_error($query);
}
if (defined('DEBUG'))
{
$this->sql_report('stop', $query);
}
else if (defined('PHPBB_DISPLAY_LOAD_TIME'))
{
$this->sql_time += microtime(true) - $this->curtime;
}
if (!$this->query_result)
{
return false;
}
if ($cache && $cache_ttl)
{
$this->query_result = $cache->sql_save($this, $query, $this->query_result, $cache_ttl);
}
}
else if (defined('DEBUG'))
{
$this->sql_report('fromcache', $query);
}
}
else
{
return false;
}
return $this->query_result;
}
/**
* Build LIMIT query
*/
function _sql_query_limit($query, $total, $offset = 0, $cache_ttl = 0)
{
$this->query_result = false;
// if $total is set to 0 we do not want to limit the number of rows
if ($total == 0)
{
$total = -1;
}
$query .= "\n LIMIT " . ((!empty($offset)) ? $offset . ', ' . $total : $total);
return $this->sql_query($query, $cache_ttl);
}
/**
* {@inheritDoc}
*/
function sql_affectedrows()
{
return ($this->db_connect_id) ? @sqlite_changes($this->db_connect_id) : false;
}
/**
* {@inheritDoc}
*/
function sql_fetchrow($query_id = false)
{
global $cache;
if ($query_id === false)
{
$query_id = $this->query_result;
}
if ($cache && $cache->sql_exists($query_id))
{
return $cache->sql_fetchrow($query_id);
}
return ($query_id) ? sqlite_fetch_array($query_id, SQLITE_ASSOC) : false;
}
/**
* {@inheritDoc}
*/
function sql_rowseek($rownum, &$query_id)
{
global $cache;
if ($query_id === false)
{
$query_id = $this->query_result;
}
if ($cache && $cache->sql_exists($query_id))
{
return $cache->sql_rowseek($rownum, $query_id);
}
return ($query_id) ? @sqlite_seek($query_id, $rownum) : false;
}
/**
* {@inheritDoc}
*/
function sql_nextid()
{
return ($this->db_connect_id) ? @sqlite_last_insert_rowid($this->db_connect_id) : false;
}
/**
* {@inheritDoc}
*/
function sql_freeresult($query_id = false)
{
global $cache;
if ($query_id === false)
{
$query_id = $this->query_result;
}
if ($cache && !is_object($query_id) && $cache->sql_exists($query_id))
{
return $cache->sql_freeresult($query_id);
}
return true;
}
/**
* {@inheritDoc}
*/
function sql_escape($msg)
{
return @sqlite_escape_string($msg);
}
/**
* {@inheritDoc}
*
* For SQLite an underscore is a not-known character... this may change with SQLite3
*/
function sql_like_expression($expression)
{
// Unlike LIKE, GLOB is unfortunately case sensitive.
// We only catch * and ? here, not the character map possible on file globbing.
$expression = str_replace(array(chr(0) . '_', chr(0) . '%'), array(chr(0) . '?', chr(0) . '*'), $expression);
$expression = str_replace(array('?', '*'), array("\?", "\*"), $expression);
$expression = str_replace(array(chr(0) . "\?", chr(0) . "\*"), array('?', '*'), $expression);
return 'GLOB \'' . $this->sql_escape($expression) . '\'';
}
/**
* {@inheritDoc}
*
* For SQLite an underscore is a not-known character...
*/
function sql_not_like_expression($expression)
{
// Unlike NOT LIKE, NOT GLOB is unfortunately case sensitive.
// We only catch * and ? here, not the character map possible on file globbing.
$expression = str_replace(array(chr(0) . '_', chr(0) . '%'), array(chr(0) . '?', chr(0) . '*'), $expression);
$expression = str_replace(array('?', '*'), array("\?", "\*"), $expression);
$expression = str_replace(array(chr(0) . "\?", chr(0) . "\*"), array('?', '*'), $expression);
return 'NOT GLOB \'' . $this->sql_escape($expression) . '\'';
}
/**
* return sql error array
* @access private
*/
function _sql_error()
{
if (function_exists('sqlite_error_string'))
{
$error = array(
'message' => @sqlite_error_string(@sqlite_last_error($this->db_connect_id)),
'code' => @sqlite_last_error($this->db_connect_id),
);
}
else
{
$error = array(
'message' => $this->connect_error,
'code' => '',
);
}
return $error;
}
/**
* Build db-specific query data
* @access private
*/
function _sql_custom_build($stage, $data)
{
return $data;
}
/**
* Close sql connection
* @access private
*/
function _sql_close()
{
return @sqlite_close($this->db_connect_id);
}
/**
* Build db-specific report
* @access private
*/
function _sql_report($mode, $query = '')
{
switch ($mode)
{
case 'start':
break;
case 'fromcache':
$endtime = explode(' ', microtime());
$endtime = $endtime[0] + $endtime[1];
$result = @sqlite_query($query, $this->db_connect_id);
if ($result)
{
while ($void = sqlite_fetch_array($result, SQLITE_ASSOC))
{
// Take the time spent on parsing rows into account
}
}
$splittime = explode(' ', microtime());
$splittime = $splittime[0] + $splittime[1];
$this->sql_report('record_fromcache', $query, $endtime, $splittime);
break;
}
}
}

View File

@ -65,10 +65,6 @@ class factory
{
return $this->container->get('dbal.extractor.extractors.postgres_extractor');
}
else if ($this->db instanceof \phpbb\db\driver\sqlite)
{
return $this->container->get('dbal.extractor.extractors.sqlite_extractor');
}
else if ($this->db instanceof \phpbb\db\driver\sqlite3)
{
return $this->container->get('dbal.extractor.extractors.sqlite3_extractor');

View File

@ -1,149 +0,0 @@
<?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\db\extractor;
use phpbb\db\extractor\exception\extractor_not_initialized_exception;
class sqlite_extractor extends base_extractor
{
/**
* {@inheritdoc}
*/
public function write_start($table_prefix)
{
if (!$this->is_initialized)
{
throw new extractor_not_initialized_exception();
}
$sql_data = "--\n";
$sql_data .= "-- phpBB Backup Script\n";
$sql_data .= "-- Dump of tables for $table_prefix\n";
$sql_data .= "-- DATE : " . gmdate("d-m-Y H:i:s", $this->time) . " GMT\n";
$sql_data .= "--\n";
$sql_data .= "BEGIN TRANSACTION;\n";
$this->flush($sql_data);
}
/**
* {@inheritdoc}
*/
public function write_table($table_name)
{
if (!$this->is_initialized)
{
throw new extractor_not_initialized_exception();
}
$sql_data = '-- Table: ' . $table_name . "\n";
$sql_data .= "DROP TABLE $table_name;\n";
$sql = "SELECT sql
FROM sqlite_master
WHERE type = 'table'
AND name = '" . $this->db->sql_escape($table_name) . "'
ORDER BY type DESC, name;";
$result = $this->db->sql_query($sql);
$row = $this->db->sql_fetchrow($result);
$this->db->sql_freeresult($result);
// Create Table
$sql_data .= $row['sql'] . ";\n";
$result = $this->db->sql_query("PRAGMA index_list('" . $this->db->sql_escape($table_name) . "');");
$ar = array();
while ($row = $this->db->sql_fetchrow($result))
{
$ar[] = $row;
}
$this->db->sql_freeresult($result);
foreach ($ar as $value)
{
if (strpos($value['name'], 'autoindex') !== false)
{
continue;
}
$result = $this->db->sql_query("PRAGMA index_info('" . $this->db->sql_escape($value['name']) . "');");
$fields = array();
while ($row = $this->db->sql_fetchrow($result))
{
$fields[] = $row['name'];
}
$this->db->sql_freeresult($result);
$sql_data .= 'CREATE ' . ($value['unique'] ? 'UNIQUE ' : '') . 'INDEX ' . $value['name'] . ' on ' . $table_name . ' (' . implode(', ', $fields) . ");\n";
}
$this->flush($sql_data . "\n");
}
/**
* {@inheritdoc}
*/
public function write_data($table_name)
{
if (!$this->is_initialized)
{
throw new extractor_not_initialized_exception();
}
$col_types = sqlite_fetch_column_types($this->db->get_db_connect_id(), $table_name);
$sql = "SELECT *
FROM $table_name";
$result = sqlite_unbuffered_query($this->db->get_db_connect_id(), $sql);
$rows = sqlite_fetch_all($result, SQLITE_ASSOC);
$sql_insert = 'INSERT INTO ' . $table_name . ' (' . implode(', ', array_keys($col_types)) . ') VALUES (';
foreach ($rows as $row)
{
foreach ($row as $column_name => $column_data)
{
if (is_null($column_data))
{
$row[$column_name] = 'NULL';
}
else if ($column_data == '')
{
$row[$column_name] = "''";
}
else if (strpos($col_types[$column_name], 'text') !== false || strpos($col_types[$column_name], 'char') !== false || strpos($col_types[$column_name], 'blob') !== false)
{
$row[$column_name] = sanitize_data_generic(str_replace("'", "''", $column_data));
}
}
$this->flush($sql_insert . implode(', ', $row) . ");\n");
}
}
/**
* Writes closing line(s) to database backup
*
* @return null
* @throws \phpbb\db\extractor\exception\extractor_not_initialized_exception when calling this function before init_extractor()
*/
public function write_end()
{
if (!$this->is_initialized)
{
throw new extractor_not_initialized_exception();
}
$this->flush("COMMIT;\n");
parent::write_end();
}
}

View File

@ -136,37 +136,6 @@ class tools implements tools_interface
'VARBINARY' => 'raw(255)',
),
'sqlite' => array(
'INT:' => 'int(%d)',
'BINT' => 'bigint(20)',
'ULINT' => 'INTEGER UNSIGNED', // 'int(10) UNSIGNED',
'UINT' => 'INTEGER UNSIGNED', // 'mediumint(8) UNSIGNED',
'UINT:' => 'INTEGER UNSIGNED', // 'int(%d) UNSIGNED',
'TINT:' => 'tinyint(%d)',
'USINT' => 'INTEGER UNSIGNED', // 'mediumint(4) UNSIGNED',
'BOOL' => 'INTEGER UNSIGNED', // 'tinyint(1) UNSIGNED',
'VCHAR' => 'varchar(255)',
'VCHAR:' => 'varchar(%d)',
'CHAR:' => 'char(%d)',
'XSTEXT' => 'text(65535)',
'STEXT' => 'text(65535)',
'TEXT' => 'text(65535)',
'MTEXT' => 'mediumtext(16777215)',
'XSTEXT_UNI'=> 'text(65535)',
'STEXT_UNI' => 'text(65535)',
'TEXT_UNI' => 'text(65535)',
'MTEXT_UNI' => 'mediumtext(16777215)',
'TIMESTAMP' => 'INTEGER UNSIGNED', // 'int(11) UNSIGNED',
'DECIMAL' => 'decimal(5,2)',
'DECIMAL:' => 'decimal(%d,2)',
'PDECIMAL' => 'decimal(6,3)',
'PDECIMAL:' => 'decimal(%d,3)',
'VCHAR_UNI' => 'varchar(255)',
'VCHAR_UNI:'=> 'varchar(%d)',
'VCHAR_CI' => 'varchar(255)',
'VARBINARY' => 'blob',
),
'sqlite3' => array(
'INT:' => 'INT(%d)',
'BINT' => 'BIGINT(20)',
@ -277,12 +246,6 @@ class tools implements tools_interface
$sql = 'SHOW TABLES';
break;
case 'sqlite':
$sql = 'SELECT name
FROM sqlite_master
WHERE type = "table"';
break;
case 'sqlite3':
$sql = 'SELECT name
FROM sqlite_master
@ -398,7 +361,6 @@ class tools implements tools_interface
{
case 'mysql_40':
case 'mysql_41':
case 'sqlite':
case 'sqlite3':
$table_sql .= ",\n\t PRIMARY KEY (" . implode(', ', $table_data['PRIMARY_KEY']) . ')';
break;
@ -420,7 +382,6 @@ class tools implements tools_interface
break;
case 'mysql_40':
case 'sqlite':
case 'sqlite3':
$table_sql .= "\n);";
$statements[] = $table_sql;
@ -497,7 +458,7 @@ class tools implements tools_interface
$sqlite = false;
// For SQLite we need to perform the schema changes in a much more different way
if (($this->db->get_sql_layer() == 'sqlite' || $this->db->get_sql_layer() == 'sqlite3') && $this->return_statements)
if ($this->db->get_sql_layer() == 'sqlite3' && $this->return_statements)
{
$sqlite_data = array();
$sqlite = true;
@ -884,7 +845,6 @@ class tools implements tools_interface
WHERE LOWER(table_name) = '" . strtolower($table_name) . "'";
break;
case 'sqlite':
case 'sqlite3':
$sql = "SELECT sql
FROM sqlite_master
@ -967,7 +927,6 @@ class tools implements tools_interface
$col = 'index_name';
break;
case 'sqlite':
case 'sqlite3':
$sql = "PRAGMA index_list('" . $table_name . "');";
$col = 'name';
@ -986,7 +945,6 @@ class tools implements tools_interface
switch ($this->sql_layer)
{
case 'oracle':
case 'sqlite':
case 'sqlite3':
$row[$col] = substr($row[$col], strlen($table_name) + 1);
break;
@ -1026,7 +984,6 @@ class tools implements tools_interface
$col = 'index_name';
break;
case 'sqlite':
case 'sqlite3':
$sql = "PRAGMA index_list('" . $table_name . "');";
$col = 'name';
@ -1041,7 +998,7 @@ class tools implements tools_interface
continue;
}
if (($this->sql_layer == 'sqlite' || $this->sql_layer == 'sqlite3') && !$row['unique'])
if ($this->sql_layer == 'sqlite3' && !$row['unique'])
{
continue;
}
@ -1061,7 +1018,6 @@ class tools implements tools_interface
}
break;
case 'sqlite':
case 'sqlite3':
$row[$col] = substr($row[$col], strlen($table_name) + 1);
break;
@ -1193,18 +1149,12 @@ class tools implements tools_interface
break;
case 'sqlite':
case 'sqlite3':
$return_array['primary_key_set'] = false;
if (isset($column_data[2]) && $column_data[2] == 'auto_increment')
{
$sql .= ' INTEGER PRIMARY KEY';
$sql .= ' INTEGER PRIMARY KEY AUTOINCREMENT';
$return_array['primary_key_set'] = true;
if ($this->sql_layer === 'sqlite3')
{
$sql .= ' AUTOINCREMENT';
}
}
else
{
@ -1306,57 +1256,6 @@ class tools implements tools_interface
$statements[] = 'ALTER TABLE ' . $table_name . ' ADD ' . $column_name . ' ' . $column_data['column_type_sql'];
break;
case 'sqlite':
if ($inline && $this->return_statements)
{
return $column_name . ' ' . $column_data['column_type_sql'];
}
$recreate_queries = $this->sqlite_get_recreate_table_queries($table_name);
if (empty($recreate_queries))
{
break;
}
$statements[] = 'begin';
$sql_create_table = array_shift($recreate_queries);
// Create a backup table and populate it, destroy the existing one
$statements[] = preg_replace('#CREATE\s+TABLE\s+"?' . $table_name . '"?#i', 'CREATE TEMPORARY TABLE ' . $table_name . '_temp', $sql_create_table);
$statements[] = 'INSERT INTO ' . $table_name . '_temp SELECT * FROM ' . $table_name;
$statements[] = 'DROP TABLE ' . $table_name;
preg_match('#\((.*)\)#s', $sql_create_table, $matches);
$new_table_cols = trim($matches[1]);
$old_table_cols = preg_split('/,(?![\s\w]+\))/m', $new_table_cols);
$column_list = array();
foreach ($old_table_cols as $declaration)
{
$entities = preg_split('#\s+#', trim($declaration));
if ($entities[0] == 'PRIMARY')
{
continue;
}
$column_list[] = $entities[0];
}
$columns = implode(',', $column_list);
$new_table_cols = $column_name . ' ' . $column_data['column_type_sql'] . ',' . $new_table_cols;
// create a new table and fill it up. destroy the temp one
$statements[] = 'CREATE TABLE ' . $table_name . ' (' . $new_table_cols . ');';
$statements = array_merge($statements, $recreate_queries);
$statements[] = 'INSERT INTO ' . $table_name . ' (' . $columns . ') SELECT ' . $columns . ' FROM ' . $table_name . '_temp;';
$statements[] = 'DROP TABLE ' . $table_name . '_temp';
$statements[] = 'commit';
break;
case 'sqlite3':
if ($inline && $this->return_statements)
{
@ -1388,7 +1287,6 @@ class tools implements tools_interface
$statements[] = 'ALTER TABLE ' . $table_name . ' DROP COLUMN ' . $column_name;
break;
case 'sqlite':
case 'sqlite3':
if ($inline && $this->return_statements)
@ -1465,7 +1363,6 @@ class tools implements tools_interface
break;
case 'oracle':
case 'sqlite':
case 'sqlite3':
$statements[] = 'DROP INDEX ' . $table_name . '_' . $index_name;
break;
@ -1529,7 +1426,6 @@ class tools implements tools_interface
$statements[] = 'ALTER TABLE ' . $table_name . ' add CONSTRAINT pk_' . $table_name . ' PRIMARY KEY (' . implode(', ', $column) . ')';
break;
case 'sqlite':
case 'sqlite3':
if ($inline && $this->return_statements)
@ -1596,7 +1492,6 @@ class tools implements tools_interface
switch ($this->sql_layer)
{
case 'oracle':
case 'sqlite':
case 'sqlite3':
$statements[] = 'CREATE UNIQUE INDEX ' . $table_name . '_' . $index_name . ' ON ' . $table_name . '(' . implode(', ', $column) . ')';
break;
@ -1628,7 +1523,6 @@ class tools implements tools_interface
switch ($this->sql_layer)
{
case 'oracle':
case 'sqlite':
case 'sqlite3':
$statements[] = 'CREATE INDEX ' . $table_name . '_' . $index_name . ' ON ' . $table_name . '(' . implode(', ', $column) . ')';
break;
@ -1693,7 +1587,6 @@ class tools implements tools_interface
$col = 'index_name';
break;
case 'sqlite':
case 'sqlite3':
$sql = "PRAGMA index_info('" . $table_name . "');";
$col = 'name';
@ -1711,7 +1604,6 @@ class tools implements tools_interface
switch ($this->sql_layer)
{
case 'oracle':
case 'sqlite':
case 'sqlite3':
$row[$col] = substr($row[$col], strlen($table_name) + 1);
break;
@ -1818,7 +1710,6 @@ class tools implements tools_interface
$this->return_statements = $old_return_statements;
break;
case 'sqlite':
case 'sqlite3':
if ($inline && $this->return_statements)
@ -1899,7 +1790,6 @@ class tools implements tools_interface
{
case 'mysql_40':
case 'mysql_41':
case 'sqlite':
case 'sqlite3':
// Not supported
throw new \Exception('DBMS is not supported');

View File

@ -90,15 +90,6 @@ class database
'AVAILABLE' => true,
'2.0.x' => true,
),
'sqlite' => array(
'LABEL' => 'SQLite',
'SCHEMA' => 'sqlite',
'MODULE' => 'sqlite',
'DELIM' => ';',
'DRIVER' => 'phpbb\db\driver\sqlite',
'AVAILABLE' => true,
'2.0.x' => false,
),
'sqlite3' => array(
'LABEL' => 'SQLite3',
'SCHEMA' => 'sqlite',
@ -390,14 +381,6 @@ class database
);
}
break;
case 'sqlite':
if (version_compare($db->sql_server_info(true), '2.8.2', '<'))
{
$errors[] = array(
'title' => 'INST_ERR_DB_NO_SQLITE',
);
}
break;
case 'sqlite3':
if (version_compare($db->sql_server_info(true), '3.6.15', '<'))
{

View File

@ -878,7 +878,6 @@ class fulltext_native extends \phpbb\search\base
break;
case 'sqlite':
case 'sqlite3':
$sql_array_count['SELECT'] = ($type == 'posts') ? 'DISTINCT p.post_id' : 'DISTINCT p.topic_id';
$sql = 'SELECT COUNT(' . (($type == 'posts') ? 'post_id' : 'topic_id') . ') as total_results
@ -1185,7 +1184,7 @@ class fulltext_native extends \phpbb\search\base
}
else
{
if ($this->db->get_sql_layer() == 'sqlite' || $this->db->get_sql_layer() == 'sqlite3')
if ($this->db->get_sql_layer() == 'sqlite3')
{
$sql = 'SELECT COUNT(topic_id) as total_results
FROM (SELECT DISTINCT t.topic_id';
@ -1202,7 +1201,7 @@ class fulltext_native extends \phpbb\search\base
$post_visibility
$sql_fora
AND t.topic_id = p.topic_id
$sql_time" . (($this->db->get_sql_layer() == 'sqlite' || $this->db->get_sql_layer() == 'sqlite3') ? ')' : '');
$sql_time" . ($this->db->get_sql_layer() == 'sqlite3' ? ')' : '');
}
$result = $this->db->sql_query($sql);
@ -1667,7 +1666,6 @@ class fulltext_native extends \phpbb\search\base
{
switch ($this->db->get_sql_layer())
{
case 'sqlite':
case 'sqlite3':
$this->db->sql_query('DELETE FROM ' . SEARCH_WORDLIST_TABLE);
$this->db->sql_query('DELETE FROM ' . SEARCH_WORDMATCH_TABLE);

View File

@ -127,7 +127,6 @@ if (!$show_guests)
{
switch ($db->get_sql_layer())
{
case 'sqlite':
case 'sqlite3':
$sql = 'SELECT COUNT(session_ip) as num_guests
FROM (

View File

@ -22,7 +22,6 @@ class phpbb_convert_30_dbms_to_31_test extends phpbb_test_case
array('mysqli'),
array('oracle'),
array('postgres'),
array('sqlite'),
);
}

View File

@ -29,7 +29,7 @@ class schema_generator_test extends phpbb_test_case
parent::setUp();
$this->config = new \phpbb\config\config(array());
$this->db = new \phpbb\db\driver\sqlite();
$this->db = new \phpbb\db\driver\sqlite3();
$factory = new \phpbb\db\tools\factory();
$this->db_tools = $factory->get($this->db);
$this->table_prefix = 'phpbb_';

View File

@ -76,7 +76,7 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test
global $table_prefix;
$db = new \phpbb\db\driver\sqlite();
$db = new \phpbb\db\driver\sqlite3();
$factory = new \phpbb\db\tools\factory();
$db_tools = $factory->get($db, true);

View File

@ -55,7 +55,6 @@ class phpbb_database_test_connection_manager
switch ($this->dbms['PDO'])
{
case 'sqlite2':
case 'sqlite': // SQLite3 driver
$dsn .= $this->config['dbhost'];
break;
@ -193,7 +192,6 @@ class phpbb_database_test_connection_manager
{
switch ($this->config['dbms'])
{
case 'phpbb\db\driver\sqlite':
case 'phpbb\db\driver\sqlite3':
$this->connect();
// Drop all of the tables
@ -269,12 +267,6 @@ class phpbb_database_test_connection_manager
$sql = 'SHOW TABLES';
break;
case 'phpbb\db\driver\sqlite':
$sql = 'SELECT name
FROM sqlite_master
WHERE type = "table"';
break;
case 'phpbb\db\driver\sqlite3':
$sql = 'SELECT name
FROM sqlite_master
@ -378,7 +370,7 @@ class phpbb_database_test_connection_manager
$classes = $finder->core_path('phpbb/db/migration/data/')
->get_classes();
$db = new \phpbb\db\driver\sqlite();
$db = new \phpbb\db\driver\sqlite3();
$factory = new \phpbb\db\tools\factory();
$db_tools = $factory->get($db, true);
@ -454,11 +446,6 @@ class phpbb_database_test_connection_manager
'DELIM' => ';',
'PDO' => 'pgsql',
),
'phpbb\db\driver\sqlite' => array(
'SCHEMA' => 'sqlite',
'DELIM' => ';',
'PDO' => 'sqlite2',
),
'phpbb\db\driver\sqlite3' => array(
'SCHEMA' => 'sqlite',
'DELIM' => ';',

View File

@ -122,17 +122,6 @@ class phpbb_test_case_helpers
'dbpasswd' => '',
));
}
else if (extension_loaded('sqlite'))
{
$config = array_merge($config, array(
'dbms' => 'phpbb\db\driver\sqlite',
'dbhost' => dirname(__FILE__) . '/../phpbb_unit_tests.sqlite2', // filename
'dbport' => '',
'dbname' => '',
'dbuser' => '',
'dbpasswd' => '',
));
}
if (isset($_SERVER['PHPBB_TEST_CONFIG']))
{