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).'
'. ''.__('Title').' | '. ''.__('URL Length').' | '; while ($rs->fetch()) { $this->list .= '
---|---|
'. html::escapeHTML($rs->post_title).' | '. ''.$rs->xlen.' | '. '
'. sprintf(__('%s ping URLs are longer than %d characters:'),$rs->count(),UTF8MB4_MAXLEN).'
'. ''.__('Ping URL').' | '. ''.__('URL Length').' | '; while ($rs->fetch()) { $this->list .= '
---|---|
'. html::escapeHTML($rs->ping_url).' | '. ''.$rs->xlen.' | '. '
'. sprintf(__('%s meta IDs are longer than %d characters:'),$rs->count(),UTF8MB4_MAXLEN).'
'. ''.__('Meta ID').' | '. ''.__('Type').' | '. ''.__('Length').' | '; while ($rs->fetch()) { $this->list .= '
---|---|---|
'. ($rs->meta_type == 'tag' ? '' : ''). html::escapeHTML($rs->meta_id).($rs->meta_type == 'tag' ? '' : '').' | '. ''.$rs->meta_type.' | '. ''.$rs->xlen.' | '. '
'. sprintf(__('%s category URLs are longer than %d characters:'),$rs->count(),UTF8MB4_MAXLEN).'
'. ''.__('Title').' | '. ''.__('URL Length').' | '; while ($rs->fetch()) { $this->list .= '
---|---|
'. ''. html::escapeHTML($rs->cat_title).' | '. ''.$rs->xlen.' | '. '
'. sprintf(__('%s User preference IDs are longer than %d characters:'),$rs->count(),UTF8MB4_MAXLEN).'
'. ''.__('Preference ID').' | '. ''.__('Workspace').' | '. ''.__('Length').' | '; while ($rs->fetch()) { $this->list .= '
---|---|---|
'.html::escapeHTML($rs->pref_id).' | '. ''.html::escapeHTML($rs->pref_ws).' | '. ''.$rs->xlen.' | '. '
'. sprintf(__('%s Blog setting IDs are longer than %d characters:'),$rs->count(),UTF8MB4_MAXLEN).'
'. ''.__('Setting ID').' | '. ''.__('Namespace').' | '. ''.__('Length').' | '; while ($rs->fetch()) { $this->list .= '
---|---|---|
'.html::escapeHTML($rs->setting_id).' | '. ''.html::escapeHTML($rs->setting_ns).' | '. ''.$rs->xlen.' | '. '