Skip to content

Commit

Permalink
[BUGFIX] Extension list view throws errors (georgringer#236)
Browse files Browse the repository at this point in the history
* [BUGFIX] Add missing action in form

* [BUGFIX] Add closing div tag

* [TASK] Add margin bottom class

* [BUGFIX] Change QueryBuilder in ExtensionRepository
  • Loading branch information
rniklas authored Oct 29, 2024
1 parent 2739003 commit e7daa33
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
24 changes: 20 additions & 4 deletions Classes/Domain/Repository/ExtensionRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
* LICENSE.txt file that was distributed with this source code.
*/

use Doctrine\DBAL\Exception;
use T3Monitor\T3monitoring\Domain\Model\Dto\ExtensionFilterDemand;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Database\Query\QueryBuilder;
Expand All @@ -25,6 +26,10 @@ public function initializeObject(): void
$this->setDefaultOrderings(['name' => QueryInterface::ORDER_ASCENDING]);
}

/**
* @param string $name
* @return QueryResultInterface|array
*/
public function findAllVersionsByName(string $name): QueryResultInterface|array
{
$query = $this->getQuery();
Expand All @@ -36,6 +41,11 @@ public function findAllVersionsByName(string $name): QueryResultInterface|array
return $query->execute();
}

/**
* @param ExtensionFilterDemand $demand
* @return array
* @throws Exception
*/
public function findByDemand(ExtensionFilterDemand $demand): array
{
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('tx_t3monitoring_domain_model_extension');
Expand All @@ -52,16 +62,20 @@ public function findByDemand(ExtensionFilterDemand $demand): array
->orderBy('ext.version_integer', 'DESC')
->orderBy('client.title', 'ASC');
$this->extendWhereClause($demand, $queryBuilder);

$statement = $queryBuilder->executeQuery();
$result = [];
while ($row = $queryBuilder->executeQuery()->fetchAssociative()) {
while ($row = $statement->fetchAssociative()) {
$result[$row['name']][$row['version']]['insecure'] = $row['insecure'];
$result[$row['name']][$row['version']]['clients'][] = $row;
}

return $result;
}

/**
* @param ExtensionFilterDemand $demand
* @param QueryBuilder $qb
*/
protected function extendWhereClause(ExtensionFilterDemand $demand, QueryBuilder $qb): void
{
if (!$demand->getName()) {
Expand All @@ -70,8 +84,10 @@ protected function extendWhereClause(ExtensionFilterDemand $demand, QueryBuilder
if ($demand->isExactSearch()) {
$condition = $qb->expr()->eq('ext.name', $qb->createNamedParameter($demand->getName()));
} else {
$condition = $qb->expr()->like('ext.name',
$qb->createNamedParameter('%' . $qb->escapeLikeWildcards($demand->getName()) . '%'));
$condition = $qb->expr()->like(
'ext.name',
$qb->createNamedParameter('%' . $qb->escapeLikeWildcards($demand->getName()) . '%')
);
}
$qb->andWhere($condition);
}
Expand Down
4 changes: 3 additions & 1 deletion Resources/Private/Templates/Extension/List.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<f:section name="Content">
<h1>{f:translate(key:'view.usedExtensions')}</h1>

<f:form name="filter" object="{filter}" class="form-inline">
<f:form action="list" name="filter" object="{filter}" class="form-inline mb-3">

<div class="form-group">
<label>{f:translate(key:'extensionFilter.name')}</label>
Expand Down Expand Up @@ -72,6 +72,7 @@ <h1>{f:translate(key:'view.usedExtensions')}</h1>
</f:for>
</f:for>
</table>
</div>
</f:then>
<f:else>
<f:be.infobox>
Expand All @@ -80,4 +81,5 @@ <h1>{f:translate(key:'view.usedExtensions')}</h1>
</f:else>
</f:if>
</f:section>

</html>

0 comments on commit e7daa33

Please sign in to comment.