Visitar URL original
Merge pull request #18891 from kamil-tekiela/Fix-tracker-enable/disable · phpmyadmin/phpmyadmin@ab48ff8 · GitHub
Skip to content

Commit ab48ff8

Browse files
Merge pull request #18891 from kamil-tekiela/Fix-tracker-enable/disable
Fix initialization of Relation and Tracker
2 parents 37d1b3e + 4e8c62f commit ab48ff8

19 files changed

Lines changed: 47 additions & 209 deletions

‎phpstan-baseline.neon‎

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15695,11 +15695,6 @@ parameters:
1569515695
count: 2
1569615696
path: src/Tracking/Tracker.php
1569715697

15698-
-
15699-
message: "#^Only booleans are allowed in a negated boolean, mixed given\\.$#"
15700-
count: 2
15701-
path: src/Tracking/Tracker.php
15702-
1570315698
-
1570415699
message: "#^Only booleans are allowed in an if condition, string\\|false given\\.$#"
1570515700
count: 1
@@ -15825,11 +15820,6 @@ parameters:
1582515820
count: 1
1582615821
path: src/Tracking/Tracking.php
1582715822

15828-
-
15829-
message: "#^Only booleans are allowed in a negated boolean, mixed given\\.$#"
15830-
count: 1
15831-
path: src/Tracking/TrackingChecker.php
15832-
1583315823
-
1583415824
message: "#^Method PhpMyAdmin\\\\Transformations\\:\\:getAvailableMimeTypes\\(\\) should return array but returns mixed\\.$#"
1583515825
count: 1

‎psalm-baseline.xml‎

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5095,7 +5095,6 @@
50955095
<code>Config::getInstance()</code>
50965096
<code>Config::getInstance()</code>
50975097
<code>Config::getInstance()</code>
5098-
<code>Config::getInstance()</code>
50995098
</DeprecatedMethod>
51005099
<DeprecatedProperty>
51015100
<code>Routing::$route</code>
@@ -6513,11 +6512,6 @@
65136512
<code><![CDATA[$_REQUEST['goto']]]></code>
65146513
</PossiblyInvalidCast>
65156514
</file>
6516-
<file src="src/Http/Middleware/ZeroConfPostConnection.php">
6517-
<DeprecatedMethod>
6518-
<code>DatabaseInterface::getInstance()</code>
6519-
</DeprecatedMethod>
6520-
</file>
65216515
<file src="src/Image/ImageWrapper.php">
65226516
<PossiblyUnusedReturnValue>
65236517
<code>bool</code>
@@ -11857,8 +11851,6 @@
1185711851
<MixedAssignment>
1185811852
<code><![CDATA[$GLOBALS['export_type']]]></code>
1185911853
<code><![CDATA[$result['tablename']]]></code>
11860-
<code>$trackingEnabled</code>
11861-
<code>$trackingEnabled</code>
1186211854
<code>Current::$database</code>
1186311855
</MixedAssignment>
1186411856
<MixedInferredReturnType>
@@ -11966,11 +11958,6 @@
1196611958
<code>$versionNumber</code>
1196711959
</PossiblyNullArgument>
1196811960
</file>
11969-
<file src="src/Tracking/TrackingChecker.php">
11970-
<MixedAssignment>
11971-
<code>$trackingEnabled</code>
11972-
</MixedAssignment>
11973-
</file>
1197411961
<file src="src/Transformations.php">
1197511962
<DeprecatedMethod>
1197611963
<code>DatabaseInterface::getInstance()</code>
@@ -13809,8 +13796,6 @@
1380913796
<code>Config::getInstance()</code>
1381013797
<code>Config::getInstance()</code>
1381113798
<code>Config::getInstance()</code>
13812-
<code>Config::getInstance()</code>
13813-
<code>Config::getInstance()</code>
1381413799
<code>DatabaseInterface::getInstance()</code>
1381513800
<code>DatabaseInterface::getInstance()</code>
1381613801
</DeprecatedMethod>

