Skip to content

Commit

Permalink
fix 6159
Browse files Browse the repository at this point in the history
  • Loading branch information
alikon committed Feb 25, 2015
1 parent b91f038 commit f395b9e
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 3 deletions.
2 changes: 1 addition & 1 deletion administrator/components/com_modules/models/modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ protected function getListQuery()
{
$escapedSearchString = $this->refineSearchStringToRegex($search, '/');
$search = $db->quote($escapedSearchString);
$query->where('(' . 'a.title REGEXP ' . $search . ' OR a.note REGEXP ' . $search . ')');
$query->where('(' . 'a.title ' . $db->regexp($search) . ' OR a.note ' . $db->regexp($search) . ')');
}
}

Expand Down
2 changes: 1 addition & 1 deletion administrator/components/com_templates/models/styles.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ protected function getListQuery()
{
$escapedSearchString = $this->refineSearchStringToRegex($search, '/');
$search = $db->quote($escapedSearchString);
$query->where('(' . 'a.template REGEXP ' . $search . ' OR a.title REGEXP ' . $search . ')');
$query->where('(' . 'a.template ' . $db->regexp($search) . ' OR a.title ' . $db->regexp($search) . ')');
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ protected function getListQuery()
{
$escapedSearchString = $this->refineSearchStringToRegex($search, '/');
$search = $db->quote($escapedSearchString);
$query->where('(' . 'a.element REGEXP ' . $search . ' OR a.name REGEXP ' . $search . ')');
$query->where('(' . 'a.element ' . $db->regexp($search) . ' OR a.name ' . $db->regexp($search) . ')');
}
}

Expand Down
19 changes: 19 additions & 0 deletions libraries/joomla/database/query/mysqli.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,23 @@ public function setLimit($limit = 0, $offset = 0)

return $this;
}

/**
* Return correct regexp operator for mysqli.
*
* Ensure that the regexp operator is mysqli compatible.
*
* Usage:
* $query->where('field ' . $db->regexp($search));
*
* @param string $value The regex pattern.
*
* @return string Returns the regex operator.
*
* @since 11.3
*/
public function regexp($value)
{
return ' REGEXP ' . $value;
}
}
19 changes: 19 additions & 0 deletions libraries/joomla/database/query/postgresql.php
Original file line number Diff line number Diff line change
Expand Up @@ -619,4 +619,23 @@ public function dateAdd($date, $interval, $datePart)
return "timestamp '" . $date . "' - interval '" . ltrim($interval, '-') . " " . $datePart . "'";
}
}

/**
* Return correct regexp operator for Postgresql.
*
* Ensure that the regexp operator is Postgresql compatible.
*
* Usage:
* $query->where('field ' . $db->regexp($search));
*
* @param string $value The regex pattern.
*
* @return string Returns the regex operator.
*
* @since 11.3
*/
public function regexp($value)
{
return ' ~* ' . $value;
}
}

0 comments on commit f395b9e

Please sign in to comment.