Skip to content

Commit 47c044c

Browse files
authored
Merge pull request #97 from in2code-pro/improve-compatibility-with-sql-modes
[BUGFIX] Improve compatibility with sql modes
2 parents 3db856d + 7ee2787 commit 47c044c

File tree

6 files changed

+16
-13
lines changed

6 files changed

+16
-13
lines changed

Classes/Condition/PowermailConditionFunctionsProvider.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,17 @@ protected function isPowermailSubmittedFunction(): ExpressionFunction
7070
*/
7171
protected function isPluginExistingOnCurrentPageInCurrentLanguage(array $plugins): bool
7272
{
73-
$listTypes = implode('","', $plugins);
73+
$listTypes = implode('\',\'', $plugins);
7474
$queryBuilder = DatabaseUtility::getQueryBuilderForTable('tt_content');
7575
$row = $queryBuilder
7676
->select('*')
7777
->from('tt_content')
78-
->where('pid=' . FrontendUtility::getCurrentPageIdentifier()
79-
. ' and CType in ("' . $listTypes . '") and sys_language_uid='
80-
. FrontendUtility::getSysLanguageUid())->setMaxResults(1)->executeQuery()
78+
->where(
79+
'pid=' . FrontendUtility::getCurrentPageIdentifier()
80+
. ' and CType in (\'' . $listTypes . '\') and sys_language_uid='
81+
. FrontendUtility::getSysLanguageUid()
82+
)->setMaxResults(1)
83+
->executeQuery()
8184
->fetchAssociative();
8285
return !empty($row['uid']);
8386
}

Classes/Domain/Repository/FieldRepository.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public function findAllWrongLocalizedFields(): array
106106
$rows = $queryBuilder
107107
->select('uid', 'pid', 'title', 'l10n_parent', 'sys_language_uid')
108108
->from(Field::TABLE_NAME)
109-
->where('(page = "" or page = 0) and sys_language_uid > 0 and deleted = 0')
109+
->where('(page = \'\' or page = 0) and sys_language_uid > 0 and deleted = 0')
110110
->executeQuery()
111111
->fetchAllAssociative();
112112
foreach ($rows as $row) {

Classes/Domain/Repository/FormRepository.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ public function findAllWrongLocalizedForms(): array
149149

150150
$sql = 'select uid,pid,title';
151151
$sql .= ' from ' . Form::TABLE_NAME;
152-
$sql .= ' where pages = ""';
152+
$sql .= ' where pages = \'\'';
153153
$sql .= ' and sys_language_uid > 0';
154154
$sql .= ' and deleted = 0';
155155
$sql .= ' limit 1';
@@ -167,7 +167,7 @@ public function fixWrongLocalizedForms(): void
167167
$queryBuilder = DatabaseUtility::getQueryBuilderForTable(Form::TABLE_NAME);
168168
$queryBuilder
169169
->update(Form::TABLE_NAME)
170-
->where('sys_language_uid > 0 and deleted = 0 and pages = ""')
170+
->where('sys_language_uid > 0 and deleted = 0 and pages = \'\'')
171171
->set('pages', 0)
172172
->executeStatement();
173173
}
@@ -182,7 +182,7 @@ public function fixWrongLocalizedForms(): void
182182
public function getFieldsFromFormWithSelectQuery(int $formUid): array
183183
{
184184
$queryBuilder = DatabaseUtility::getQueryBuilderForTable(Field::TABLE_NAME, true);
185-
$where = 'f.deleted = 0 and f.hidden = 0 and f.type != "submit" and f.sys_language_uid IN (-1,0)' .
185+
$where = 'f.deleted = 0 and f.hidden = 0 and f.type != \'submit\' and f.sys_language_uid IN (-1,0)' .
186186
' and fo.uid = ' . (int)$formUid;
187187
return $queryBuilder
188188
->select('f.uid', 'f.title', 'f.sender_email', 'f.sender_name', 'f.marker')

Classes/Domain/Repository/PageRepository.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public function findAllWrongLocalizedPages(): array
7777
return $queryBuilder
7878
->select('uid', 'pid', 'title', 'l10n_parent', 'sys_language_uid')
7979
->from(Page::TABLE_NAME)
80-
->where('(form = "" or form = 0) and sys_language_uid > 0 and deleted = 0')
80+
->where('(form = \'\' or form = 0) and sys_language_uid > 0 and deleted = 0')
8181
->executeQuery()
8282
->fetchAllAssociative();
8383
}

Classes/Utility/DatabaseUtility.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public static function isFieldFilled(string $fieldName, string $tableName): bool
105105
return (int)$queryBuilder
106106
->count($fieldName)
107107
->from($tableName)
108-
->where($fieldName . ' != "" and ' . $fieldName . ' != 0')
108+
->where($fieldName . ' != \'\' and ' . $fieldName . ' != 0')
109109
->executeQuery()
110110
->fetchOne() > 0;
111111
}

Classes/ViewHelpers/Be/PowermailVersionNoteViewHelper.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ protected function isCurrentVersionUnsafeCheck(): bool
123123
$row = $queryBuilder
124124
->select('review_state')
125125
->from(self::TABLE_NAME)
126-
->where('extension_key = "powermail" and version = "' . $this->getVersion() . '"')
126+
->where('extension_key = \'powermail\' and version = \'' . $this->getVersion() . '\'')
127127
->setMaxResults(1)
128128
->executeQuery()
129129
->fetchOne();
@@ -143,7 +143,7 @@ protected function isNewerVersionAvailableCheck(): bool
143143
$row = $queryBuilder
144144
->select('version')
145145
->from(self::TABLE_NAME)
146-
->where('extension_key = "powermail"')
146+
->where('extension_key = \'powermail\'')
147147
->orderBy('version', 'desc')
148148
->setMaxResults(1)
149149
->executeQuery()
@@ -167,7 +167,7 @@ protected function isCurrentVersionInExtensionTableExistingCheck(): bool
167167
$row = $queryBuilder
168168
->select('uid')
169169
->from(self::TABLE_NAME)
170-
->where('extension_key = "powermail" and version = "' . $this->getVersion() . '"')
170+
->where('extension_key = \'powermail\' and version = \'' . $this->getVersion() . '\'')
171171
->setMaxResults(1)
172172
->executeQuery()
173173
->fetchOne();

0 commit comments

Comments
 (0)