‎src/Application.php‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,10 @@
4040
use PhpMyAdmin\Http\Middleware\ThemeInitialization;
4141
use PhpMyAdmin\Http\Middleware\TokenMismatchChecking;
4242
use PhpMyAdmin\Http\Middleware\TokenRequestParamChecking;
43-
use PhpMyAdmin\Http\Middleware\TrackerEnabling;
4443
use PhpMyAdmin\Http\Middleware\UriSchemeUpdating;
4544
use PhpMyAdmin\Http\Middleware\UrlParamsSetting;
4645
use PhpMyAdmin\Http\Middleware\UrlRedirection;
4746
use PhpMyAdmin\Http\Middleware\UserPreferencesLoading;
48-
use PhpMyAdmin\Http\Middleware\ZeroConfPostConnection;
4947
use PhpMyAdmin\Http\Response;
5048
use PhpMyAdmin\Http\ServerRequest;
5149
use PhpMyAdmin\Routing\Routing;
@@ -116,8 +114,6 @@ public function run(bool $isSetupPage = false): void
116114
$requestHandler->add(new TokenMismatchChecking());
117115
$requestHandler->add(new ProfilingChecking());
118116
$requestHandler->add(new UserPreferencesLoading($this->config));
119-
$requestHandler->add(new TrackerEnabling());
120-
$requestHandler->add(new ZeroConfPostConnection($this->config));
121117

122118
$runner = new RequestHandlerRunner(
123119
$requestHandler,

‎src/DatabaseInterface.php‎

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
namespace PhpMyAdmin;
66

77
use PhpMyAdmin\Config\Settings\Server;
8-
use PhpMyAdmin\ConfigStorage\Relation;
98
use PhpMyAdmin\Dbal\Connection;
109
use PhpMyAdmin\Dbal\ConnectionException;
1110
use PhpMyAdmin\Dbal\DbalInterface;
@@ -1208,23 +1207,6 @@ public function setCollation(string $collation): void
12081207
}
12091208
}
12101209

1211-
/**
1212-
* Function called just after a connection to the MySQL database server has
1213-
* been established. It sets the connection collation, and determines the
1214-
* version of MySQL which is running.
1215-
*/
1216-
public function postConnectControl(Relation $relation): void
1217-
{
1218-
// If Zero configuration mode enabled, check PMA tables in current db.
1219-
if (! Config::getInstance()->settings['ZeroConf']) {
1220-
return;
1221-
}
1222-
1223-
$this->databaseList = null;
1224-
1225-
$relation->initRelationParamsCache();
1226-
}
1227-
12281210
/**
12291211
* returns a single value from the given result or query,
12301212
* if the query or the result has more than one row or field
@@ -1665,14 +1647,6 @@ public function connect(Server $currentServer, int $connectionType, int|null $ta
16651647
),
16661648
E_USER_WARNING,
16671649
);
1668-
1669-
return null;
1670-
}
1671-
1672-
if ($connectionType === Connection::TYPE_AUXILIARY) {
1673-
// Do not go back to main login if connection failed
1674-
// (currently used only in unit testing)
1675-
return null;
16761650
}
16771651

16781652
return null;

‎src/Dbal/DbalInterface.php‎

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
use PhpMyAdmin\Column;
88
use PhpMyAdmin\ColumnFull;
99
use PhpMyAdmin\Config\Settings\Server;
10-
use PhpMyAdmin\ConfigStorage\Relation;
1110
use PhpMyAdmin\DatabaseInterface;
1211
use PhpMyAdmin\FieldMetadata;
1312
use PhpMyAdmin\Identifiers\DatabaseName;
@@ -298,13 +297,6 @@ public function postConnect(Server $currentServer): void;
298297
*/
299298
public function setCollation(string $collation): void;
300299

