Skip to content

Commit 25d04e6

Browse files
committed
[BUGFIX] Add missing quote
1 parent dbecd72 commit 25d04e6

4 files changed

Lines changed: 8 additions & 8 deletions

File tree

Classes/Controller/NewsController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,7 @@ protected function createDemandObjectFromSettings(
132132
$class = isset($settings['demandClass']) && !empty($settings['demandClass']) ? $settings['demandClass'] : $class;
133133

134134
/* @var $demand NewsDemand */
135-
$demand = GeneralUtility::makeInstance($class, $settings);
136-
if (!$demand instanceof NewsDemand) {
135+
if (!is_a($class, NewsDemand::class, true)) {
137136
throw new \UnexpectedValueException(
138137
sprintf(
139138
'The demand object must be an instance of %s, but %s given!',
@@ -144,6 +143,7 @@ protected function createDemandObjectFromSettings(
144143
);
145144
}
146145

146+
$demand = GeneralUtility::makeInstance($class, $settings);
147147
$demand->setCategories(GeneralUtility::trimExplode(',', $settings['categories'] ?? '', true));
148148
$demand->setCategoryConjunction((string)($settings['categoryConjunction'] ?? ''));
149149
$demand->setIncludeSubCategories((bool)($settings['includeSubCategories'] ?? false));

Classes/Domain/Repository/AbstractDemandedRepository.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,10 @@ public function findDemandedRaw(DemandInterface $demand, $respectEnableFields =
9898
$queryBuilder = $queryParser->convertQueryToDoctrineQueryBuilder($query);
9999
$queryParameters = $queryBuilder->getParameters();
100100
$params = [];
101+
$connection = $queryBuilder->getConnection();
101102
foreach ($queryParameters as $key => $value) {
102103
// prefix array keys with ':'
103-
$params[':' . $key] = (is_numeric($value)) ? $value : "'" . $value . "'"; //all non numeric values have to be quoted
104+
$params[':' . $key] = (is_numeric($value)) ? $value : $connection->quote($value); //all non numeric values have to be quoted
104105
unset($params[$key]);
105106
}
106107
// replace placeholders with real values

Classes/Domain/Repository/NewsRepository.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,8 @@ public function findByUid($uid, $respectEnableFields = true): ?\GeorgRinger\News
364364
*/
365365
public function countByDate(DemandInterface $demand): array
366366
{
367+
$connection = GeneralUtility::makeInstance(ConnectionPool::class)
368+
->getConnectionForTable('tx_news_domain_model_news');
367369
$data = [];
368370
$sql = $this->findDemandedRaw($demand);
369371

@@ -372,17 +374,14 @@ public function countByDate(DemandInterface $demand): array
372374

373375
// Get the month/year into the result
374376
$field = $demand->getDateField();
375-
$field = empty($field) ? 'datetime' : $field;
377+
$field = $connection->quoteIdentifier(empty($field) ? 'datetime' : $field);
376378

377379
$sql = 'SELECT MONTH(FROM_UNIXTIME(0) + INTERVAL ' . $field . ' SECOND ) AS "_Month",' .
378380
' YEAR(FROM_UNIXTIME(0) + INTERVAL ' . $field . ' SECOND) AS "_Year" ,' .
379381
' count(MONTH(FROM_UNIXTIME(0) + INTERVAL ' . $field . ' SECOND )) as count_month,' .
380382
' count(YEAR(FROM_UNIXTIME(0) + INTERVAL ' . $field . ' SECOND)) as count_year' .
381383
' FROM tx_news_domain_model_news ' . substr($sql, strpos($sql, 'WHERE '));
382384

383-
$connection = GeneralUtility::makeInstance(ConnectionPool::class)
384-
->getConnectionForTable('tx_news_domain_model_news');
385-
386385
if (TYPO3_MODE === 'FE') {
387386
$sql .= $GLOBALS['TSFE']->sys_page->enableFields('tx_news_domain_model_news');
388387
} else {

ext_emconf.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
'author_email' => 'mail@ringer.it',
99
'state' => 'stable',
1010
'clearCacheOnLoad' => true,
11-
'version' => '9.4.0',
11+
'version' => '9.4.1',
1212
'constraints' => [
1313
'depends' => [
1414
'typo3' => '10.4.13-11.9.99',

0 commit comments

Comments
 (0)