Version 4.5.0
This commit is contained in:
1 parent
1a0c7fd3c2
commit
f79dcf067a
3791 files changed
+248032
-76372
No files matched your search
@@ -70,7 +70,7 @@ class Convert
|
||||
/**
|
||||
* @brief Create don't populate
|
||||
*/
|
||||
protected static $createOnly = array( 'content_cache_posts', 'content_cache_sigs', 'sessions', 'topic_views', 'search_keywords' );
|
||||
protected static $createOnly = array( 'content_cache_posts', 'content_cache_sigs', 'sessions', 'topic_views', 'search_keywords', 'core_share_links_log', 'spider_logs', 'inline_notifications' );
|
||||
|
||||
/**
|
||||
* @brief Problem Tables that can cause an error due to serialization while using "fast" mode
|
||||
@@ -92,7 +92,7 @@ class Convert
|
||||
if ( self::$instance === NULL )
|
||||
{
|
||||
static::$db = \IPSUtf8\Db::i();
|
||||
if ( defined( 'SOURCE_DB_CHARSET' ) AND SOURCE_DB_CHARSET !== NULL )
|
||||
if ( \defined( 'SOURCE_DB_CHARSET' ) AND SOURCE_DB_CHARSET !== NULL )
|
||||
{
|
||||
static::$db->set_charset( SOURCE_DB_CHARSET );
|
||||
}
|
||||
@@ -177,24 +177,24 @@ class Convert
|
||||
|
||||
/* Latin1 is actually cp1252, not ISO-8859-1 @link http://dev.mysql.com/doc/refman/5.0/en/charset-we-sets.html */
|
||||
/* But only if our document character set is ISO-8859-1 or UTF-8. Otherwise, we're using the slow method which needs to real charset despite what the table is set too */
|
||||
if ( $tableCharSet === 'latin1' AND in_array( mb_strtolower( $currentCharSet ), array( 'iso-8859-1', 'utf-8' ) ) )
|
||||
if ( $tableCharSet === 'latin1' AND \in_array( mb_strtolower( $currentCharSet ), array( 'iso-8859-1', 'utf-8' ) ) )
|
||||
{
|
||||
$currentCharSet = 'windows-1252';
|
||||
}
|
||||
|
||||
if ( defined( 'FORCE_CONVERT_CHARSET' ) AND FORCE_CONVERT_CHARSET !== NULL )
|
||||
if ( \defined( 'FORCE_CONVERT_CHARSET' ) AND FORCE_CONVERT_CHARSET !== NULL )
|
||||
{
|
||||
$currentCharSet = FORCE_CONVERT_CHARSET;
|
||||
}
|
||||
}
|
||||
|
||||
if ( !defined( 'SOURCE_DB_CHARSET' ) OR SOURCE_DB_CHARSET === NULL )
|
||||
if ( !\defined( 'SOURCE_DB_CHARSET' ) OR SOURCE_DB_CHARSET === NULL )
|
||||
{
|
||||
static::$db->set_charset( $tableCharSet );
|
||||
}
|
||||
|
||||
/* Create table only */
|
||||
if ( IPB_LOCK and in_array( $table['name'], static::$createOnly ) )
|
||||
if ( IPB_LOCK and \in_array( $table['name'], static::$createOnly ) )
|
||||
{
|
||||
static::log( 'No content conversion of ' . $table['name'] . ' required' );
|
||||
|
||||
@@ -213,7 +213,7 @@ class Convert
|
||||
|
||||
if ( $table === null )
|
||||
{
|
||||
if ( count( array_keys( \IPSUtf8\Session::i()->tables ) ) == count( array_keys( \IPSUtf8\Session::i()->completed_json ) ) )
|
||||
if ( \count( array_keys( \IPSUtf8\Session::i()->tables ) ) == \count( array_keys( \IPSUtf8\Session::i()->completed_json ) ) )
|
||||
{
|
||||
\IPSUtf8\Session::i()->status = 'completed';
|
||||
\IPSUtf8\Session::i()->save();
|
||||
@@ -224,7 +224,7 @@ class Convert
|
||||
}
|
||||
|
||||
/* Got any fields to convert? */
|
||||
if ( count( $convertCols ) === 0 )
|
||||
if ( \count( $convertCols ) === 0 )
|
||||
{
|
||||
/* No data to convert, lets repopulate the easy way! */
|
||||
$this->preInsert( $table );
|
||||
@@ -272,7 +272,7 @@ class Convert
|
||||
}
|
||||
|
||||
/* Latin1 or ISO-8559-1? */
|
||||
if ( ! in_array( $table['name'], static::$problemTables ) AND ( in_array( $tableCharSet, $this->getMysqlCharSets() ) ) and ( \IPSUtf8\Session::i()->current_charset == 'utf-8' or \IPSUtf8\Session::i()->current_charset == 'iso-8859-1' ) AND ( !isset( $sessionData['force_conversion'] ) OR $sessionData['force_conversion'] !== 1 ) )
|
||||
if ( ! \in_array( $table['name'], static::$problemTables ) AND ( \in_array( $tableCharSet, $this->getMysqlCharSets() ) ) and ( \IPSUtf8\Session::i()->current_charset == 'utf-8' or \IPSUtf8\Session::i()->current_charset == 'iso-8859-1' ) AND ( !isset( $sessionData['force_conversion'] ) OR $sessionData['force_conversion'] !== 1 ) )
|
||||
{
|
||||
/* Convert the fast way! */
|
||||
$count = static::$utf->select( 'COUNT(*)', $table['name'] )->first();
|
||||
@@ -295,7 +295,7 @@ class Convert
|
||||
|
||||
foreach( array_keys( $table['definition']['columns'] ) as $col )
|
||||
{
|
||||
if ( in_array( $col, $convertCols ) )
|
||||
if ( \in_array( $col, $convertCols ) )
|
||||
{
|
||||
/* 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 */
|
||||
@@ -304,7 +304,7 @@ class Convert
|
||||
{
|
||||
$select[] = 'CAST( `' . $col . '` AS BINARY )';
|
||||
}
|
||||
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' ) ) )
|
||||
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' AND mb_substr( $columnCollation, 0, 5 ) == 'latin' )
|
||||
{
|
||||
@@ -336,12 +336,12 @@ class Convert
|
||||
}
|
||||
|
||||
$source_charset = 'latin1';
|
||||
if ( defined( 'SOURCE_DB_CHARSET' ) AND SOURCE_DB_CHARSET !== NULL )
|
||||
if ( \defined( 'SOURCE_DB_CHARSET' ) AND SOURCE_DB_CHARSET !== NULL )
|
||||
{
|
||||
$source_charset = SOURCE_DB_CHARSET;
|
||||
}
|
||||
|
||||
if ( defined( 'MULTI_NO_CMP' ) AND MULTI_NO_CMP === TRUE )
|
||||
if ( \defined( 'MULTI_NO_CMP' ) AND MULTI_NO_CMP === TRUE )
|
||||
{
|
||||
$select[] = "CONVERT(CONVERT(CONVERT(`{$col}` USING {$source_charset}) USING BINARY) USING {$using})";
|
||||
}
|
||||
@@ -385,7 +385,7 @@ class Convert
|
||||
$rows = static::$db->select(
|
||||
'*',
|
||||
$table['name'],
|
||||
array( \IPSUtf8\Session::i()->current_pkey . ' > ?', intval( $start ) ),
|
||||
array( \IPSUtf8\Session::i()->current_pkey . ' > ?', \intval( $start ) ),
|
||||
\IPSUtf8\Session::i()->current_pkey . ' ASC',
|
||||
( $limit ? array( 0, ( $limit - $convertCount ) ) : null )
|
||||
);
|
||||
@@ -404,14 +404,14 @@ class Convert
|
||||
);
|
||||
}
|
||||
|
||||
if ( !defined( 'FORCE_CONVERT_METHOD' ) OR FORCE_CONVERT_METHOD === NULL )
|
||||
if ( !\defined( 'FORCE_CONVERT_METHOD' ) OR FORCE_CONVERT_METHOD === NULL )
|
||||
{
|
||||
\IPSUtf8\Text\Charset::$method = 'internal';
|
||||
|
||||
/* Optimise for latin character sets */
|
||||
if ( function_exists( 'mb_convert_encoding' ) )
|
||||
if ( \function_exists( 'mb_convert_encoding' ) )
|
||||
{
|
||||
if ( in_array( strtolower( $currentCharSet ), array_map( 'strtolower', mb_list_encodings() ) ) )
|
||||
if ( \in_array( strtolower( $currentCharSet ), array_map( 'strtolower', mb_list_encodings() ) ) )
|
||||
{
|
||||
\IPSUtf8\Text\Charset::$method = 'mb';
|
||||
}
|
||||
@@ -419,7 +419,7 @@ class Convert
|
||||
}
|
||||
|
||||
$rowCount = 0;
|
||||
$gotRows = count( $rows );
|
||||
$gotRows = \count( $rows );
|
||||
$batch = array();
|
||||
$batchBytes = 0;
|
||||
$max = ( $limit ) ?: 250;
|
||||
@@ -464,7 +464,7 @@ class Convert
|
||||
{
|
||||
if ( isset( $row[ $col ] ) AND ! empty( $row[ $col ] ) )
|
||||
{
|
||||
$currentCharSet = ( defined( 'FORCE_CONVERT_CHARSET' ) AND FORCE_CONVERT_CHARSET != NULL ) ? FORCE_CONVERT_CHARSET : $currentCharSet;
|
||||
$currentCharSet = ( \defined( 'FORCE_CONVERT_CHARSET' ) AND FORCE_CONVERT_CHARSET != NULL ) ? FORCE_CONVERT_CHARSET : $currentCharSet;
|
||||
if ( static::isSerialized( $row[ $col ] ) AND \IPSUtf8\Text\Charset::i()->needsConverting( $row[ $col ], $currentCharSet, 'UTF-8' ) )
|
||||
{
|
||||
/* Store a copy in case it doesn't work */
|
||||
@@ -484,7 +484,7 @@ class Convert
|
||||
/* Something went wrong... maybe we can figure it out */
|
||||
$work = unserialize( $original );
|
||||
array_walk_recursive( $work, function ( &$input, $key ) use ( $currentCharSet, $tableCharSet ) {
|
||||
if ( function_exists( 'mb_detect_encoding' ) )
|
||||
if ( \function_exists( 'mb_detect_encoding' ) )
|
||||
{
|
||||
$encoding = mb_detect_encoding( $input );
|
||||
$input = \IPSUtf8\Text\Charset::i()->convert( $input, $encoding, 'UTF-8' );
|
||||
@@ -515,7 +515,7 @@ class Convert
|
||||
{
|
||||
if ( isset( $row[ $col ] ) AND ! empty( $row[ $col ] ) )
|
||||
{
|
||||
if ( $row[ $col ] === null OR ! is_numeric( $row[ $col ] ) )
|
||||
if ( $row[ $col ] === null OR !\is_numeric( $row[ $col ] ) )
|
||||
{
|
||||
$row[ $col ] = 0;
|
||||
}
|
||||
@@ -526,7 +526,7 @@ class Convert
|
||||
$tmp = $row; // Use a copy so the reference in array_walk doesn't overwrite the row to be inserted
|
||||
|
||||
/* Make sure it's an associative array as topic_views only has 1 column so DB driver returns an indexed array only */
|
||||
if ( is_array( $tmp ) )
|
||||
if ( \is_array( $tmp ) )
|
||||
{
|
||||
array_walk_recursive( $tmp, function( &$input, $key )
|
||||
{
|
||||
@@ -540,23 +540,23 @@ class Convert
|
||||
$nextBatch = null;
|
||||
|
||||
/* Give us an error margin to account for MySQL syntax */
|
||||
if ( $batchBytes > ( $this->_data['max_allowed_packet'] - ( ( $this->_data['max_allowed_packet'] / 100 ) * ( count( $batch ) * 0.3 ) ) ) )
|
||||
if ( $batchBytes > ( $this->_data['max_allowed_packet'] - ( ( $this->_data['max_allowed_packet'] / 100 ) * ( \count( $batch ) * 0.3 ) ) ) )
|
||||
{
|
||||
/* Remove last row */
|
||||
$nextBatch = array_pop( $batch );
|
||||
|
||||
static::log( "Max packet hit with " . $batchBytes . 'b with ' . count( $batch ) . ' rows' );
|
||||
static::log( "Max packet hit with " . $batchBytes . 'b with ' . \count( $batch ) . ' rows' );
|
||||
}
|
||||
|
||||
/* If we have moved the only row from $batch to $nextbatch, then process that now */
|
||||
if ( count( $nextBatch ) and ! count( $batch ) )
|
||||
if ( \count( $nextBatch ) and ! \count( $batch ) )
|
||||
{
|
||||
$batch = $nextBatch;
|
||||
$nextBatch = array();
|
||||
}
|
||||
|
||||
/* Got a batch to write? */
|
||||
if ( $nextBatch !== null OR ( count( $batch ) === $max ) OR ( $gotRows === count( $batch ) ) )
|
||||
if ( $nextBatch !== null OR ( \count( $batch ) === $max ) OR ( $gotRows === \count( $batch ) ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -573,8 +573,8 @@ class Convert
|
||||
$this->postInsert( $table );
|
||||
|
||||
/* Update counts */
|
||||
$sessionData['convertedCount'] += count( $batch );
|
||||
$convertCount += count( $batch );
|
||||
$sessionData['convertedCount'] += \count( $batch );
|
||||
$convertCount += \count( $batch );
|
||||
|
||||
if ( \IPSUtf8\Session::i()->current_pkey )
|
||||
{
|
||||
@@ -582,14 +582,14 @@ class Convert
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPSUtf8\Session::i()->current_row += count( $batch );
|
||||
\IPSUtf8\Session::i()->current_row += \count( $batch );
|
||||
}
|
||||
|
||||
\IPSUtf8\Session::i()->status = 'processing';
|
||||
\IPSUtf8\Session::i()->json = $sessionData;
|
||||
\IPSUtf8\Session::i()->save();
|
||||
|
||||
static::log( count( $batch ) . " rows batch inserted using conversion method: " . \IPSUtf8\Text\Charset::$method . ', last insert ID ' . $insertId );
|
||||
static::log( \count( $batch ) . " rows batch inserted using conversion method: " . \IPSUtf8\Text\Charset::$method . ', last insert ID ' . $insertId );
|
||||
|
||||
$batch = ( $nextBatch !== null ) ? array( $nextBatch ) : array();
|
||||
$batchBytes = 0;
|
||||
@@ -790,9 +790,9 @@ class Convert
|
||||
foreach( explode( ";", $currentLocale ) as $locale )
|
||||
{
|
||||
$parts = explode( "=", $locale );
|
||||
if( in_array( $parts[0], array( 'LC_ALL', 'LC_COLLATE', 'LC_CTYPE', 'LC_MONETARY', 'LC_NUMERIC', 'LC_TIME' ) ) )
|
||||
if( \in_array( $parts[0], array( 'LC_ALL', 'LC_COLLATE', 'LC_CTYPE', 'LC_MONETARY', 'LC_NUMERIC', 'LC_TIME' ) ) )
|
||||
{
|
||||
setlocale( constant( $parts[0] ), $parts[1] );
|
||||
setlocale( \constant( $parts[0] ), $parts[1] );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -979,7 +979,7 @@ class Convert
|
||||
|
||||
foreach( \IPSUtf8\Session::i()->tables as $name => $data )
|
||||
{
|
||||
if ( in_array( $name, $this->getNonUtf8CollationTables() ) )
|
||||
if ( \in_array( $name, $this->getNonUtf8CollationTables() ) )
|
||||
{
|
||||
/* Skip if it's an _old table */
|
||||
if( mb_substr( $name, -4 ) == '_old' )
|
||||
@@ -990,72 +990,37 @@ class Convert
|
||||
$cols = static::getConvertableColumns( $data['name'] );
|
||||
$tableData = \IPSUtf8\Session::i()->tables[ $data['name'] ];
|
||||
|
||||
if ( count( $cols ) )
|
||||
if ( \count( $cols ) )
|
||||
{
|
||||
$dropIndexes = array();
|
||||
$addIndexes = array();
|
||||
$modify = array();
|
||||
$hasUnique = FALSE;
|
||||
|
||||
/* Changing collation can cause issues for duplicate entries in unique keys */
|
||||
if ( isset( $tableData['definition']['indexes'] ) )
|
||||
{
|
||||
foreach( $tableData['definition']['indexes'] as $key => $index )
|
||||
{
|
||||
if ( $index['type'] === 'unique' OR $index['type'] === 'primary' )
|
||||
{
|
||||
/* Make sure none of the columns in this index are auto_increment */
|
||||
foreach( $index['columns'] AS $k => $idxcol )
|
||||
{
|
||||
if ( $tableData['definition']['columns'][ $idxcol ]['auto_increment'] === TRUE )
|
||||
{
|
||||
continue 2;
|
||||
}
|
||||
}
|
||||
|
||||
if ( static::$db->checkForIndex( $name, $key ) )
|
||||
{
|
||||
$hasUnique = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* We don't need to drop any indexes - just create a copy of the table and insert ignore */
|
||||
if ( $hasUnique === TRUE )
|
||||
{
|
||||
/* 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 . "` DEFAULT CHARACTER SET " . $charset . " COLLATE " . $collation );
|
||||
}
|
||||
catch( \IPSUtf8\Db\Exception $e )
|
||||
{
|
||||
/* Did not work - try the long way */
|
||||
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." );
|
||||
/* Previously we used a raw create table query to create a copy, however this does not check index lengths. Leaving this for reference. */
|
||||
//static::$utf->query( "CREATE TABLE `" . static::$db->prefix . $name . "` LIKE `" . static::$db->prefix . $name . "_temp`" );
|
||||
static::$db->createTable( $this->checkTable( $tableData['definition'] ) );
|
||||
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" );
|
||||
}
|
||||
}
|
||||
else
|
||||
/* 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 . "` DEFAULT CHARACTER SET " . $charset . " COLLATE " . $collation );
|
||||
}
|
||||
catch( \IPSUtf8\Db\Exception $e )
|
||||
{
|
||||
/* Did not work - try the long way */
|
||||
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." );
|
||||
/* Previously we used a raw create table query to create a copy, however this does not check index lengths. Leaving this for reference. */
|
||||
//static::$utf->query( "CREATE TABLE `" . static::$db->prefix . $name . "` LIKE `" . static::$db->prefix . $name . "_temp`" );
|
||||
static::$db->createTable( $this->checkTable( $tableData['definition'] ) );
|
||||
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" );
|
||||
}
|
||||
|
||||
if ( count( $cols ) )
|
||||
if ( \count( $cols ) )
|
||||
{
|
||||
foreach( $cols as $col )
|
||||
{
|
||||
@@ -1063,14 +1028,14 @@ class Convert
|
||||
{
|
||||
$colData = $tableData['definition']['columns'][ $col ];
|
||||
|
||||
$modify[] = " MODIFY `" . $col . "` " . $colData['type'] . ( ( is_numeric( $colData['length'] ) AND $colData['length'] > 0 ) ? "(" . $colData['length'] . ")" : '' ) . " CHARACTER SET " . $charset . " COLLATE " . $collation;
|
||||
$modify[] = " MODIFY `" . $col . "` " . $colData['type'] . ( ( \is_numeric( $colData['length'] ) AND $colData['length'] > 0 ) ? "(" . $colData['length'] . ")" : '' ) . " CHARACTER SET " . $charset . " COLLATE " . $collation;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( count( $cols ) )
|
||||
if ( \count( $cols ) )
|
||||
{
|
||||
if ( count( $modify ) )
|
||||
if ( \count( $modify ) )
|
||||
{
|
||||
$query = "ALTER TABLE `" . static::$db->prefix . $name . "` " . implode( ',', $modify );
|
||||
|
||||
@@ -1078,7 +1043,7 @@ class Convert
|
||||
static::$utf->query( $query );
|
||||
}
|
||||
|
||||
if ( /*count( $modify ) and*/ count( $addIndexes ) )
|
||||
if ( /*count( $modify ) and*/ \count( $addIndexes ) )
|
||||
{
|
||||
$query = "ALTER TABLE `" . static::$db->prefix . $name . "` " . implode( ',', $addIndexes );
|
||||
|
||||
@@ -1212,13 +1177,13 @@ class Convert
|
||||
$nonUtf8Tables = array_keys( \IPSUtf8\Session::i()->tables );//$this->getNonUtf8Tables();
|
||||
|
||||
/* No table selected */
|
||||
if ( is_array( $nonUtf8Tables ) and count( $nonUtf8Tables ) )
|
||||
if ( \is_array( $nonUtf8Tables ) and \count( $nonUtf8Tables ) )
|
||||
{
|
||||
if ( is_array( \IPSUtf8\Session::i()->completed_json ) )
|
||||
if ( \is_array( \IPSUtf8\Session::i()->completed_json ) )
|
||||
{
|
||||
$diff = array_diff( $nonUtf8Tables, array_keys( \IPSUtf8\Session::i()->completed_json ) );
|
||||
|
||||
if ( count( $diff ) )
|
||||
if ( \count( $diff ) )
|
||||
{
|
||||
$table = \IPSUtf8\Session::i()->tables[ array_shift( $diff ) ];
|
||||
}
|
||||
@@ -1309,7 +1274,7 @@ class Convert
|
||||
{
|
||||
$thisLength = ( isset( $index['length'][ $i ] ) ) ? $index['length'][ $i ] : ( ( (int) $definition['columns'][ $column ]['length'] or empty( $definition['columns'][ $column ]['length'] ) ) ? $definition['columns'][ $column ]['length'] : 250 );
|
||||
|
||||
$isText = in_array( mb_strtolower( $definition['columns'][ $column ]['type'] ), array( 'mediumtext', 'text' ) );
|
||||
$isText = \in_array( mb_strtolower( $definition['columns'][ $column ]['type'] ), array( 'mediumtext', 'text' ) );
|
||||
|
||||
if ( $hasText === false and $isText === true )
|
||||
{
|
||||
@@ -1328,7 +1293,7 @@ class Convert
|
||||
{
|
||||
$thisLength = ( isset( $index['length'][ $i ] ) ) ? $index['length'][ $i ] : ( (int) $definition['columns'][ $column ]['length'] ? $definition['columns'][ $column ]['length'] : 250 );
|
||||
|
||||
if ( isset( $definition['columns'][ $column ] ) and ( ( ! empty( $thisLength ) or in_array( mb_strtolower( $definition['columns'][ $column ]['type'] ), array( 'mediumtext', 'text' ) ) ) ) )
|
||||
if ( isset( $definition['columns'][ $column ] ) and ( ( ! empty( $thisLength ) or \in_array( mb_strtolower( $definition['columns'][ $column ]['type'] ), array( 'mediumtext', 'text' ) ) ) ) )
|
||||
{
|
||||
/* Column name, column length, column type */
|
||||
$needsFixing[ $key ][ $i ] = array( $column, $thisLength, $definition['columns'][ $column ]['type'] );
|
||||
@@ -1340,7 +1305,7 @@ class Convert
|
||||
}
|
||||
}
|
||||
|
||||
if ( count( $needsFixing ) )
|
||||
if ( \count( $needsFixing ) )
|
||||
{
|
||||
foreach( $needsFixing as $key => $i )
|
||||
{
|
||||
@@ -1362,7 +1327,7 @@ class Convert
|
||||
/* Apply debt if we have any. We do not reduce integers */
|
||||
foreach( $i as $x => $vals )
|
||||
{
|
||||
if ( in_array( mb_strtoupper( $vals[2] ), array_keys( static::$numericCols ) ) )
|
||||
if ( \in_array( mb_strtoupper( $vals[2] ), array_keys( static::$numericCols ) ) )
|
||||
{
|
||||
$debt += $vals[1];
|
||||
}
|
||||
@@ -1382,7 +1347,7 @@ class Convert
|
||||
$vals[1] = 250;
|
||||
}
|
||||
|
||||
if ( in_array( mb_strtoupper( $vals[2] ), array_keys( static::$numericCols ) ) )
|
||||
if ( \in_array( mb_strtoupper( $vals[2] ), array_keys( static::$numericCols ) ) )
|
||||
{
|
||||
/* Preserve col len where possible but if the column length is greater than subpart allowed, NULL the length
|
||||
otherwise MySQL will complain as you cannot use subpart on non-string column. */
|
||||
@@ -1402,9 +1367,9 @@ class Convert
|
||||
|
||||
foreach( $i as $x => $vals )
|
||||
{
|
||||
if ( in_array( mb_strtolower( $vals[2] ), static::$convertCols ) AND $definition['columns'][ $definition['indexes'][ $key ]['columns'][ $x ] ]['length'] != $vals[1] )
|
||||
if ( \in_array( mb_strtolower( $vals[2] ), static::$convertCols ) AND $definition['columns'][ $definition['indexes'][ $key ]['columns'][ $x ] ]['length'] != $vals[1] )
|
||||
{
|
||||
$definition['indexes'][ $key ]['length'][ $x ] = intval( $vals[1] );
|
||||
$definition['indexes'][ $key ]['length'][ $x ] = \intval( $vals[1] );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1503,7 +1468,7 @@ class Convert
|
||||
|
||||
foreach( $table['definition']['columns'] as $col => $val )
|
||||
{
|
||||
if ( in_array( mb_strtolower( $val['type'] ), array( 'mediumtext', 'text' ) ) )
|
||||
if ( \in_array( mb_strtolower( $val['type'] ), array( 'mediumtext', 'text' ) ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -1529,7 +1494,7 @@ class Convert
|
||||
{
|
||||
$total++;
|
||||
|
||||
if ( in_array( mb_strtolower( $val['type'] ), array( 'varchar' ) ) )
|
||||
if ( \in_array( mb_strtolower( $val['type'] ), array( 'varchar' ) ) )
|
||||
{
|
||||
$var++;
|
||||
}
|
||||
@@ -1580,7 +1545,7 @@ class Convert
|
||||
/* Best check the tables, then */
|
||||
$json = \IPSUtf8\Session::i()->json;
|
||||
|
||||
if ( count( $this->getNonUtf8Tables() ) )
|
||||
if ( \count( $this->getNonUtf8Tables() ) )
|
||||
{
|
||||
$yeahProbably = false;
|
||||
}
|
||||
@@ -1651,7 +1616,7 @@ class Convert
|
||||
|
||||
foreach( array_keys( \IPSUtf8\Session::i()->tables ) as $table )
|
||||
{
|
||||
static::$rowsToConvert += intval( \IPSUtf8\Session::i()->tables[ $table ]['count'] );
|
||||
static::$rowsToConvert += \intval( \IPSUtf8\Session::i()->tables[ $table ]['count'] );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1673,7 +1638,7 @@ class Convert
|
||||
foreach( \IPSUtf8\Session::i()->tables as $table => $definition )
|
||||
{
|
||||
/* If the table itself is not utf8_unicode_ci, don't bother check columns */
|
||||
if ( $definition['definition']['collation'] AND !in_array( $definition['definition']['collation'], array( 'utf8_unicode_ci', 'utf8mb4_unicode_ci' ) ) )
|
||||
if ( $definition['definition']['collation'] AND !\in_array( $definition['definition']['collation'], array( 'utf8_unicode_ci', 'utf8mb4_unicode_ci' ) ) )
|
||||
{
|
||||
static::$nonUtf8Collations[] = $table;
|
||||
continue;
|
||||
@@ -1681,7 +1646,7 @@ class Convert
|
||||
|
||||
foreach( $definition['definition']['columns'] as $name => $column )
|
||||
{
|
||||
if ( $column['collation'] and ! in_array( $column['collation'], array( 'utf8_unicode_ci', 'utf8mb4_unicode_ci' ) ) )
|
||||
if ( $column['collation'] and ! \in_array( $column['collation'], array( 'utf8_unicode_ci', 'utf8mb4_unicode_ci' ) ) )
|
||||
{
|
||||
static::$nonUtf8Collations[] = $table;
|
||||
break;
|
||||
@@ -1712,10 +1677,10 @@ class Convert
|
||||
|
||||
foreach( $json['charSets'] as $charSet => $tablesArray )
|
||||
{
|
||||
$data[] = count( $tablesArray ) . ' tables are ' . $charSet;
|
||||
$data[] = \count( $tablesArray ) . ' tables are ' . $charSet;
|
||||
}
|
||||
|
||||
$data[] = count( $this->getNonUtf8CollationTables() ) . " tables have incorrect collations";
|
||||
$data[] = \count( $this->getNonUtf8CollationTables() ) . " tables have incorrect collations";
|
||||
$data[] = "Can use 'dump' method: " . var_export( $this->canDump(), true );
|
||||
|
||||
return $data;
|
||||
@@ -1771,7 +1736,7 @@ class Convert
|
||||
*/
|
||||
public static function getNumericColumns( $name )
|
||||
{
|
||||
if ( ! is_string( $name ) )
|
||||
if ( ! \is_string( $name ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -1781,7 +1746,7 @@ class Convert
|
||||
|
||||
foreach( $table['definition']['columns'] as $col => $val )
|
||||
{
|
||||
if ( in_array( mb_strtolower( $val['type'] ), static::$numericCols ) )
|
||||
if ( \in_array( mb_strtolower( $val['type'] ), static::$numericCols ) )
|
||||
{
|
||||
$return[] = $val['name'];
|
||||
}
|
||||
@@ -1798,7 +1763,7 @@ class Convert
|
||||
*/
|
||||
public static function getConvertableColumns( $name )
|
||||
{
|
||||
if ( ! is_string( $name ) )
|
||||
if ( ! \is_string( $name ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -1808,7 +1773,7 @@ class Convert
|
||||
|
||||
foreach( $table['definition']['columns'] as $col => $val )
|
||||
{
|
||||
if ( in_array( mb_strtolower( $val['type'] ), static::$convertCols ) )
|
||||
if ( \in_array( mb_strtolower( $val['type'] ), static::$convertCols ) )
|
||||
{
|
||||
$return[] = $val['name'];
|
||||
}
|
||||
@@ -1840,7 +1805,7 @@ class Convert
|
||||
if (
|
||||
( $tablesOk ) AND
|
||||
( \IPSUtf8\Session::i()->current_charset == 'utf-8' or \IPSUtf8\Session::i()->current_charset == 'iso-8859-1' ) AND
|
||||
( ( is_callable( 'exec' ) AND false === stripos( ini_get( 'disable_functions' ), 'exec' ) ) )
|
||||
( ( \is_callable( 'exec' ) AND false === stripos( ini_get( 'disable_functions' ), 'exec' ) ) )
|
||||
)
|
||||
{
|
||||
try
|
||||
@@ -1852,7 +1817,7 @@ class Convert
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( ! array( $output ) or ! count( $output ) or ( ! stristr( implode( "\n", $output ), 'latin' ) ) )
|
||||
if ( ! array( $output ) or ! \count( $output ) or ( ! stristr( implode( "\n", $output ), 'latin' ) ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user