Skip to content

Commit

Permalink
Merge pull request phpmyadmin#19507 from MauricioFauth/tcpdf-language…
Browse files Browse the repository at this point in the history
…-array

Replace $GLOBALS['l'] with TCPDF::setLanguageArray()
  • Loading branch information
MauricioFauth authored Jan 11, 2025
2 parents 5a10863 + 5ac0d3c commit db2635c
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 27 deletions.
12 changes: 0 additions & 12 deletions libraries/classes/Language.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace PhpMyAdmin;

use function __;
use function _bindtextdomain;
use function _setlocale;
use function _textdomain;
Expand Down Expand Up @@ -192,17 +191,6 @@ public function activate(): void
$GLOBALS['text_dir'] = 'ltr';
}

/* TCPDF */
$GLOBALS['l'] = [];

/* TCPDF settings */
$GLOBALS['l']['a_meta_charset'] = 'UTF-8';
$GLOBALS['l']['a_meta_dir'] = $GLOBALS['text_dir'];
$GLOBALS['l']['a_meta_language'] = $this->code;

/* TCPDF translations */
$GLOBALS['l']['w_page'] = __('Page number:');

/* Show possible warnings from langauge selection */
LanguageManager::getInstance()->showWarnings();
}
Expand Down
6 changes: 6 additions & 0 deletions libraries/classes/Pdf.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ public function __construct(
$this->AddFont('DejaVuSans', 'B', 'dejavusansb.php');
$this->setFont(self::PMA_PDF_FONT, '', 14);
$this->setFooterFont([self::PMA_PDF_FONT, '', 14]);
$this->setLanguageArray([
'a_meta_charset' => 'UTF-8',
'a_meta_dir' => $GLOBALS['text_dir'],
'a_meta_language' => $GLOBALS['lang'],
'w_page' => __('Page number:'),
]);
}

/**
Expand Down
15 changes: 0 additions & 15 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -22180,21 +22180,6 @@ parameters:
count: 1
path: libraries/classes/Language.php

-
message: "#^Cannot access offset 'a_meta_dir' on mixed\\.$#"
count: 1
path: libraries/classes/Language.php

-
message: "#^Cannot access offset 'a_meta_language' on mixed\\.$#"
count: 1
path: libraries/classes/Language.php

-
message: "#^Cannot access offset 'w_page' on mixed\\.$#"
count: 1
path: libraries/classes/Language.php

-
message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
count: 1
Expand Down
1 change: 1 addition & 0 deletions test/classes/AbstractTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ protected function setUp(): void
$GLOBALS['db'] = '';
$GLOBALS['table'] = '';
$GLOBALS['PMA_PHP_SELF'] = '';
$GLOBALS['lang'] = 'en';

// Config before DBI
$this->setGlobalConfig();
Expand Down
1 change: 1 addition & 0 deletions test/classes/Html/SecurityTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ protected function tearDown(): void

public function testInjectCodeUsingTemplate(): void
{
$GLOBALS['lang'] = '';
self::assertSame('?db=%3Cscript%3Ealert%28%27%26%3D%21%3A%3B%27%29%3B%3C%2Fscr'
. 'ipt%3E&table=%26mytable%3E1%3F&server=12'
. "\n"
Expand Down

0 comments on commit db2635c

Please sign in to comment.