Fix unknown streamQuery on load Filter (#5845)

* Fix unknown `streamQuery` on load `Filter`

* Fix unknown `streamQuery` on load `Filter`

* Update CHANGELOG.md (#5845)

* Fix unknown `streamQuery` on load `Filter`
This commit is contained in:
Yuriy Bakhtin 2022-08-15 18:16:36 +03:00 committed by GitHub
parent d66d706f75
commit c577bf5fc6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 29 additions and 13 deletions

View File

@ -9,6 +9,7 @@ HumHub Changelog
- Fix #5814: Fix numerated lists in mail summary content
- Fix #5830: Fix cron job of search index rebuilding
- Fix #5838: Fix deprecated null value for `file_exists()` on PHP 8.1
- Fix #5845: Fix unknown `streamQuery` on load `Filter`
1.12.0 (July 27, 2022)
----------------------

View File

@ -25,6 +25,18 @@ abstract class StreamQueryFilter extends QueryFilter
*/
public $autoLoad = self::AUTO_LOAD_GET;
/**
* @inheritdoc
*/
public function init()
{
parent::init();
if ($this->isLoaded && !parent::validate()) {
$this->streamQuery->addErrors($this->getErrors());
}
}
/**
* @inheritDoc
*/
@ -32,4 +44,5 @@ abstract class StreamQueryFilter extends QueryFilter
{
return $this->formName ?: 'StreamQuery';
}
}

View File

@ -28,6 +28,11 @@ abstract class Filter extends Model
*/
public $autoLoad = self::AUTO_LOAD_ALL;
/**
* @var bool True - if data was loaded at least one time
*/
protected $isLoaded = false;
public abstract function apply();
public function init() {
@ -35,7 +40,7 @@ abstract class Filter extends Model
return;
}
if($this->autoLoad === static::AUTO_LOAD_ALL) {
if ($this->autoLoad === static::AUTO_LOAD_ALL) {
$this->load(Yii::$app->request->get());
$this->load(Yii::$app->request->post());
} elseif($this->autoLoad === static::AUTO_LOAD_GET) {
@ -45,24 +50,21 @@ abstract class Filter extends Model
}
}
public function formName() {
return $this->formName ?: parent::formName();
}
/**
* @inheritdoc
* @inheridoc
*/
public function load($data, $formName = null)
{
if (!parent::load($data, $formName)) {
return false;
if (parent::load($data, $formName)) {
$this->isLoaded = true;
return true;
}
if (!parent::validate()) {
$this->streamQuery->addErrors($this->getErrors());
}
return true;
}
public function formName() {
return $this->formName ? $this->formName : parent::formName();
return false;
}
}