MNT Deprecation notice if param has wrong type (#10853)

This commit is contained in:
Sabina Talipova 2023-07-05 17:21:30 +12:00 committed by GitHub
parent 66f2df2571
commit a57adfc778
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View File

@ -186,7 +186,7 @@ class GridFieldFilterHeader extends AbstractGridFieldComponent implements GridFi
$dataListClone = clone($dataList);
$results = $this->getSearchContext($gridField)
->getQuery($filterArguments, false, false, $dataListClone);
->getQuery($filterArguments, false, null, $dataListClone);
return $results;
}

View File

@ -18,6 +18,7 @@ use SilverStripe\Forms\CheckboxField;
use InvalidArgumentException;
use Exception;
use SilverStripe\Core\Config\Config;
use SilverStripe\Dev\Deprecation;
use SilverStripe\ORM\DataQuery;
/**
@ -140,6 +141,13 @@ class SearchContext
*/
public function getQuery($searchParams, $sort = false, $limit = false, $existingQuery = null)
{
if ((count(func_get_args()) >= 3) && (!in_array(gettype($limit), ['array', 'NULL', 'string']))) {
Deprecation::notice(
'5.1.0',
'$limit should be type of array|string|null'
);
$limit = null;
}
$this->setSearchParams($searchParams);
$query = $this->prepareQuery($sort, $limit, $existingQuery);
return $this->search($query);