Skip to content

Commit

Permalink
MDL-58957 Global search: fix failing text compare in Oracle
Browse files Browse the repository at this point in the history
  • Loading branch information
sammarshallou authored and danpoltawski committed Jul 13, 2017
1 parent 6719717 commit e80e477
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions search/classes/base_block.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,13 @@ public function get_block_name() {
* Returns restrictions on which block_instances rows to return. By default, excludes rows
* that have empty configdata.
*
* @return string SQL restriction (or multiple restrictions joined by AND), empty if none
* If no restriction is required, you could return ['', []].
*
* @return array 2-element array of SQL restriction and params for it
*/
protected function get_indexing_restrictions() {
return "bi.configdata != ''";
global $DB;
return [$DB->sql_compare_text('bi.configdata') . " != ?", ['']];
}

/**
Expand All @@ -88,10 +91,11 @@ protected function get_indexing_restrictions() {
*/
public function get_recordset_by_timestamp($modifiedfrom = 0) {
global $DB;
$restrictions = $this->get_indexing_restrictions();
list ($restrictions, $restrictionparams) = $this->get_indexing_restrictions();
if ($restrictions) {
$restrictions = 'AND ' . $restrictions;
}

// Query for all entries in block_instances for this type of block, which were modified
// since the given date. Also find the course or module where the block is located.
// (Although this query supports both module and course context, currently only two page
Expand All @@ -108,12 +112,12 @@ public function get_recordset_by_timestamp($modifiedfrom = 0) {
OR (c.id = parent.instanceid AND parent.contextlevel = ?)
WHERE bi.timemodified >= ?
AND bi.blockname = ?
AND (parent.contextlevel = ? AND (bi.pagetypepattern LIKE 'course-view-%'
AND (parent.contextlevel = ? AND (" . $DB->sql_like('bi.pagetypepattern', '?') . "
OR bi.pagetypepattern IN ('site-index', 'course-*', '*')))
$restrictions
ORDER BY bi.timemodified ASC",
[CONTEXT_BLOCK, CONTEXT_MODULE, CONTEXT_COURSE, $modifiedfrom,
$this->get_block_name(), CONTEXT_COURSE]);
array_merge([CONTEXT_BLOCK, CONTEXT_MODULE, CONTEXT_COURSE, $modifiedfrom,
$this->get_block_name(), CONTEXT_COURSE, 'course-view-%'], $restrictionparams));
}

public function get_doc_url(\core_search\document $doc) {
Expand Down

0 comments on commit e80e477

Please sign in to comment.