diff --git a/composer.json b/composer.json index f7d2688bd5..6716ab9842 100644 --- a/composer.json +++ b/composer.json @@ -49,7 +49,7 @@ "phpmyadmin/motranslator": "^4.0", "phpmyadmin/shapefile": "^2.0", "phpmyadmin/sql-parser": "^5.0", - "phpmyadmin/twig-i18n-extension": "^2.0", + "phpmyadmin/twig-i18n-extension": "^2.0 || ^3.0", "phpseclib/phpseclib": "^2.0", "symfony/config": "^4.2.8", "symfony/dependency-injection": "^4.2.8", @@ -57,7 +57,7 @@ "symfony/polyfill-ctype": "^1.8", "symfony/polyfill-mbstring": "^1.3", "symfony/yaml": "^4.2.8", - "twig/twig": "^2.9", + "twig/twig": "^2.9 || ^3", "williamdes/mariadb-mysql-kbs": "^1.2" }, "conflict": { diff --git a/libraries/classes/Controllers/Server/ReplicationController.php b/libraries/classes/Controllers/Server/ReplicationController.php index dd48411aa0..635f9c4993 100644 --- a/libraries/classes/Controllers/Server/ReplicationController.php +++ b/libraries/classes/Controllers/Server/ReplicationController.php @@ -11,9 +11,6 @@ namespace PhpMyAdmin\Controllers\Server; use PhpMyAdmin\Controllers\AbstractController; use PhpMyAdmin\ReplicationGui; use Throwable; -use Twig_Error_Loader; -use Twig_Error_Runtime; -use Twig_Error_Syntax; /** * Server replications @@ -27,9 +24,9 @@ class ReplicationController extends AbstractController * * @return string HTML * @throws Throwable - * @throws Twig_Error_Loader - * @throws Twig_Error_Runtime - * @throws Twig_Error_Syntax + * @throws \Twig\Error\LoaderError + * @throws \Twig\Error\RuntimeError + * @throws \Twig\Error\SyntaxError */ public function index(array $params, ReplicationGui $replicationGui): string { diff --git a/libraries/classes/Controllers/Server/Status/StatusController.php b/libraries/classes/Controllers/Server/Status/StatusController.php index 53d78a32dc..78cdde2e2b 100644 --- a/libraries/classes/Controllers/Server/Status/StatusController.php +++ b/libraries/classes/Controllers/Server/Status/StatusController.php @@ -12,9 +12,6 @@ namespace PhpMyAdmin\Controllers\Server\Status; use PhpMyAdmin\ReplicationGui; use PhpMyAdmin\Util; use Throwable; -use Twig_Error_Loader; -use Twig_Error_Runtime; -use Twig_Error_Syntax; /** * Class StatusController @@ -27,9 +24,9 @@ class StatusController extends AbstractController * * @return string * @throws Throwable - * @throws Twig_Error_Loader - * @throws Twig_Error_Runtime - * @throws Twig_Error_Syntax + * @throws \Twig\Error\LoaderError + * @throws \Twig\Error\RuntimeError + * @throws \Twig\Error\SyntaxError */ public function index(ReplicationGui $replicationGui): string { diff --git a/libraries/classes/Display/Error.php b/libraries/classes/Display/Error.php index a60153285d..4e2a01c042 100644 --- a/libraries/classes/Display/Error.php +++ b/libraries/classes/Display/Error.php @@ -12,9 +12,6 @@ namespace PhpMyAdmin\Display; use PhpMyAdmin\Sanitize; use PhpMyAdmin\Template; use Throwable; -use Twig_Error_Loader; -use Twig_Error_Runtime; -use Twig_Error_Syntax; /** * Displays Error @@ -32,9 +29,9 @@ class Error * * @return string * @throws Throwable - * @throws Twig_Error_Loader - * @throws Twig_Error_Runtime - * @throws Twig_Error_Syntax + * @throws \Twig\Error\LoaderError + * @throws \Twig\Error\RuntimeError + * @throws \Twig\Error\SyntaxError */ public static function display( Template $template, diff --git a/libraries/classes/Display/Export.php b/libraries/classes/Display/Export.php index db02a5e7c8..df82615aaa 100644 --- a/libraries/classes/Display/Export.php +++ b/libraries/classes/Display/Export.php @@ -21,9 +21,6 @@ use PhpMyAdmin\Table; use PhpMyAdmin\Template; use PhpMyAdmin\Util; use Throwable; -use Twig_Error_Loader; -use Twig_Error_Runtime; -use Twig_Error_Syntax; /** * PhpMyAdmin\Display\Export class @@ -576,9 +573,9 @@ class Export * * @return string * @throws Throwable - * @throws Twig_Error_Loader - * @throws Twig_Error_Runtime - * @throws Twig_Error_Syntax + * @throws \Twig\Error\LoaderError + * @throws \Twig\Error\RuntimeError + * @throws \Twig\Error\SyntaxError */ private function getHtmlForCurrentAlias() { diff --git a/libraries/classes/Plugins/TwoFactor/Key.php b/libraries/classes/Plugins/TwoFactor/Key.php index cbb118c03f..1f1459b424 100644 --- a/libraries/classes/Plugins/TwoFactor/Key.php +++ b/libraries/classes/Plugins/TwoFactor/Key.php @@ -17,9 +17,6 @@ use Samyoul\U2F\U2FServer\U2FException; use Samyoul\U2F\U2FServer\U2FServer; use stdClass; use Throwable; -use Twig_Error_Loader; -use Twig_Error_Runtime; -use Twig_Error_Syntax; /** * Hardware key based two-factor authentication @@ -137,9 +134,9 @@ class Key extends TwoFactorPlugin * @return string HTML code * @throws U2FException * @throws Throwable - * @throws Twig_Error_Loader - * @throws Twig_Error_Runtime - * @throws Twig_Error_Syntax + * @throws \Twig\Error\LoaderError + * @throws \Twig\Error\RuntimeError + * @throws \Twig\Error\SyntaxError */ public function setup() { diff --git a/libraries/classes/Template.php b/libraries/classes/Template.php index 9b26a9eca3..2a9101f2ac 100644 --- a/libraries/classes/Template.php +++ b/libraries/classes/Template.php @@ -25,14 +25,8 @@ use PhpMyAdmin\Twig\UtilExtension; use RuntimeException; use Throwable; use Twig\Environment; -use Twig\Error\LoaderError; -use Twig\Error\RuntimeError; -use Twig\Error\SyntaxError; use Twig\Loader\FilesystemLoader; -use Twig_Error_Loader; -use Twig_Error_Runtime; -use Twig_Error_Syntax; -use Twig_TemplateWrapper; +use Twig\TemplateWrapper; /** * Class Template @@ -95,12 +89,12 @@ class Template * * @param string $templateName Template path name * - * @return Twig_TemplateWrapper - * @throws LoaderError - * @throws RuntimeError - * @throws SyntaxError + * @return TemplateWrapper + * @throws \Twig\Error\LoaderError + * @throws \Twig\Error\RuntimeError + * @throws \Twig\Error\SyntaxError */ - public function load(string $templateName): Twig_TemplateWrapper + public function load(string $templateName): TemplateWrapper { try { $template = static::$twig->load($templateName . '.twig'); @@ -131,9 +125,9 @@ class Template * * @return string * @throws Throwable - * @throws Twig_Error_Loader - * @throws Twig_Error_Runtime - * @throws Twig_Error_Syntax + * @throws \Twig\Error\LoaderError + * @throws \Twig\Error\RuntimeError + * @throws \Twig\Error\SyntaxError */ public function render(string $template, array $data = []): string { diff --git a/libraries/classes/Twig/I18n/TokenParserTrans.php b/libraries/classes/Twig/I18n/TokenParserTrans.php index adcf8c86e5..81d2a63cb5 100644 --- a/libraries/classes/Twig/I18n/TokenParserTrans.php +++ b/libraries/classes/Twig/I18n/TokenParserTrans.php @@ -11,7 +11,6 @@ namespace PhpMyAdmin\Twig\I18n; use PhpMyAdmin\Twig\Extensions\TokenParser\TransTokenParser; use Twig\Token; -use Twig_Error_Syntax; /** * Class TokenParserTrans @@ -27,7 +26,7 @@ class TokenParserTrans extends TransTokenParser * * @return NodeTrans * - * @throws Twig_Error_Syntax + * @throws \Twig\Error\SyntaxError */ public function parse(Token $token) { diff --git a/libraries/classes/UserPreferencesHeader.php b/libraries/classes/UserPreferencesHeader.php index cecbb05cdc..4d6b26f189 100644 --- a/libraries/classes/UserPreferencesHeader.php +++ b/libraries/classes/UserPreferencesHeader.php @@ -11,9 +11,6 @@ namespace PhpMyAdmin; use PhpMyAdmin\Config\Forms\User\UserFormList; use Throwable; -use Twig_Error_Loader; -use Twig_Error_Runtime; -use Twig_Error_Syntax; /** * Functions for displaying user preferences header @@ -30,9 +27,9 @@ class UserPreferencesHeader * * @return string * @throws Throwable - * @throws Twig_Error_Loader - * @throws Twig_Error_Runtime - * @throws Twig_Error_Syntax + * @throws \Twig\Error\LoaderError + * @throws \Twig\Error\RuntimeError + * @throws \Twig\Error\SyntaxError */ public static function getContent(Template $template, Relation $relation): string { @@ -46,9 +43,9 @@ class UserPreferencesHeader * * @return string * @throws Throwable - * @throws Twig_Error_Loader - * @throws Twig_Error_Runtime - * @throws Twig_Error_Syntax + * @throws \Twig\Error\LoaderError + * @throws \Twig\Error\RuntimeError + * @throws \Twig\Error\SyntaxError */ protected static function displayTabs(Template $template): string { diff --git a/scripts/generate-twig-cache b/scripts/generate-twig-cache index c343c4511f..ccacb93ebd 100644 --- a/scripts/generate-twig-cache +++ b/scripts/generate-twig-cache @@ -72,7 +72,11 @@ foreach (new \RecursiveIteratorIterator( // force compilation if ($file->isFile() && $file->getExtension() === 'twig') { $name = str_replace($tplDir . '/', '', $file->getPathname()); - $template = $twig->loadTemplate($name); + if (Environment::MAJOR_VERSION === 3) { + $template = $twig->loadTemplate($twig->getTemplateClass($name), $name); + } else { + $template = $twig->loadTemplate($name); + } // Generate line map $cacheFilename = $twigCache->generateKey($name, $twig->getTemplateClass($name)); diff --git a/templates/columns_definitions/column_virtuality.twig b/templates/columns_definitions/column_virtuality.twig index 96f020e136..d53f5d55e8 100644 --- a/templates/columns_definitions/column_virtuality.twig +++ b/templates/columns_definitions/column_virtuality.twig @@ -15,13 +15,11 @@ {% if char_editing == 'textarea' %} - {% apply spaceless %} - {% endapply %} {% else %}