301-
/**
302-
* Function called just after a connection to the MySQL database server has
303-
* been established. It sets the connection collation, and determines the
304-
* version of MySQL which is running.
305-
*/
306-
public function postConnectControl(Relation $relation): void;
307-
308300
/**
309301
* returns a single value from the given result or query,
310302
* if the query or the result has more than one row or field

‎src/Http/Middleware/Authentication.php‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Fig\Http\Message\StatusCodeInterface;
88
use PhpMyAdmin\Config;
99
use PhpMyAdmin\Config\Settings\Server;
10+
use PhpMyAdmin\ConfigStorage\Relation;
1011
use PhpMyAdmin\Container\ContainerBuilder;
1112
use PhpMyAdmin\DatabaseInterface;
1213
use PhpMyAdmin\Dbal\Connection;
@@ -20,6 +21,7 @@
2021
use PhpMyAdmin\Plugins\AuthenticationPluginFactory;
2122
use PhpMyAdmin\ResponseRenderer;
2223
use PhpMyAdmin\Template;
24+
use PhpMyAdmin\Tracking\Tracker;
2325
use Psr\Http\Message\ResponseInterface;
2426
use Psr\Http\Message\ServerRequestInterface;
2527
use Psr\Http\Server\MiddlewareInterface;
@@ -70,6 +72,15 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
7072
}
7173

7274
$this->connectToDatabaseServer(DatabaseInterface::getInstance(), $authPlugin, $currentServer);
75+
76+
// Relation should only be initialized after the connection is successful
77+
/** @var Relation $relation */
78+
$relation = ContainerBuilder::getContainer()->get('relation');
79+
$relation->initRelationParamsCache();
80+
81+
// Tracker can only be activated after the relation has been initialized
82+
Tracker::enable();
83+
7384
$authPlugin->rememberCredentials();
7485
assert($request instanceof ServerRequest);
7586
$authPlugin->checkTwoFactor($request);

‎src/Http/Middleware/MinimumCommonRedirection.php‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
use PhpMyAdmin\ResponseRenderer;
1313
use PhpMyAdmin\Routing\Routing;
1414
use PhpMyAdmin\Theme\ThemeManager;
15-
use PhpMyAdmin\Tracking\Tracker;
1615
use Psr\Http\Message\ResponseInterface;
1716
use Psr\Http\Message\ServerRequestInterface;
1817
use Psr\Http\Server\MiddlewareInterface;
@@ -36,7 +35,6 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
3635
/** @var ThemeManager $themeManager */
3736
$themeManager = $container->get(ThemeManager::class);
3837
$this->config->loadUserPreferences($themeManager, true);
39-
Tracker::enable();
4038
assert($request instanceof ServerRequest);
4139

4240
try {

‎src/Http/Middleware/SetupPageRedirection.php‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
use PhpMyAdmin\ResponseRenderer;
1414
use PhpMyAdmin\Routing\Routing;
1515
use PhpMyAdmin\Theme\ThemeManager;
16-
use PhpMyAdmin\Tracking\Tracker;
1716
use Psr\Http\Message\ResponseInterface;
1817
use Psr\Http\Message\ServerRequestInterface;
1918
use Psr\Http\Server\MiddlewareInterface;
@@ -39,7 +38,6 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
3938
/** @var ThemeManager $themeManager */
4039
$themeManager = $container->get(ThemeManager::class);
4140
$this->config->loadUserPreferences($themeManager, true);
42-
Tracker::enable();
4341
$this->setupPageBootstrap();
4442
assert($request instanceof ServerRequest);
4543

‎src/Http/Middleware/TrackerEnabling.php‎

Lines changed: 0 additions & 22 deletions
This file was deleted.

‎src/Http/Middleware/UrlRedirection.php‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
use PhpMyAdmin\Config;
88
use PhpMyAdmin\Container\ContainerBuilder;
99
use PhpMyAdmin\Theme\ThemeManager;
10-
use PhpMyAdmin\Tracking\Tracker;
1110
use PhpMyAdmin\UrlRedirector;
1211
use Psr\Http\Message\ResponseInterface;
1312
use Psr\Http\Message\ServerRequestInterface;
@@ -32,7 +31,6 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
3231
/** @var ThemeManager $themeManager */
3332
$themeManager = $container->get(ThemeManager::class);
3433
$this->config->loadUserPreferences($themeManager, true);
35-
Tracker::enable();
3634

3735
return UrlRedirector::redirect($this->getUrlParam($request->getQueryParams()['url'] ?? null));
3836
}

0 commit comments

Comments
 (0)