mirror of
https://github.com/processwire/processwire.git
synced 2025-08-09 08:17:12 +02:00
Fix issue processwire/processwire-issues#1199
This commit is contained in:
@@ -165,6 +165,12 @@ class PageFinder extends Wire {
|
||||
*
|
||||
*/
|
||||
'useSortsAfter' => false,
|
||||
|
||||
/**
|
||||
* Options passed to DatabaseQuery::bindOptions() for primary query generated by this PageFinder
|
||||
*
|
||||
*/
|
||||
'bindOptions' => array(),
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -1386,6 +1392,9 @@ class PageFinder extends Wire {
|
||||
|
||||
/** @var DatabaseQuerySelect $query */
|
||||
$query = $this->wire(new DatabaseQuerySelect());
|
||||
if(!empty($options['bindOptions'])) {
|
||||
foreach($options['bindOptions'] as $k => $v) $query->bindOption($k, $v);
|
||||
}
|
||||
$query->select($columns);
|
||||
$query->from("pages");
|
||||
$query->groupby($options['returnParentIDs'] ? 'pages.parent_id' : 'pages.id');
|
||||
@@ -1665,7 +1674,11 @@ class PageFinder extends Wire {
|
||||
$query = $pageFinder->find($selectors, array(
|
||||
'returnQuery' => true,
|
||||
'returnVerbose' => false,
|
||||
'findAll' => true
|
||||
'findAll' => true,
|
||||
'bindOptions' => array(
|
||||
'prefix' => 'pfor',
|
||||
'global' => true,
|
||||
)
|
||||
));
|
||||
if($n > 0) $sql .= " \n\tOR pages.id IN (\n";
|
||||
$query->set('groupby', array());
|
||||
@@ -2416,7 +2429,14 @@ class PageFinder extends Wire {
|
||||
$s = '';
|
||||
foreach(explode(' ', $value) as $n => $word) {
|
||||
$word = $sanitizer->pageName($word, Sanitizer::toAscii);
|
||||
$bindKey = $query->bindValueGetKey('[[:<:]]' . $word . '[[:>:]]');
|
||||
$mySQL8 = false; // @todo add version check
|
||||
if($mySQL8) {
|
||||
// confirm the statement below works in MySQL 8.x because "\\b" has
|
||||
// very different regex meaning between 8.x and versions prior to it
|
||||
$bindKey = $query->bindValueGetKey("\\b$word\\b");
|
||||
} else {
|
||||
$bindKey = $query->bindValueGetKey('[[:<:]]' . $word . '[[:>:]]');
|
||||
}
|
||||
$s .= ($s ? ' AND ' : '') . "$table.$field RLIKE $bindKey";
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user