Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Build/Scripts/runTests.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash

#
# EXT:examples test runner based on docker/podman.
# EXT:mysqlreport test runner based on docker/podman.
#

trap 'cleanUp;exit 2' SIGINT
Expand Down Expand Up @@ -60,8 +60,8 @@ handleDbmsOptions() {
echo "Use \".Build/Scripts/runTests.sh -h\" to display help and valid options" >&2
exit 1
fi
[ -z "${DBMS_VERSION}" ] && DBMS_VERSION="10.4"
if ! [[ ${DBMS_VERSION} =~ ^(10.4|10.5|10.6|10.7|10.8|10.9|10.10|10.11|11.0|11.1)$ ]]; then
[ -z "${DBMS_VERSION}" ] && DBMS_VERSION="10.11"
if ! [[ ${DBMS_VERSION} =~ ^(10.6|10.7|10.8|10.9|10.10|10.11|11.0|11.1)$ ]]; then
echo "Invalid combination -d ${DBMS} -i ${DBMS_VERSION}" >&2
echo >&2
echo "Use \".Build/Scripts/runTests.sh -h\" to display help and valid options" >&2
Expand Down
1 change: 1 addition & 0 deletions Build/phpunit/FunctionalTestsBootstrap.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/*
* This file is part of the TYPO3 CMS project.
*
Expand Down
1 change: 1 addition & 0 deletions Build/phpunit/UnitTestsBootstrap.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/*
* This file is part of the TYPO3 CMS project.
*
Expand Down
2 changes: 1 addition & 1 deletion Classes/Configuration/ExtConf.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class ExtConf

public function __construct(
ExtensionConfiguration $extensionConfiguration,
readonly private LoggerInterface $logger,
private readonly LoggerInterface $logger,
) {
$extConf = [];

Expand Down
8 changes: 4 additions & 4 deletions Classes/Doctrine/Middleware/LoggerStatement.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ class LoggerStatement implements Statement
* @param \SplQueue<QueryInformation> $queries
*/
public function __construct(
readonly private StatementInterface $wrappedStatement,
readonly private MySqlReportSqlLogger $logger,
readonly private string $sql,
readonly private \SplQueue $queries,
private readonly StatementInterface $wrappedStatement,
private readonly MySqlReportSqlLogger $logger,
private readonly string $sql,
private readonly \SplQueue $queries,
) {}

public function bindValue(int|string $param, mixed $value, ParameterType $type = ParameterType::STRING): void
Expand Down
4 changes: 2 additions & 2 deletions Classes/Doctrine/Middleware/LoggerWithQueryTimeMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
use TYPO3\CMS\Core\Utility\GeneralUtility;

/**
* With new driverMiddlewares-hook of TYPO3 we register a Middleware into Doctrine.
* With the new driverMiddlewares-hook of TYPO3 we register a Middleware into Doctrine.
*/
readonly class LoggerWithQueryTimeMiddleware implements UsableForConnectionInterface
{
Expand All @@ -43,7 +43,7 @@ public function canBeUsedForConnection(string $identifier, array $connectionPara

public function wrap(Driver $driver): Driver
{
// As $driver is transferred as constructor argument, DI can not be used in that class
// As $driver is transferred as a constructor argument, DI cannot be used in that class
return GeneralUtility::makeInstance(LoggerWithQueryTimeDriver::class, $driver);
}
}
2 changes: 1 addition & 1 deletion Classes/Domain/Repository/QueryInformationRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ public function findQueryInformationRecordsWithSlowQueries(): array
public function bulkInsert(array $queries): void
{
try {
$connection = $this->getDefaultConnection();
$connection = $this->getConnectionForMySqlReport();

foreach (array_chunk($queries, 50) as $chunkOfQueriesToStore) {
$connection->bulkInsert(
Expand Down
12 changes: 7 additions & 5 deletions Classes/EventListener/CacheAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
use TYPO3\CMS\Backend\Backend\Event\ModifyClearCacheActionsEvent;
use TYPO3\CMS\Backend\Routing\Exception\RouteNotFoundException;
use TYPO3\CMS\Backend\Routing\UriBuilder;
use TYPO3\CMS\Core\Utility\GeneralUtility;

/**
* Create ClearCache entry and process Cache Clearing of mysqlreport
Expand All @@ -24,6 +23,10 @@
{
use DatabaseConnectionTrait;

public function __construct(
private UriBuilder $uriBuilder,
) {}

/**
* Add clear cache menu entry
*
Expand All @@ -32,13 +35,12 @@
*/
public function __invoke(ModifyClearCacheActionsEvent $modifyClearCacheActionsEvent): void
{
$uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);

$modifyClearCacheActionsEvent->addCacheActionIdentifier('mysqlprofiles');
$modifyClearCacheActionsEvent->addCacheAction([
'id' => 'mysqlprofile',
'title' => 'LLL:EXT:mysqlreport/Resources/Private/Language/locallang.xlf:clearCache.title',
'description' => 'LLL:EXT:mysqlreport/Resources/Private/Language/locallang.xlf:clearCache.description',
'href' => (string)$uriBuilder->buildUriFromRoute('tce_db', ['cacheCmd' => 'mysqlprofiles']),
'href' => (string)$this->uriBuilder->buildUriFromRoute('tce_db', ['cacheCmd' => 'mysqlprofiles']),
'iconIdentifier' => 'actions-system-cache-clear-impact-high',
]);
}
Expand All @@ -54,7 +56,7 @@ public function clearProfiles(array $params = []): void
isset($params['cacheCmd'])
&& $params['cacheCmd'] === 'mysqlprofiles'
) {
$this->getDefaultConnection()->truncate('tx_mysqlreport_query_information');
$this->getConnectionForMySqlReport()->truncate('tx_mysqlreport_query_information');
}
}
}
2 changes: 1 addition & 1 deletion Classes/Helper/QueryParamsHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
use TYPO3\CMS\Core\Database\ConnectionPool;

/**
* Helper to replace query params in query to get a ready to use query for EXPLAIN
* Helper to replace query params in a query to get a ready to use query for EXPLAIN
*/
readonly class QueryParamsHelper
{
Expand Down
10 changes: 10 additions & 0 deletions Classes/Traits/DatabaseConnectionTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,16 @@ private function getDefaultConnection(): Connection
);
}

/**
* It may happen that the mysqlreport table is NOT configured for DEFAULT_CONNECTION_NAME (read-ony|write setups)
*/
private function getConnectionForMySqlReport(): Connection
{
return $this->getConnectionPool()->getConnectionForTable(
'tx_mysqlreport_query_information',
);
}

private function isValidConnectionDriver(string $connectionDriver): bool
{
return in_array($connectionDriver, ['mysqli', 'pdo_mysql'], true);
Expand Down
5 changes: 5 additions & 0 deletions Documentation/ChangeLog/Index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ ChangeLog
.. contents::
:local:

Version 4.0.2
=============

* [TASK] Use specific connection for mysqlreport table

Version 4.0.1
=============

Expand Down
2 changes: 1 addition & 1 deletion Documentation/guides.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
/>
<project title="MySQL Report"
release="4.0"
version="4.0.1"
version="4.0.2"
copyright="since 2024 by Stefan Froemken &amp; contributors"
/>
<inventory id="t3coreapi"
Expand Down
2 changes: 1 addition & 1 deletion ext_emconf.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
'author_email' => 'froemken@gmail.com',
'state' => 'stable',
'author_company' => '',
'version' => '4.0.1',
'version' => '4.0.2',
'constraints' => [
'depends' => [
'typo3' => '13.0.0-13.4.99',
Expand Down