Skip to content

Commit 819e9ac

Browse files
beni71richard67
andauthored
[5.4] Fix MySql 8 error "Illegal argument to a regular expression." in banners model (#46547)
--------- Co-authored-by: Richard Fath <richard67@users.noreply.github.com>
1 parent 561b0ea commit 819e9ac

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

components/com_banners/src/Model/BannersModel.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,14 +186,14 @@ protected function getListQuery()
186186
} else {
187187
$temp = [];
188188
$config = ComponentHelper::getParams('com_banners');
189-
$prefix = $config->get('metakey_prefix');
189+
$prefix = $config->get('metakey_prefix', '');
190190

191191
if ($categoryId) {
192192
$query->join('LEFT', $db->quoteName('#__categories', 'cat'), $db->quoteName('a.catid') . ' = ' . $db->quoteName('cat.id'));
193193
}
194194

195195
foreach ($keywords as $key => $keyword) {
196-
$regexp = '[[:<:]]' . $keyword . '[[:>:]]';
196+
$regexp = $db->getServerType() === 'mysql' ? '\\b' . $keyword . '\\b' : '[[:<:]]' . $keyword . '[[:>:]]';
197197
$valuesToBind = [$keyword, $keyword, $regexp];
198198

199199
if ($cid) {
@@ -272,8 +272,10 @@ public function getItems()
272272
if (!isset($this->cache['items'])) {
273273
$this->cache['items'] = parent::getItems();
274274

275-
foreach ($this->cache['items'] as &$item) {
276-
$item->params = new Registry($item->params);
275+
if (\is_array($this->cache['items'])) {
276+
foreach ($this->cache['items'] as &$item) {
277+
$item->params = new Registry($item->params);
278+
}
277279
}
278280
}
279281

0 commit comments

Comments
 (0)