name = __('UTF8-mb4 check'); $this->task = __('UTF8-mb4 compatibility check'); $this->step = __('Next: %s'); $this->step_task = __('Next'); $this->success = __('Check end'); $this->error = __('Some data will not be fully importable in a UTF8-mb4 database. You need to reduce them before.'); $this->description = __('Check various data for compatibility with UTF8-mb4 (full UTF8 encoding storage) before exporting and importing them in a new UTF8-mb4 MySQL database.'); } public function execute() { $this->code = $this->checkUtf8mb4($this->code); return $this->code ?: true; } public function task() { return $this->code ? $this->step_task : $this->task; } public function step() { return $this->code ? '

'.$this->list.'

' : null; } public function success() { return $this->code ? sprintf($this->step, $this->step_task) : $this->success; } public function header() { return sprintf($this->step, $this->step_task); } protected function checkUtf8mb4($code=null) { switch ($code) { case null: case 0: # check posts $this->list = __('All post URLs are importable in UTF8-mb4 database'); $rs = $this->core->con->select( 'SELECT post_id, post_type, post_title, post_url, LENGTH(post_url) AS xlen FROM '.$this->core->prefix.'post '. 'WHERE LENGTH(post_url) > '.UTF8MB4_MAXLEN.' ORDER BY post_id', true); if (!$rs->isEmpty()) { $this->list = '

'. sprintf(__('%s post URLs are longer than %d characters:'),$rs->count(),UTF8MB4_MAXLEN).'

'. '
'. ''. ''. ''; while ($rs->fetch()) { $this->list .= ''. ''. ''. ''; } $this->list .= '
'.__('Title').''.__('URL Length').'
'. html::escapeHTML($rs->post_title).''.$rs->xlen.'
'. '
'; } $code++; break; case 1: # check pings $this->list = __('All ping URLs are importable in UTF8-mb4 database'); $rs = $this->core->con->select( 'SELECT post_id, ping_url, LENGTH(ping_url) AS xlen FROM '.$this->core->prefix.'ping '. 'WHERE LENGTH(ping_url) > '.UTF8MB4_MAXLEN.' ORDER BY post_id', true); if (!$rs->isEmpty()) { $this->list = '

'. sprintf(__('%s ping URLs are longer than %d characters:'),$rs->count(),UTF8MB4_MAXLEN).'

'. '
'. ''. ''. ''; while ($rs->fetch()) { $this->list .= ''. ''. ''. ''; } $this->list .= '
'.__('Ping URL').''.__('URL Length').'
'. html::escapeHTML($rs->ping_url).''.$rs->xlen.'
'. '
'; } $code++; break; case 2: # check meta $this->list = __('All meta IDs are importable in UTF8-mb4 database'); $rs = $this->core->con->select( 'SELECT meta_id, meta_type, LENGTH(meta_id) AS xlen FROM '.$this->core->prefix.'meta '. 'WHERE LENGTH(meta_id) > '.UTF8MB4_MAXLEN.' ORDER BY meta_id', true); if (!$rs->isEmpty()) { $this->list = '

'. sprintf(__('%s meta IDs are longer than %d characters:'),$rs->count(),UTF8MB4_MAXLEN).'

'. '
'. ''. ''. ''. ''; while ($rs->fetch()) { $this->list .= ''. ''. ''. ''. ''; } $this->list .= '
'.__('Meta ID').''.__('Type').''.__('Length').'
'. ($rs->meta_type == 'tag' ? '' : ''). html::escapeHTML($rs->meta_id).($rs->meta_type == 'tag' ? '' : '').''.$rs->meta_type.''.$rs->xlen.'
'. '
'; } $code++; break; case 3: # check categories $this->list = __('All Category URLs are importable in UTF8-mb4 database'); $rs = $this->core->con->select( 'SELECT cat_id, cat_title, cat_url, LENGTH(cat_url) AS xlen FROM '.$this->core->prefix.'category '. 'WHERE LENGTH(cat_url) > '.UTF8MB4_MAXLEN.' ORDER BY cat_id', true); if (!$rs->isEmpty()) { $this->list = '

'. sprintf(__('%s category URLs are longer than %d characters:'),$rs->count(),UTF8MB4_MAXLEN).'

'. '
'. ''. ''. ''; while ($rs->fetch()) { $this->list .= ''. ''. ''. ''; } $this->list .= '
'.__('Title').''.__('URL Length').'
'. ''. html::escapeHTML($rs->cat_title).''.$rs->xlen.'
'. '
'; } $code++; break; case 4: # check prefs $this->list = __('All User preferences are importable in UTF8-mb4 database'); $rs = $this->core->con->select( 'SELECT pref_id, pref_ws, LENGTH(pref_id) AS xlen FROM '.$this->core->prefix.'pref '. 'WHERE LENGTH(pref_id) > '.UTF8MB4_MAXLEN.' ORDER BY pref_ws,pref_id', true); if (!$rs->isEmpty()) { $this->list = '

'. sprintf(__('%s User preference IDs are longer than %d characters:'),$rs->count(),UTF8MB4_MAXLEN).'

'. '
'. ''. ''. ''. ''; while ($rs->fetch()) { $this->list .= ''. ''. ''. ''. ''; } $this->list .= '
'.__('Preference ID').''.__('Workspace').''.__('Length').'
'.html::escapeHTML($rs->pref_id).''.html::escapeHTML($rs->pref_ws).''.$rs->xlen.'
'. '
'; } $code++; break; case 5: # check settings $this->list = __('All Blog settings are importable in UTF8-mb4 database'); $rs = $this->core->con->select( 'SELECT setting_id, setting_ns, LENGTH(setting_id) AS xlen FROM '.$this->core->prefix.'setting '. 'WHERE LENGTH(setting_id) > '.UTF8MB4_MAXLEN.' ORDER BY setting_ns,setting_id', true); if (!$rs->isEmpty()) { $this->list = '

'. sprintf(__('%s Blog setting IDs are longer than %d characters:'),$rs->count(),UTF8MB4_MAXLEN).'

'. '
'. ''. ''. ''. ''; while ($rs->fetch()) { $this->list .= ''. ''. ''. ''. ''; } $this->list .= '
'.__('Setting ID').''.__('Namespace').''.__('Length').'
'.html::escapeHTML($rs->setting_id).''.html::escapeHTML($rs->setting_ns).''.$rs->xlen.'
'. '
'; } $code++; break; default: # Ending check $code = null; break; } return $code; } }