Version 4.1.19
This commit is contained in:
1 parent
28bd025b35
commit
2bd5025018
2674 files changed
+233518
-77766
No files matched your search
@@ -2,7 +2,7 @@
|
||||
/**
|
||||
* @brief Conversion module
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Tools
|
||||
* @since 4 Sept 2013
|
||||
@@ -16,7 +16,7 @@ namespace IPSUtf8;
|
||||
*/
|
||||
class Convert
|
||||
{
|
||||
const VERSION_ID = '1.1.18';
|
||||
const VERSION_ID = '1.1.20';
|
||||
|
||||
/**
|
||||
* @brief Data Store
|
||||
@@ -147,7 +147,7 @@ class Convert
|
||||
/* MB4? */
|
||||
$sessionData = \IPSUtf8\Session::i()->json;
|
||||
|
||||
if ( isset( $sessionData['use_utf8mb4'] ) AND ! empty( $sessionData['use_utf8mb4'] ) )
|
||||
if ( isset( $sessionData['use_utf8mb4'] ) AND $sessionData['use_utf8mb4'] )
|
||||
{
|
||||
static::$utf->set_charset( 'utf8mb4' );
|
||||
}
|
||||
@@ -301,13 +301,13 @@ class Convert
|
||||
/* Even if the current charset is set to UTF-8, if the Table Charset is latin1, we need to use this method */
|
||||
/* ... but only if the actual column isn't using utf8 */
|
||||
$columnCollation = $schematic['definition']['columns'][$col]['collation'];
|
||||
if ( defined( 'UTF8_INSERT_ONLY' ) AND UTF8_INSERT_ONLY === TRUE AND $tableCharSet == 'utf8' )
|
||||
if ( UTF8_INSERT_ONLY === TRUE AND $tableCharSet == 'utf8' )
|
||||
{
|
||||
$select[] = 'CAST( `' . $col . '` AS BINARY )';
|
||||
}
|
||||
else if ( \IPSUtf8\Session::i()->current_charset != 'utf-8' OR ( $tableCharSet != 'utf8' AND ! in_array( $columnCollation, array( 'utf8_unicode_ci', 'utf8mb4_unicode_ci' ) ) ) OR ( $tableCharSet == 'utf8' AND mb_substr( $columnCollation, 0, 5 ) == 'latin' ) )
|
||||
else if ( FORCE_MULTI_CONVERT === FALSE AND ( \IPSUtf8\Session::i()->current_charset != 'utf-8' OR ( $tableCharSet != 'utf8' AND ! in_array( $columnCollation, array( 'utf8_unicode_ci', 'utf8mb4_unicode_ci' ) ) ) OR ( $tableCharSet == 'utf8' AND mb_substr( $columnCollation, 0, 5 ) == 'latin' ) ) )
|
||||
{
|
||||
if ( \IPSUtf8\Session::i()->current_charset == 'iso-8859-1' OR mb_substr( $columnCollation, 0, 5 ) == 'latin' )
|
||||
if ( \IPSUtf8\Session::i()->current_charset == 'iso-8859-1' AND mb_substr( $columnCollation, 0, 5 ) == 'latin' )
|
||||
{
|
||||
/* Casting as binary truncates non-latin characters, so if we are using real Latin1, just convert */
|
||||
$select[] = 'CONVERT( `' . $col . '` USING utf8 )';
|
||||
@@ -557,7 +557,7 @@ class Convert
|
||||
/* Optimise */
|
||||
$this->preInsert( $table );
|
||||
|
||||
$insertId = static::$utf->insert( $table['name'], $batch, false, true, $table );
|
||||
$insertId = static::$utf->insert( $table['name'], $batch, true, true, $table );
|
||||
|
||||
if ( ! empty( static::$utf->error ) )
|
||||
{
|
||||
@@ -985,7 +985,7 @@ class Convert
|
||||
$modify = array();
|
||||
$hasUnique = FALSE;
|
||||
|
||||
/* Changing collation can cause issues for duplicate enries in unique keys */
|
||||
/* Changing collation can cause issues for duplicate entries in unique keys */
|
||||
if ( isset( $tableData['definition']['indexes'] ) )
|
||||
{
|
||||
foreach( $tableData['definition']['indexes'] as $key => $index )
|
||||
@@ -1017,7 +1017,7 @@ class Convert
|
||||
/* Let's try an alter first - below may not be necessary */
|
||||
try
|
||||
{
|
||||
static::$utf->query( "ALTER TABLE `" . static::$db->prefix . $name . "` CONVERT TO CHARACTER SET " . $charset . " COLLATE " . $collation );
|
||||
static::$utf->query( "ALTER TABLE `" . static::$db->prefix . $name . "` CONVERT TO CHARACTER SET " . $charset . " COLLATE " . $collation );
|
||||
static::$utf->query( "ALTER TABLE `" . static::$db->prefix . $name . "` DEFAULT CHARACTER SET " . $charset . " COLLATE " . $collation );
|
||||
}
|
||||
catch( \IPSUtf8\Db\Exception $e )
|
||||
@@ -1026,14 +1026,13 @@ class Convert
|
||||
static::$utf->query( "RENAME TABLE `" . static::$db->prefix . $name . "` TO `" . static::$db->prefix . $name . "_temp`" );
|
||||
static::log( $name . " has Unique Index - temp table created from main." );
|
||||
static::$utf->query( "CREATE TABLE `" . static::$db->prefix . $name . "` LIKE `" . static::$db->prefix . $name . "_temp`" );
|
||||
static::$utf->query( "ALTER TABLE `" . static::$db->prefix . $name . "` CONVERT TO CHARACTER SET " . $charset . " COLLATE " . $collation );
|
||||
static::$utf->query( "ALTER TABLE `" . static::$db->prefix . $name . "` DEFAULT CHARACTER SET " . $charset . " COLLATE " . $collation );
|
||||
static::log( $name . " created from temp table." );
|
||||
static::$utf->query( "REPLACE INTO `" . static::$db->prefix . $name . "` SELECT * FROM `" . static::$db->prefix . $name . "_temp`" );
|
||||
static::log( $name . " data copied to new table." );
|
||||
static::$utf->query( "DROP TABLE `" . static::$db->prefix . $name . "_temp`" );
|
||||
static::log( $name . "_temp dropped" );
|
||||
|
||||
static::$utf->query( "ALTER TABLE `" . static::$db->prefix . $name . "` CONVERT TO CHARACTER SET " . $charset . " COLLATE " . $collation );
|
||||
static::$utf->query( "ALTER TABLE `" . static::$db->prefix . $name . "` DEFAULT CHARACTER SET " . $charset . " COLLATE " . $collation );
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -1078,6 +1077,12 @@ class Convert
|
||||
|
||||
/* Update table data */
|
||||
\IPSUtf8\Session::i()->updateTableData();
|
||||
|
||||
/* Update character set if we're in IP.Board */
|
||||
if ( static::$utf->checkForTable('core_sys_conf_settings' ) )
|
||||
{
|
||||
static::$utf->update( 'core_sys_conf_settings', array( 'conf_value' => '' ), array( 'conf_key=?', 'gb_char_set' ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1085,7 +1090,7 @@ class Convert
|
||||
*
|
||||
* @param int $limit Process() method limit
|
||||
* @param int $cycleCount Items processed if this was in the middle of process()
|
||||
* @return void
|
||||
* @return bool|null
|
||||
*/
|
||||
public function heal( $limit=250, $cycleCount=0 )
|
||||
{
|
||||
@@ -1147,6 +1152,8 @@ class Convert
|
||||
/* Run again */
|
||||
return $this->process( ( $limit - $cycleCount ), TRUE );
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1160,7 +1167,7 @@ class Convert
|
||||
|
||||
if ( \IPSUtf8\Session::i()->current_table AND isset( \IPSUtf8\Session::i()->tables[ \IPSUtf8\Session::i()->current_table ] ) )
|
||||
{
|
||||
/* Table selected and convertion in progress */
|
||||
/* Table selected and conversion in progress */
|
||||
$table = \IPSUtf8\Session::i()->tables[ \IPSUtf8\Session::i()->current_table ];
|
||||
|
||||
static::log( "Continuing with " . $table['name'] . ' (PKEY: ' . \IPSUtf8\Session::i()->current_pkey . ')' );
|
||||
@@ -1502,6 +1509,16 @@ class Convert
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the database is IPS4 already
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function databaseIsIPS4()
|
||||
{
|
||||
return (boolean) static::$db->checkForTable( 'core_members' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the DB is UTF8 already
|
||||
*
|
||||
@@ -1686,19 +1703,22 @@ class Convert
|
||||
*/
|
||||
public static function log( $message )
|
||||
{
|
||||
$file = THIS_PATH . '/tmp/log_' . date('Y-m-d') . '.cgi';
|
||||
$isNew = false;
|
||||
|
||||
if ( ! is_file( $file ) )
|
||||
if ( LOG )
|
||||
{
|
||||
$isNew = true;
|
||||
}
|
||||
|
||||
@file_put_contents( $file, "\n" . str_repeat( '-', 48 ) . "\n" . date('r') . "\n" . $message, FILE_APPEND );
|
||||
|
||||
if ( $isNew )
|
||||
{
|
||||
@chmod( $file, 0777 );
|
||||
$file = THIS_PATH . '/tmp/log_' . date('Y-m-d') . '.cgi';
|
||||
$isNew = false;
|
||||
|
||||
if ( ! is_file( $file ) )
|
||||
{
|
||||
$isNew = true;
|
||||
}
|
||||
|
||||
@file_put_contents( $file, "\n" . str_repeat( '-', 48 ) . "\n" . date('r') . "\n" . $message, FILE_APPEND );
|
||||
|
||||
if ( $isNew )
|
||||
{
|
||||
@chmod( $file, 0777 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user