newVersion(My::id(), dcCore::app()->plugins->moduleInfo(My::id(), 'version')); return static::$init; } public static function process(): bool { if (!static::$init) { return false; } try { self::growUp(); return true; } catch (Exception $e) { dcCore::app()->error->add($e->getMessage()); } return true; } /** * Upgrade plugin * * @return bool Upgrade done */ private static function growUp() { $current = dcCore::app()->getVersion(My::id()); // use short settings id if ($current && version_compare($current, '2022.12.22', '<')) { $record = dcCore::app()->con->select( 'SELECT * FROM ' . dcCore::app()->prefix . dcNamespace::NS_TABLE_NAME . ' ' . "WHERE setting_ns = 'translater' " ); while ($record->fetch()) { if (preg_match('/^translater_(.*?)$/', $record->setting_id, $match)) { $cur = dcCore::app()->con->openCursor(dcCore::app()->prefix . dcNamespace::NS_TABLE_NAME); $cur->setting_id = $match[1]; $cur->setting_ns = My::id(); $cur->update( "WHERE setting_id = '" . $record->setting_id . "' and setting_ns = 'translater' " . 'AND blog_id ' . (null === $record->blog_id ? 'IS NULL ' : ("= '" . dcCore::app()->con->escape($record->blog_id) . "' ")) ); } } return true; } return false; } }