2 namespace wcf\acp\page
;
3 use wcf\data\
object\type\ObjectTypeCache
;
4 use wcf\page\AbstractPage
;
8 * Show the list of available rebuild data options.
11 * @copyright 2001-2019 WoltLab GmbH
12 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
13 * @package WoltLabSuite\Core\Acp\Page
15 class RebuildDataPage
extends AbstractPage
{
19 public $activeMenuItem = 'wcf.acp.menu.link.maintenance.rebuildData';
22 * disallow any rebuild actions unless `wcfN_user_storage` uses `utf8mb4`
25 public $convertEncoding = false;
30 public $neededPermissions = ['admin.management.canRebuildData'];
36 public $objectTypes = [];
41 public function readData() {
45 $this->objectTypes
= ObjectTypeCache
::getInstance()->getObjectTypes('com.woltlab.wcf.rebuildData');
48 uasort($this->objectTypes
, function ($a, $b) {
49 $niceValueA = ($a->nicevalue ?
: 0);
50 $niceValueB = ($b->nicevalue ?
: 0);
52 if ($niceValueA < $niceValueB) {
55 else if ($niceValueA > $niceValueB) {
62 // We're disallowing rebuilding any other data unless the
63 // database encoding has been converted to utf8mb4. The
64 // user_storage table is used as a reference, as it is the
65 // last WCF table that holds a varchar column.
67 // Querying the columns for each table to reliably detect
68 // the need of an encoding conversion isn't an option, as
69 // it turns out to be super slow to retrieve this data.
70 $sql = "SHOW FULL COLUMNS FROM wcf".WCF_N
."_user_storage";
71 $statement = WCF
::getDB()->prepareStatement($sql);
72 $statement->execute();
73 while ($row = $statement->fetchArray()) {
74 if ($row['Field'] === 'field') {
75 if (preg_match('~^utf8mb4~', $row['Collation'])) {
76 $this->convertEncoding
= true;
85 public function assignVariables() {
86 parent
::assignVariables();
88 WCF
::getTPL()->assign([
89 'convertEncoding' => $this->convertEncoding
,
90 'objectTypes' => $this->objectTypes
,