mirror of
https://github.com/phpbb/phpbb.git
synced 2025-08-06 16:56:44 +02:00
Merge remote-tracking branch 'phpbb/develop' into feature/softdelete-1-permission
* phpbb/develop: (704 commits) [ticket/11630] Improvements to the PHP lint pre-commit hook [feature/auth-refactor] Move auth providers to separate directory [ticket/11619] Use HTTP/1.0 because of lack of chunked-encoding handling. [ticket/11619] Some tests for get_remote_file(). [ticket/11617] Remove spaces and tabs from empty lines [ticket/11617] Missing U_ACTION in acp_captcha.php [feature/auth-refactor] Fix code style issue [feature/auth-refactor] Fix comment grammar [feature/auth-refactor] Fix the actual cause of test failures [ticket/10838] Fix URL for wiki and remove irrelevant line [ticket/10838] Remove php 5.4 and builtin server references [ticket/10838] Fix missing data [ticket/10838] separate database used mentioned in unit tests [ticket/11585] Make $auth_admin class property [feature/auth-refactor] A possible fix for the functional test failures [ticket/11566] Subsilver template error displayed after table headers [ticket/11566] Remove extra pair of brackets from conditional statement [ticket/11566] Check that guest doesn't have reporting permission by default [ticket/11566] Add captcha to report post template in subsilver [ticket/11566] Use the new constant CONFIRM_REPORT for captcha init ... Conflicts: phpBB/docs/sphinx.sample.conf phpBB/feed.php phpBB/styles/prosilver/template/search_results.html phpBB/styles/prosilver/template/viewforum_body.html
This commit is contained in:
@@ -568,12 +568,12 @@ class phpbb_db_driver
|
||||
* Run more than one insert statement.
|
||||
*
|
||||
* @param string $table table name to run the statements on
|
||||
* @param array &$sql_ary multi-dimensional array holding the statement data.
|
||||
* @param array $sql_ary multi-dimensional array holding the statement data.
|
||||
*
|
||||
* @return bool false if no statements were executed.
|
||||
* @access public
|
||||
*/
|
||||
function sql_multi_insert($table, &$sql_ary)
|
||||
function sql_multi_insert($table, $sql_ary)
|
||||
{
|
||||
if (!sizeof($sql_ary))
|
||||
{
|
||||
|
65
phpBB/includes/db/driver/mssql_base.php
Normal file
65
phpBB/includes/db/driver/mssql_base.php
Normal file
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package dbal
|
||||
* @copyright (c) 2013 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
if (!defined('IN_PHPBB'))
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* MSSQL Database Base Abstraction Layer
|
||||
* @package dbal
|
||||
*/
|
||||
abstract class phpbb_db_driver_mssql_base extends phpbb_db_driver
|
||||
{
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function sql_concatenate($expr1, $expr2)
|
||||
{
|
||||
return $expr1 . ' + ' . $expr2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Escape string used in sql query
|
||||
*/
|
||||
function sql_escape($msg)
|
||||
{
|
||||
return str_replace(array("'", "\0"), array("''", ''), $msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
function sql_lower_text($column_name)
|
||||
{
|
||||
return "LOWER(SUBSTRING($column_name, 1, DATALENGTH($column_name)))";
|
||||
}
|
||||
|
||||
/**
|
||||
* Build LIKE expression
|
||||
* @access private
|
||||
*/
|
||||
function _sql_like_expression($expression)
|
||||
{
|
||||
return $expression . " ESCAPE '\\'";
|
||||
}
|
||||
|
||||
/**
|
||||
* Build db-specific query data
|
||||
* @access private
|
||||
*/
|
||||
function _sql_custom_build($stage, $data)
|
||||
{
|
||||
return $data;
|
||||
}
|
||||
}
|
@@ -26,7 +26,7 @@ if (!defined('IN_PHPBB'))
|
||||
*
|
||||
* @package dbal
|
||||
*/
|
||||
class phpbb_db_driver_mssql_odbc extends phpbb_db_driver
|
||||
class phpbb_db_driver_mssql_odbc extends phpbb_db_driver_mssql_base
|
||||
{
|
||||
var $last_query_text = '';
|
||||
var $connect_error = '';
|
||||
@@ -125,14 +125,6 @@ class phpbb_db_driver_mssql_odbc extends phpbb_db_driver
|
||||
return ($this->sql_server_version) ? 'MSSQL (ODBC)<br />' . $this->sql_server_version : 'MSSQL (ODBC)';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function sql_concatenate($expr1, $expr2)
|
||||
{
|
||||
return $expr1 . ' + ' . $expr2;
|
||||
}
|
||||
|
||||
/**
|
||||
* SQL Transaction
|
||||
* @access private
|
||||
@@ -261,7 +253,7 @@ class phpbb_db_driver_mssql_odbc extends phpbb_db_driver
|
||||
* Fetch current row
|
||||
* @note number of bytes returned depends on odbc.defaultlrl php.ini setting. If it is limited to 4K for example only 4K of data is returned max.
|
||||
*/
|
||||
function sql_fetchrow($query_id = false, $debug = false)
|
||||
function sql_fetchrow($query_id = false)
|
||||
{
|
||||
global $cache;
|
||||
|
||||
@@ -325,40 +317,6 @@ class phpbb_db_driver_mssql_odbc extends phpbb_db_driver
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Escape string used in sql query
|
||||
*/
|
||||
function sql_escape($msg)
|
||||
{
|
||||
return str_replace(array("'", "\0"), array("''", ''), $msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
function sql_lower_text($column_name)
|
||||
{
|
||||
return "LOWER(SUBSTRING($column_name, 1, DATALENGTH($column_name)))";
|
||||
}
|
||||
|
||||
/**
|
||||
* Build LIKE expression
|
||||
* @access private
|
||||
*/
|
||||
function _sql_like_expression($expression)
|
||||
{
|
||||
return $expression . " ESCAPE '\\'";
|
||||
}
|
||||
|
||||
/**
|
||||
* Build db-specific query data
|
||||
* @access private
|
||||
*/
|
||||
function _sql_custom_build($stage, $data)
|
||||
{
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* return sql error array
|
||||
* @access private
|
||||
|
@@ -191,7 +191,7 @@ class result_mssqlnative
|
||||
/**
|
||||
* @package dbal
|
||||
*/
|
||||
class phpbb_db_driver_mssqlnative extends phpbb_db_driver
|
||||
class phpbb_db_driver_mssqlnative extends phpbb_db_driver_mssql_base
|
||||
{
|
||||
var $m_insert_id = NULL;
|
||||
var $last_query_text = '';
|
||||
@@ -256,14 +256,6 @@ class phpbb_db_driver_mssqlnative extends phpbb_db_driver
|
||||
return ($this->sql_server_version) ? 'MSSQL<br />' . $this->sql_server_version : 'MSSQL';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function sql_concatenate($expr1, $expr2)
|
||||
{
|
||||
return $expr1 . ' + ' . $expr2;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@@ -334,7 +326,7 @@ class phpbb_db_driver_mssqlnative extends phpbb_db_driver
|
||||
$this->sql_report('stop', $query);
|
||||
}
|
||||
|
||||
if ($cache_ttl)
|
||||
if ($cache && $cache_ttl)
|
||||
{
|
||||
$this->open_queries[(int) $this->query_result] = $this->query_result;
|
||||
$this->query_result = $cache->sql_save($this, $query, $this->query_result, $cache_ttl);
|
||||
@@ -402,7 +394,7 @@ class phpbb_db_driver_mssqlnative extends phpbb_db_driver
|
||||
*/
|
||||
function sql_affectedrows()
|
||||
{
|
||||
return (!empty($this->query_result)) ? @sqlsrv_rows_affected($this->query_result) : false;
|
||||
return ($this->db_connect_id) ? @sqlsrv_rows_affected($this->query_result) : false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -417,7 +409,7 @@ class phpbb_db_driver_mssqlnative extends phpbb_db_driver
|
||||
$query_id = $this->query_result;
|
||||
}
|
||||
|
||||
if ($cache->sql_exists($query_id))
|
||||
if ($cache && $cache->sql_exists($query_id))
|
||||
{
|
||||
return $cache->sql_fetchrow($query_id);
|
||||
}
|
||||
@@ -482,39 +474,14 @@ class phpbb_db_driver_mssqlnative extends phpbb_db_driver
|
||||
return $cache->sql_freeresult($query_id);
|
||||
}
|
||||
|
||||
if (isset($this->open_queries[$query_id]))
|
||||
if (isset($this->open_queries[(int) $query_id]))
|
||||
{
|
||||
unset($this->open_queries[$query_id]);
|
||||
unset($this->open_queries[(int) $query_id]);
|
||||
return @sqlsrv_free_stmt($query_id);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Escape string used in sql query
|
||||
*/
|
||||
function sql_escape($msg)
|
||||
{
|
||||
return str_replace(array("'", "\0"), array("''", ''), $msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
function sql_lower_text($column_name)
|
||||
{
|
||||
return "LOWER(SUBSTRING($column_name, 1, DATALENGTH($column_name)))";
|
||||
}
|
||||
|
||||
/**
|
||||
* Build LIKE expression
|
||||
* @access private
|
||||
*/
|
||||
function _sql_like_expression($expression)
|
||||
{
|
||||
return $expression . " ESCAPE '\\'";
|
||||
}
|
||||
|
||||
/**
|
||||
* return sql error array
|
||||
* @access private
|
||||
@@ -560,15 +527,6 @@ class phpbb_db_driver_mssqlnative extends phpbb_db_driver
|
||||
return $error;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build db-specific query data
|
||||
* @access private
|
||||
*/
|
||||
function _sql_custom_build($stage, $data)
|
||||
{
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Close sql connection
|
||||
* @access private
|
||||
|
@@ -24,7 +24,7 @@ if (!defined('IN_PHPBB'))
|
||||
* MySQL 5.0+
|
||||
* @package dbal
|
||||
*/
|
||||
class phpbb_db_driver_mysql extends phpbb_db_driver
|
||||
class phpbb_db_driver_mysql extends phpbb_db_driver_mysql_base
|
||||
{
|
||||
var $multi_insert = true;
|
||||
var $connect_error = '';
|
||||
@@ -135,14 +135,6 @@ class phpbb_db_driver_mysql extends phpbb_db_driver
|
||||
return ($raw) ? $this->sql_server_version : 'MySQL ' . $this->sql_server_version;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function sql_concatenate($expr1, $expr2)
|
||||
{
|
||||
return 'CONCAT(' . $expr1 . ', ' . $expr2 . ')';
|
||||
}
|
||||
|
||||
/**
|
||||
* SQL Transaction
|
||||
* @access private
|
||||
@@ -226,25 +218,6 @@ class phpbb_db_driver_mysql extends phpbb_db_driver
|
||||
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)
|
||||
{
|
||||
// Having a value of -1 was always a bug
|
||||
$total = '18446744073709551615';
|
||||
}
|
||||
|
||||
$query .= "\n LIMIT " . ((!empty($offset)) ? $offset . ', ' . $total : $total);
|
||||
|
||||
return $this->sql_query($query, $cache_ttl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return number of affected rows
|
||||
*/
|
||||
@@ -341,101 +314,6 @@ class phpbb_db_driver_mysql extends phpbb_db_driver
|
||||
return @mysql_real_escape_string($msg, $this->db_connect_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the estimated number of rows in a specified table.
|
||||
*
|
||||
* @param string $table_name Table name
|
||||
*
|
||||
* @return string Number of rows in $table_name.
|
||||
* Prefixed with ~ if estimated (otherwise exact).
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
function get_estimated_row_count($table_name)
|
||||
{
|
||||
$table_status = $this->get_table_status($table_name);
|
||||
|
||||
if (isset($table_status['Engine']))
|
||||
{
|
||||
if ($table_status['Engine'] === 'MyISAM')
|
||||
{
|
||||
return $table_status['Rows'];
|
||||
}
|
||||
else if ($table_status['Engine'] === 'InnoDB' && $table_status['Rows'] > 100000)
|
||||
{
|
||||
return '~' . $table_status['Rows'];
|
||||
}
|
||||
}
|
||||
|
||||
return parent::get_row_count($table_name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the exact number of rows in a specified table.
|
||||
*
|
||||
* @param string $table_name Table name
|
||||
*
|
||||
* @return string Exact number of rows in $table_name.
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
function get_row_count($table_name)
|
||||
{
|
||||
$table_status = $this->get_table_status($table_name);
|
||||
|
||||
if (isset($table_status['Engine']) && $table_status['Engine'] === 'MyISAM')
|
||||
{
|
||||
return $table_status['Rows'];
|
||||
}
|
||||
|
||||
return parent::get_row_count($table_name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets some information about the specified table.
|
||||
*
|
||||
* @param string $table_name Table name
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @access protected
|
||||
*/
|
||||
function get_table_status($table_name)
|
||||
{
|
||||
$sql = "SHOW TABLE STATUS
|
||||
LIKE '" . $this->sql_escape($table_name) . "'";
|
||||
$result = $this->sql_query($sql);
|
||||
$table_status = $this->sql_fetchrow($result);
|
||||
$this->sql_freeresult($result);
|
||||
|
||||
return $table_status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build LIKE expression
|
||||
* @access private
|
||||
*/
|
||||
function _sql_like_expression($expression)
|
||||
{
|
||||
return $expression;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build db-specific query data
|
||||
* @access private
|
||||
*/
|
||||
function _sql_custom_build($stage, $data)
|
||||
{
|
||||
switch ($stage)
|
||||
{
|
||||
case 'FROM':
|
||||
$data = '(' . $data . ')';
|
||||
break;
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* return sql error array
|
||||
* @access private
|
||||
|
145
phpBB/includes/db/driver/mysql_base.php
Normal file
145
phpBB/includes/db/driver/mysql_base.php
Normal file
@@ -0,0 +1,145 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package dbal
|
||||
* @copyright (c) 2013 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
if (!defined('IN_PHPBB'))
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Abstract MySQL Database Base Abstraction Layer
|
||||
* @package dbal
|
||||
*/
|
||||
abstract class phpbb_db_driver_mysql_base extends phpbb_db_driver
|
||||
{
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function sql_concatenate($expr1, $expr2)
|
||||
{
|
||||
return 'CONCAT(' . $expr1 . ', ' . $expr2 . ')';
|
||||
}
|
||||
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
// MySQL 4.1+ no longer supports -1 in limit queries
|
||||
$total = '18446744073709551615';
|
||||
}
|
||||
|
||||
$query .= "\n LIMIT " . ((!empty($offset)) ? $offset . ', ' . $total : $total);
|
||||
|
||||
return $this->sql_query($query, $cache_ttl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the estimated number of rows in a specified table.
|
||||
*
|
||||
* @param string $table_name Table name
|
||||
*
|
||||
* @return string Number of rows in $table_name.
|
||||
* Prefixed with ~ if estimated (otherwise exact).
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
function get_estimated_row_count($table_name)
|
||||
{
|
||||
$table_status = $this->get_table_status($table_name);
|
||||
|
||||
if (isset($table_status['Engine']))
|
||||
{
|
||||
if ($table_status['Engine'] === 'MyISAM')
|
||||
{
|
||||
return $table_status['Rows'];
|
||||
}
|
||||
else if ($table_status['Engine'] === 'InnoDB' && $table_status['Rows'] > 100000)
|
||||
{
|
||||
return '~' . $table_status['Rows'];
|
||||
}
|
||||
}
|
||||
|
||||
return parent::get_row_count($table_name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the exact number of rows in a specified table.
|
||||
*
|
||||
* @param string $table_name Table name
|
||||
*
|
||||
* @return string Exact number of rows in $table_name.
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
function get_row_count($table_name)
|
||||
{
|
||||
$table_status = $this->get_table_status($table_name);
|
||||
|
||||
if (isset($table_status['Engine']) && $table_status['Engine'] === 'MyISAM')
|
||||
{
|
||||
return $table_status['Rows'];
|
||||
}
|
||||
|
||||
return parent::get_row_count($table_name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets some information about the specified table.
|
||||
*
|
||||
* @param string $table_name Table name
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @access protected
|
||||
*/
|
||||
function get_table_status($table_name)
|
||||
{
|
||||
$sql = "SHOW TABLE STATUS
|
||||
LIKE '" . $this->sql_escape($table_name) . "'";
|
||||
$result = $this->sql_query($sql);
|
||||
$table_status = $this->sql_fetchrow($result);
|
||||
$this->sql_freeresult($result);
|
||||
|
||||
return $table_status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build LIKE expression
|
||||
* @access private
|
||||
*/
|
||||
function _sql_like_expression($expression)
|
||||
{
|
||||
return $expression;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build db-specific query data
|
||||
* @access private
|
||||
*/
|
||||
function _sql_custom_build($stage, $data)
|
||||
{
|
||||
switch ($stage)
|
||||
{
|
||||
case 'FROM':
|
||||
$data = '(' . $data . ')';
|
||||
break;
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
@@ -21,7 +21,7 @@ if (!defined('IN_PHPBB'))
|
||||
* MySQL 4.1+ or MySQL 5.0+
|
||||
* @package dbal
|
||||
*/
|
||||
class phpbb_db_driver_mysqli extends phpbb_db_driver
|
||||
class phpbb_db_driver_mysqli extends phpbb_db_driver_mysql_base
|
||||
{
|
||||
var $multi_insert = true;
|
||||
var $connect_error = '';
|
||||
@@ -103,6 +103,7 @@ class phpbb_db_driver_mysqli extends phpbb_db_driver
|
||||
|
||||
/**
|
||||
* Version information about used database
|
||||
* @param bool $raw if true, only return the fetched sql_server_version
|
||||
* @param bool $use_cache If true, it is safe to retrieve the value from the cache
|
||||
* @return string sql server version
|
||||
*/
|
||||
@@ -127,14 +128,6 @@ class phpbb_db_driver_mysqli extends phpbb_db_driver
|
||||
return ($raw) ? $this->sql_server_version : 'MySQL(i) ' . $this->sql_server_version;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function sql_concatenate($expr1, $expr2)
|
||||
{
|
||||
return 'CONCAT(' . $expr1 . ', ' . $expr2 . ')';
|
||||
}
|
||||
|
||||
/**
|
||||
* SQL Transaction
|
||||
* @access private
|
||||
@@ -217,25 +210,6 @@ class phpbb_db_driver_mysqli extends phpbb_db_driver
|
||||
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)
|
||||
{
|
||||
// MySQL 4.1+ no longer supports -1 in limit queries
|
||||
$total = '18446744073709551615';
|
||||
}
|
||||
|
||||
$query .= "\n LIMIT " . ((!empty($offset)) ? $offset . ', ' . $total : $total);
|
||||
|
||||
return $this->sql_query($query, $cache_ttl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return number of affected rows
|
||||
*/
|
||||
@@ -327,101 +301,6 @@ class phpbb_db_driver_mysqli extends phpbb_db_driver
|
||||
return @mysqli_real_escape_string($this->db_connect_id, $msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the estimated number of rows in a specified table.
|
||||
*
|
||||
* @param string $table_name Table name
|
||||
*
|
||||
* @return string Number of rows in $table_name.
|
||||
* Prefixed with ~ if estimated (otherwise exact).
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
function get_estimated_row_count($table_name)
|
||||
{
|
||||
$table_status = $this->get_table_status($table_name);
|
||||
|
||||
if (isset($table_status['Engine']))
|
||||
{
|
||||
if ($table_status['Engine'] === 'MyISAM')
|
||||
{
|
||||
return $table_status['Rows'];
|
||||
}
|
||||
else if ($table_status['Engine'] === 'InnoDB' && $table_status['Rows'] > 100000)
|
||||
{
|
||||
return '~' . $table_status['Rows'];
|
||||
}
|
||||
}
|
||||
|
||||
return parent::get_row_count($table_name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the exact number of rows in a specified table.
|
||||
*
|
||||
* @param string $table_name Table name
|
||||
*
|
||||
* @return string Exact number of rows in $table_name.
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
function get_row_count($table_name)
|
||||
{
|
||||
$table_status = $this->get_table_status($table_name);
|
||||
|
||||
if (isset($table_status['Engine']) && $table_status['Engine'] === 'MyISAM')
|
||||
{
|
||||
return $table_status['Rows'];
|
||||
}
|
||||
|
||||
return parent::get_row_count($table_name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets some information about the specified table.
|
||||
*
|
||||
* @param string $table_name Table name
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @access protected
|
||||
*/
|
||||
function get_table_status($table_name)
|
||||
{
|
||||
$sql = "SHOW TABLE STATUS
|
||||
LIKE '" . $this->sql_escape($table_name) . "'";
|
||||
$result = $this->sql_query($sql);
|
||||
$table_status = $this->sql_fetchrow($result);
|
||||
$this->sql_freeresult($result);
|
||||
|
||||
return $table_status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build LIKE expression
|
||||
* @access private
|
||||
*/
|
||||
function _sql_like_expression($expression)
|
||||
{
|
||||
return $expression;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build db-specific query data
|
||||
* @access private
|
||||
*/
|
||||
function _sql_custom_build($stage, $data)
|
||||
{
|
||||
switch ($stage)
|
||||
{
|
||||
case 'FROM':
|
||||
$data = '(' . $data . ')';
|
||||
break;
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* return sql error array
|
||||
* @access private
|
||||
|
23
phpBB/includes/db/migration/data/310/boardindex.php
Normal file
23
phpBB/includes/db/migration/data/310/boardindex.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package migration
|
||||
* @copyright (c) 2013 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
class phpbb_db_migration_data_310_boardindex extends phpbb_db_migration
|
||||
{
|
||||
public function effectively_installed()
|
||||
{
|
||||
return isset($this->config['board_index_text']);
|
||||
}
|
||||
|
||||
public function update_data()
|
||||
{
|
||||
return array(
|
||||
array('config.add', array('board_index_text', '')),
|
||||
);
|
||||
}
|
||||
}
|
28
phpBB/includes/db/migration/data/310/forgot_password.php
Normal file
28
phpBB/includes/db/migration/data/310/forgot_password.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package migration
|
||||
* @copyright (c) 2012 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
class phpbb_db_migration_data_310_forgot_password extends phpbb_db_migration
|
||||
{
|
||||
public function effectively_installed()
|
||||
{
|
||||
return isset($this->config['allow_password_reset']);
|
||||
}
|
||||
|
||||
static public function depends_on()
|
||||
{
|
||||
return array('phpbb_db_migration_data_30x_3_0_11');
|
||||
}
|
||||
|
||||
public function update_data()
|
||||
{
|
||||
return array(
|
||||
array('config.add', array('allow_password_reset', 1)),
|
||||
);
|
||||
}
|
||||
}
|
31
phpBB/includes/db/migration/data/310/jquery_update.php
Normal file
31
phpBB/includes/db/migration/data/310/jquery_update.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package migration
|
||||
* @copyright (c) 2013 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
class phpbb_db_migration_data_310_jquery_update extends phpbb_db_migration
|
||||
{
|
||||
public function effectively_installed()
|
||||
{
|
||||
return $this->config['load_jquery_url'] !== '//ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js';
|
||||
}
|
||||
|
||||
static public function depends_on()
|
||||
{
|
||||
return array(
|
||||
'phpbb_db_migration_data_310_dev',
|
||||
);
|
||||
}
|
||||
|
||||
public function update_data()
|
||||
{
|
||||
return array(
|
||||
array('config.update', array('load_jquery_url', '//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js')),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package migration
|
||||
* @copyright (c) 2013 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
class phpbb_db_migration_data_310_notifications_schema_fix extends phpbb_db_migration
|
||||
{
|
||||
static public function depends_on()
|
||||
{
|
||||
return array('phpbb_db_migration_data_310_notifications');
|
||||
}
|
||||
|
||||
public function update_schema()
|
||||
{
|
||||
return array(
|
||||
'drop_tables' => array(
|
||||
$this->table_prefix . 'notification_types',
|
||||
$this->table_prefix . 'notifications',
|
||||
),
|
||||
'add_tables' => array(
|
||||
$this->table_prefix . 'notification_types' => array(
|
||||
'COLUMNS' => array(
|
||||
'notification_type_id' => array('USINT', NULL, 'auto_increment'),
|
||||
'notification_type_name' => array('VCHAR:255', ''),
|
||||
'notification_type_enabled' => array('BOOL', 1),
|
||||
),
|
||||
'PRIMARY_KEY' => array('notification_type_id'),
|
||||
'KEYS' => array(
|
||||
'type' => array('UNIQUE', array('notification_type_name')),
|
||||
),
|
||||
),
|
||||
$this->table_prefix . 'notifications' => array(
|
||||
'COLUMNS' => array(
|
||||
'notification_id' => array('UINT:10', NULL, 'auto_increment'),
|
||||
'notification_type_id' => array('USINT', 0),
|
||||
'item_id' => array('UINT', 0),
|
||||
'item_parent_id' => array('UINT', 0),
|
||||
'user_id' => array('UINT', 0),
|
||||
'notification_read' => array('BOOL', 0),
|
||||
'notification_time' => array('TIMESTAMP', 1),
|
||||
'notification_data' => array('TEXT_UNI', ''),
|
||||
),
|
||||
'PRIMARY_KEY' => 'notification_id',
|
||||
'KEYS' => array(
|
||||
'item_ident' => array('INDEX', array('notification_type_id', 'item_id')),
|
||||
'user' => array('INDEX', array('user_id', 'notification_read')),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
public function revert_schema()
|
||||
{
|
||||
return array(
|
||||
'drop_tables' => array(
|
||||
$this->table_prefix . 'notification_types',
|
||||
$this->table_prefix . 'notifications',
|
||||
),
|
||||
'add_tables' => array(
|
||||
$this->table_prefix . 'notification_types' => array(
|
||||
'COLUMNS' => array(
|
||||
'notification_type' => array('VCHAR:255', ''),
|
||||
'notification_type_enabled' => array('BOOL', 1),
|
||||
),
|
||||
'PRIMARY_KEY' => array('notification_type', 'notification_type_enabled'),
|
||||
),
|
||||
$this->table_prefix . 'notifications' => array(
|
||||
'COLUMNS' => array(
|
||||
'notification_id' => array('UINT', NULL, 'auto_increment'),
|
||||
'item_type' => array('VCHAR:255', ''),
|
||||
'item_id' => array('UINT', 0),
|
||||
'item_parent_id' => array('UINT', 0),
|
||||
'user_id' => array('UINT', 0),
|
||||
'notification_read' => array('BOOL', 0),
|
||||
'notification_time' => array('TIMESTAMP', 1),
|
||||
'notification_data' => array('TEXT_UNI', ''),
|
||||
),
|
||||
'PRIMARY_KEY' => 'notification_id',
|
||||
'KEYS' => array(
|
||||
'item_ident' => array('INDEX', array('item_type', 'item_id')),
|
||||
'user' => array('INDEX', array('user_id', 'notification_read')),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package migration
|
||||
* @copyright (c) 2013 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
class phpbb_db_migration_data_310_signature_module_auth extends phpbb_db_migration
|
||||
{
|
||||
public function effectively_installed()
|
||||
{
|
||||
$sql = 'SELECT module_auth
|
||||
FROM ' . MODULES_TABLE . "
|
||||
WHERE module_class = 'ucp'
|
||||
AND module_basename = 'ucp_profile'
|
||||
AND module_mode = 'signature'";
|
||||
$result = $this->db->sql_query($sql);
|
||||
$module_auth = $this->db_sql_fetchfield('module_auth');
|
||||
$this->db->sql_freeresult($result);
|
||||
|
||||
return $module_auth === 'acl_u_sig' || $module_auth === false;
|
||||
}
|
||||
|
||||
static public function depends_on()
|
||||
{
|
||||
return array('phpbb_db_migration_data_31x_dev');
|
||||
}
|
||||
|
||||
public function update_data()
|
||||
{
|
||||
return array(
|
||||
array('custom', array(
|
||||
array($this, 'update_signature_module_auth'),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
public function update_signature_module_auth()
|
||||
{
|
||||
$sql = 'UPDATE ' . MODULES_TABLE . "
|
||||
SET module_auth = 'acl_u_sig'
|
||||
WHERE module_class = 'ucp'
|
||||
AND module_basename = 'ucp_profile'
|
||||
AND module_mode = 'signature'
|
||||
AND module_auth = ''";
|
||||
$this->db->sql_query($sql);
|
||||
}
|
||||
}
|
@@ -19,6 +19,34 @@ class phpbb_db_migration_data_310_style_update_p1 extends phpbb_db_migration
|
||||
return array('phpbb_db_migration_data_30x_3_0_11');
|
||||
}
|
||||
|
||||
public function update_schema()
|
||||
{
|
||||
return array(
|
||||
'add_columns' => array(
|
||||
$this->table_prefix . 'styles' => array(
|
||||
'style_path' => array('VCHAR:100', ''),
|
||||
'bbcode_bitfield' => array('VCHAR:255', 'kNg='),
|
||||
'style_parent_id' => array('UINT', 0),
|
||||
'style_parent_tree' => array('TEXT', ''),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
public function revert_schema()
|
||||
{
|
||||
return array(
|
||||
'drop_columns' => array(
|
||||
$this->table_prefix . 'styles' => array(
|
||||
'style_path',
|
||||
'bbcode_bitfield',
|
||||
'style_parent_id',
|
||||
'style_parent_tree',
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
public function update_data()
|
||||
{
|
||||
return array(
|
||||
|
@@ -209,9 +209,6 @@ class phpbb_db_migration_tool_module implements phpbb_db_migration_tool_interfac
|
||||
}
|
||||
|
||||
// The "manual" way
|
||||
$module_log_name = ((isset($this->user->lang[$data['module_langname']])) ? $this->user->lang[$data['module_langname']] : $data['module_langname']);
|
||||
add_log('admin', 'LOG_MODULE_ADD', $module_log_name);
|
||||
|
||||
if (!is_numeric($parent))
|
||||
{
|
||||
$sql = 'SELECT module_id
|
||||
@@ -267,6 +264,8 @@ class phpbb_db_migration_tool_module implements phpbb_db_migration_tool_interfac
|
||||
else
|
||||
{
|
||||
// Success
|
||||
$module_log_name = ((isset($this->user->lang[$data['module_langname']])) ? $this->user->lang[$data['module_langname']] : $data['module_langname']);
|
||||
add_log('admin', 'LOG_MODULE_ADD', $module_log_name);
|
||||
|
||||
// Move the module if requested above/below an existing one
|
||||
if (isset($data['before']) && $data['before'])
|
||||
|
@@ -362,6 +362,12 @@ class phpbb_db_migrator
|
||||
{
|
||||
$state = ($state) ? unserialize($state) : false;
|
||||
|
||||
// reverse order of steps if reverting
|
||||
if ($revert === true)
|
||||
{
|
||||
$steps = array_reverse($steps);
|
||||
}
|
||||
|
||||
foreach ($steps as $step_identifier => $step)
|
||||
{
|
||||
$last_result = false;
|
||||
|
150
phpBB/includes/db/sql_insert_buffer.php
Normal file
150
phpBB/includes/db/sql_insert_buffer.php
Normal file
@@ -0,0 +1,150 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package dbal
|
||||
* @copyright (c) 2013 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
if (!defined('IN_PHPBB'))
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Collects rows for insert into a database until the buffer size is reached.
|
||||
* Then flushes the buffer to the database and starts over again.
|
||||
*
|
||||
* Benefits over collecting a (possibly huge) insert array and then using
|
||||
* $db->sql_multi_insert() include:
|
||||
*
|
||||
* - Going over max packet size of the database connection is usually prevented
|
||||
* because the data is submitted in batches.
|
||||
*
|
||||
* - Reaching database connection timeout is usually prevented because
|
||||
* submission of batches talks to the database every now and then.
|
||||
*
|
||||
* - Usage of less PHP memory because data no longer needed is discarded on
|
||||
* buffer flush.
|
||||
*
|
||||
* Attention:
|
||||
* Please note that users of this class have to call flush() to flush the
|
||||
* remaining rows to the database after their batch insert operation is
|
||||
* finished.
|
||||
*
|
||||
* Usage:
|
||||
* <code>
|
||||
* $buffer = new phpbb_db_sql_insert_buffer($db, 'test_table', 1234);
|
||||
*
|
||||
* while (do_stuff())
|
||||
* {
|
||||
* $buffer->insert(array(
|
||||
* 'column1' => 'value1',
|
||||
* 'column2' => 'value2',
|
||||
* ));
|
||||
* }
|
||||
*
|
||||
* $buffer->flush();
|
||||
* </code>
|
||||
*
|
||||
* @package dbal
|
||||
*/
|
||||
class phpbb_db_sql_insert_buffer
|
||||
{
|
||||
/** @var phpbb_db_driver */
|
||||
protected $db;
|
||||
|
||||
/** @var string */
|
||||
protected $table_name;
|
||||
|
||||
/** @var int */
|
||||
protected $max_buffered_rows;
|
||||
|
||||
/** @var array */
|
||||
protected $buffer = array();
|
||||
|
||||
/**
|
||||
* @param phpbb_db_driver $db
|
||||
* @param string $table_name
|
||||
* @param int $max_buffered_rows
|
||||
*/
|
||||
public function __construct(phpbb_db_driver $db, $table_name, $max_buffered_rows = 500)
|
||||
{
|
||||
$this->db = $db;
|
||||
$this->table_name = $table_name;
|
||||
$this->max_buffered_rows = $max_buffered_rows;
|
||||
}
|
||||
|
||||
/**
|
||||
* Inserts a single row into the buffer if multi insert is supported by the
|
||||
* database (otherwise an insert query is sent immediately). Then flushes
|
||||
* the buffer if the number of rows in the buffer is now greater than or
|
||||
* equal to $max_buffered_rows.
|
||||
*
|
||||
* @param array $row
|
||||
*
|
||||
* @return bool True when some data was flushed to the database.
|
||||
* False otherwise.
|
||||
*/
|
||||
public function insert(array $row)
|
||||
{
|
||||
$this->buffer[] = $row;
|
||||
|
||||
// Flush buffer if it is full or when DB does not support multi inserts.
|
||||
// In the later case, the buffer will always only contain one row.
|
||||
if (!$this->db->multi_insert || sizeof($this->buffer) >= $this->max_buffered_rows)
|
||||
{
|
||||
return $this->flush();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Inserts a row set, i.e. an array of rows, by calling insert().
|
||||
*
|
||||
* Please note that it is in most cases better to use insert() instead of
|
||||
* first building a huge rowset. Or at least sizeof($rows) should be kept
|
||||
* small.
|
||||
*
|
||||
* @param array $rows
|
||||
*
|
||||
* @return bool True when some data was flushed to the database.
|
||||
* False otherwise.
|
||||
*/
|
||||
public function insert_all(array $rows)
|
||||
{
|
||||
// Using bitwise |= because PHP does not have logical ||=
|
||||
$result = 0;
|
||||
|
||||
foreach ($rows as $row)
|
||||
{
|
||||
$result |= (int) $this->insert($row);
|
||||
}
|
||||
|
||||
return (bool) $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Flushes the buffer content to the DB and clears the buffer.
|
||||
*
|
||||
* @return bool True when some data was flushed to the database.
|
||||
* False otherwise.
|
||||
*/
|
||||
public function flush()
|
||||
{
|
||||
if (!empty($this->buffer))
|
||||
{
|
||||
$this->db->sql_multi_insert($this->table_name, $this->buffer);
|
||||
$this->buffer = array();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user