Remove Message::display method
Related to https://github.com/phpmyadmin/phpmyadmin/issues/16258. Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
This commit is contained in:
parent
78e1b4055d
commit
3f01cd8c13
@ -74,12 +74,12 @@ class TrackingController extends AbstractController
|
||||
|
||||
if (isset($_POST['delete_tracking'], $_POST['table'])) {
|
||||
Tracker::deleteTracking($db, $_POST['table']);
|
||||
Message::success(
|
||||
echo Message::success(
|
||||
__('Tracking data deleted successfully.')
|
||||
)->display();
|
||||
)->getDisplay();
|
||||
} elseif (isset($_POST['submit_create_version'])) {
|
||||
$this->tracking->createTrackingForMultipleTables($_POST['selected']);
|
||||
Message::success(
|
||||
echo Message::success(
|
||||
sprintf(
|
||||
__(
|
||||
'Version %1$s was created for selected tables,'
|
||||
@ -87,16 +87,16 @@ class TrackingController extends AbstractController
|
||||
),
|
||||
htmlspecialchars($_POST['version'])
|
||||
)
|
||||
)->display();
|
||||
)->getDisplay();
|
||||
} elseif (isset($_POST['submit_mult'])) {
|
||||
if (! empty($_POST['selected_tbl'])) {
|
||||
if ($_POST['submit_mult'] === 'delete_tracking') {
|
||||
foreach ($_POST['selected_tbl'] as $table) {
|
||||
Tracker::deleteTracking($db, $table);
|
||||
}
|
||||
Message::success(
|
||||
echo Message::success(
|
||||
__('Tracking data deleted successfully.')
|
||||
)->display();
|
||||
)->getDisplay();
|
||||
} elseif ($_POST['submit_mult'] === 'track') {
|
||||
echo $this->template->render('create_tracking_version', [
|
||||
'route' => '/database/tracking',
|
||||
@ -111,9 +111,9 @@ class TrackingController extends AbstractController
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
Message::notice(
|
||||
echo Message::notice(
|
||||
__('No tables selected.')
|
||||
)->display();
|
||||
)->getDisplay();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -54,7 +54,7 @@ class TwoFactorController extends AbstractController
|
||||
}
|
||||
|
||||
$twoFactor->configure('');
|
||||
Message::rawNotice(__('Two-factor authentication has been removed.'))->display();
|
||||
echo Message::rawNotice(__('Two-factor authentication has been removed.'))->getDisplay();
|
||||
} elseif (isset($_POST['2fa_configure'])) {
|
||||
if (! $twoFactor->configure($_POST['2fa_configure'])) {
|
||||
echo $this->template->render('preferences/two_factor/configure', [
|
||||
@ -65,7 +65,7 @@ class TwoFactorController extends AbstractController
|
||||
return;
|
||||
}
|
||||
|
||||
Message::rawNotice(__('Two-factor authentication has been configured.'))->display();
|
||||
echo Message::rawNotice(__('Two-factor authentication has been configured.'))->getDisplay();
|
||||
}
|
||||
|
||||
$backend = $twoFactor->getBackend();
|
||||
|
||||
@ -576,7 +576,7 @@ class Events
|
||||
exit;
|
||||
}
|
||||
|
||||
$message->display();
|
||||
echo $message->getDisplay();
|
||||
}
|
||||
|
||||
public function export(): void
|
||||
@ -628,6 +628,6 @@ class Events
|
||||
exit;
|
||||
}
|
||||
|
||||
$message->display();
|
||||
echo $message->getDisplay();
|
||||
}
|
||||
}
|
||||
|
||||
@ -356,7 +356,7 @@ class Qbe
|
||||
);
|
||||
$all_tables_count = $this->dbi->numRows($all_tables);
|
||||
if ($all_tables_count == 0) {
|
||||
Message::error(__('No tables found in database.'))->display();
|
||||
echo Message::error(__('No tables found in database.'))->getDisplay();
|
||||
exit;
|
||||
}
|
||||
// The tables list gets from MySQL
|
||||
|
||||
@ -220,7 +220,7 @@ class Routines
|
||||
exit;
|
||||
}
|
||||
|
||||
$message->display();
|
||||
echo $message->getDisplay();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1979,6 +1979,6 @@ class Routines
|
||||
exit;
|
||||
}
|
||||
|
||||
$message->display();
|
||||
echo $message->getDisplay();
|
||||
}
|
||||
}
|
||||
|
||||
@ -589,7 +589,7 @@ class Triggers
|
||||
exit;
|
||||
}
|
||||
|
||||
$message->display();
|
||||
echo $message->getDisplay();
|
||||
}
|
||||
|
||||
private function export(): void
|
||||
@ -645,6 +645,6 @@ class Triggers
|
||||
exit;
|
||||
}
|
||||
|
||||
$message->display();
|
||||
echo $message->getDisplay();
|
||||
}
|
||||
}
|
||||
|
||||
@ -659,9 +659,9 @@ class Export
|
||||
|
||||
/* Fail if we didn't find any plugin */
|
||||
if (empty($exportList)) {
|
||||
Message::error(
|
||||
echo Message::error(
|
||||
__('Could not load export plugins, please check your installation!')
|
||||
)->display();
|
||||
)->getDisplay();
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
@ -57,11 +57,11 @@ class Import
|
||||
|
||||
/* Fail if we didn't find any plugin */
|
||||
if (empty($importList)) {
|
||||
Message::error(
|
||||
echo Message::error(
|
||||
__(
|
||||
'Could not load import plugins, please check your installation!'
|
||||
)
|
||||
)->display();
|
||||
)->getDisplay();
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
@ -294,7 +294,7 @@ class ErrorHandler
|
||||
if (! headers_sent()) {
|
||||
$this->dispPageStart($error);
|
||||
}
|
||||
$error->display();
|
||||
echo $error->getDisplay();
|
||||
$this->dispPageEnd();
|
||||
exit;
|
||||
}
|
||||
|
||||
@ -59,16 +59,6 @@ class Menu
|
||||
$this->template = new Template();
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints the menu and the breadcrumbs
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function display()
|
||||
{
|
||||
echo $this->getDisplay();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the menu and the breadcrumbs as a string
|
||||
*
|
||||
|
||||
@ -23,7 +23,7 @@ use function strlen;
|
||||
* simple usage examples:
|
||||
* <code>
|
||||
* // display simple error message 'Error'
|
||||
* Message::error()->display();
|
||||
* echo Message::error()->getDisplay();
|
||||
*
|
||||
* // get simple success message 'Success'
|
||||
* $message = Message::success();
|
||||
@ -739,14 +739,6 @@ class Message
|
||||
return self::$level[$this->getNumber()];
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays the message in HTML
|
||||
*/
|
||||
public function display(): void
|
||||
{
|
||||
echo $this->getDisplay();
|
||||
}
|
||||
|
||||
/**
|
||||
* returns HTML code for displaying this message
|
||||
*
|
||||
|
||||
@ -152,9 +152,9 @@ class Pdf extends TCPDF
|
||||
// @codingStandardsIgnoreLine
|
||||
public function Error($error_message = '')
|
||||
{
|
||||
Message::error(
|
||||
echo Message::error(
|
||||
__('Error while creating PDF:') . ' ' . $error_message
|
||||
)->display();
|
||||
)->getDisplay();
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
@ -358,9 +358,9 @@ abstract class AuthenticationPlugin
|
||||
exit;
|
||||
}
|
||||
echo $this->template->render('login/header', ['theme' => $GLOBALS['PMA_Theme']]);
|
||||
Message::rawNotice(
|
||||
echo Message::rawNotice(
|
||||
__('You have enabled two factor authentication, please confirm your login.')
|
||||
)->display();
|
||||
)->getDisplay();
|
||||
echo $this->template->render('login/twofactor', [
|
||||
'form' => $twofactor->render(),
|
||||
'show_submit' => $twofactor->showSubmit(),
|
||||
|
||||
@ -108,13 +108,12 @@ class ImportXml extends ImportPlugin
|
||||
* The XML was malformed
|
||||
*/
|
||||
if ($xml === false) {
|
||||
Message::error(
|
||||
echo Message::error(
|
||||
__(
|
||||
'The XML file specified was either malformed or incomplete.'
|
||||
. ' Please correct the issue and try again.'
|
||||
)
|
||||
)
|
||||
->display();
|
||||
)->getDisplay();
|
||||
unset($xml);
|
||||
$GLOBALS['finished'] = false;
|
||||
|
||||
@ -173,13 +172,12 @@ class ImportXml extends ImportPlugin
|
||||
* The XML was malformed
|
||||
*/
|
||||
if ($db_name === null) {
|
||||
Message::error(
|
||||
echo Message::error(
|
||||
__(
|
||||
'The XML file specified was either malformed or incomplete.'
|
||||
. ' Please correct the issue and try again.'
|
||||
)
|
||||
)
|
||||
->display();
|
||||
)->getDisplay();
|
||||
unset($xml);
|
||||
$GLOBALS['finished'] = false;
|
||||
|
||||
|
||||
@ -66,10 +66,10 @@ class Routing
|
||||
/** @var Response $response */
|
||||
$response = $container->get(Response::class);
|
||||
$response->setHttpResponseCode(404);
|
||||
Message::error(sprintf(
|
||||
echo Message::error(sprintf(
|
||||
__('Error 404! The page %s was not found.'),
|
||||
'<code>' . htmlspecialchars($route) . '</code>'
|
||||
))->display();
|
||||
))->getDisplay();
|
||||
|
||||
return;
|
||||
}
|
||||
@ -78,7 +78,7 @@ class Routing
|
||||
/** @var Response $response */
|
||||
$response = $container->get(Response::class);
|
||||
$response->setHttpResponseCode(405);
|
||||
Message::error(__('Error 405! Request method not allowed.'))->display();
|
||||
echo Message::error(__('Error 405! Request method not allowed.'))->getDisplay();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@ -280,7 +280,7 @@ class Tracking
|
||||
*/
|
||||
if (count($data['ddlog']) == 0 && count($data['dmlog']) === 0) {
|
||||
$msg = Message::notice(__('No data'));
|
||||
$msg->display();
|
||||
echo $msg->getDisplay();
|
||||
}
|
||||
|
||||
$html .= $this->getHtmlForTrackingReportExportForm1(
|
||||
|
||||
@ -269,7 +269,7 @@ class TwoFactor
|
||||
}
|
||||
$result = $this->save();
|
||||
if ($result !== true) {
|
||||
$result->display();
|
||||
echo $result->getDisplay();
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@ -76,18 +76,6 @@ class MenuTest extends AbstractTestCase
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Table menu display test
|
||||
*/
|
||||
public function testTableDisplay(): void
|
||||
{
|
||||
$menu = new Menu('pma_test', '');
|
||||
$this->expectOutputString(
|
||||
$menu->getDisplay()
|
||||
);
|
||||
$menu->display();
|
||||
}
|
||||
|
||||
/**
|
||||
* Table menu setTable test
|
||||
*/
|
||||
|
||||
@ -490,29 +490,12 @@ class MessageTest extends AbstractTestCase
|
||||
$this->assertEquals('error', $this->object->getLevel());
|
||||
}
|
||||
|
||||
/**
|
||||
* testing display method (output string and _is_displayed variable)
|
||||
*/
|
||||
public function testDisplay(): void
|
||||
{
|
||||
$this->assertFalse($this->object->isDisplayed());
|
||||
$this->object->setMessage('Test Message');
|
||||
|
||||
$this->expectOutputString(
|
||||
'<div class="alert alert-primary" role="alert">' . "\n"
|
||||
. ' <img src="themes/dot.gif" title="" alt="" class="icon ic_s_notice"> Test Message' . "\n"
|
||||
. '</div>' . "\n"
|
||||
);
|
||||
$this->object->display();
|
||||
|
||||
$this->assertTrue($this->object->isDisplayed());
|
||||
}
|
||||
|
||||
/**
|
||||
* getDisplay test
|
||||
*/
|
||||
public function testGetDisplay(): void
|
||||
{
|
||||
$this->assertFalse($this->object->isDisplayed());
|
||||
$this->object->setMessage('Test Message');
|
||||
$this->assertEquals(
|
||||
'<div class="alert alert-primary" role="alert">' . "\n"
|
||||
@ -520,6 +503,7 @@ class MessageTest extends AbstractTestCase
|
||||
. '</div>' . "\n",
|
||||
$this->object->getDisplay()
|
||||
);
|
||||
$this->assertTrue($this->object->isDisplayed());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -574,8 +558,7 @@ class MessageTest extends AbstractTestCase
|
||||
$this->object = new Message();
|
||||
$msg = $this->object->getMessageForAffectedRows($rows);
|
||||
$this->object->addMessage($msg);
|
||||
$this->expectOutputString($output);
|
||||
$this->object->display();
|
||||
$this->assertEquals($output, $this->object->getDisplay());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -620,8 +603,7 @@ class MessageTest extends AbstractTestCase
|
||||
$this->object = new Message();
|
||||
$msg = $this->object->getMessageForInsertedRows($rows);
|
||||
$this->object->addMessage($msg);
|
||||
$this->expectOutputString($output);
|
||||
$this->object->display();
|
||||
$this->assertEquals($output, $this->object->getDisplay());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -666,7 +648,6 @@ class MessageTest extends AbstractTestCase
|
||||
$this->object = new Message();
|
||||
$msg = $this->object->getMessageForDeletedRows($rows);
|
||||
$this->object->addMessage($msg);
|
||||
$this->expectOutputString($output);
|
||||
$this->object->display();
|
||||
$this->assertEquals($output, $this->object->getDisplay());
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user