Skip to content

Commit 625e9df

Browse files
authored
Fix #114: Fixes exception "Call to a member function getSnippetSource() on array" when call \yii\sphinx\ActiveQuery::search broken by v2.0.11
1 parent 70a3edd commit 625e9df

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

.travis.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ services:
1414

1515
sudo: true
1616

17+
# xenial doesn't support PHP 5.4 - 5.5 (https://travis-ci.community/t/php-5-4-and-5-5-archives-missing/3723)
18+
# and can't install sphinxsearch
19+
dist: trusty
20+
1721
# cache vendor dirs
1822
cache:
1923
directories:

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Yii Framework 2 sphinx extension Change Log
44
2.0.13 under development
55
------------------------
66

7-
- no changes in this release.
7+
- Bug #114: Fixes exception "Call to a member function getSnippetSource() on array" when call `\yii\sphinx\ActiveQuery::search` broken by v2.0.11 (miketsoft)
88

99

1010
2.0.12 July 02, 2019

src/ActiveQuery.php

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -152,15 +152,11 @@ public function snippetByModel()
152152
* Executes query and returns all results as an array.
153153
* @param Connection $db the DB connection used to create the DB command.
154154
* If null, the DB connection returned by [[modelClass]] will be used.
155-
* @return array the query results. If the query results in nothing, an empty array will be returned.
155+
* @return array|ActiveRecord[] the query results. If the query results in nothing, an empty array will be returned.
156156
*/
157157
public function all($db = null)
158158
{
159-
if ($this->emulateExecution) {
160-
return [];
161-
}
162-
$rows = $this->createCommand($db)->queryAll();
163-
return $this->populate($rows);
159+
return parent::all($db);
164160
}
165161

166162
/**
@@ -195,14 +191,14 @@ public function populate($rows)
195191
if (!empty($this->with)) {
196192
$this->findWith($this->with, $models);
197193
}
198-
$models = $this->fillUpSnippets($models);
194+
$models = parent::populate($models);
199195
if (!$this->asArray) {
200196
foreach ($models as $model) {
201197
$model->afterFind();
202198
}
203199
}
204200

205-
return parent::populate($models);
201+
return $models;
206202
}
207203

208204
/**

src/Query.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,9 @@ public function createCommand($db = null)
185185
/**
186186
* {@inheritdoc}
187187
*/
188-
public function all($db = null)
188+
public function populate($rows)
189189
{
190-
return $this->fillUpSnippets(parent::all($db));
190+
return parent::populate($this->fillUpSnippets($rows));
191191
}
192192

193193
/**
@@ -261,7 +261,7 @@ public function search($db = null)
261261
}
262262

263263
// rows should be populated after all data read from cursor, avoiding possible 'unbuffered query' error
264-
$rows = $this->populate($this->fillUpSnippets($rawRows));
264+
$rows = $this->populate($rawRows);
265265

266266
return [
267267
'hits' => $rows,

0 commit comments

Comments
 (0)