Merge pull request #10695 from creative-commoners/pulls/5.0/numpages

FIX Handle null returns in GridFieldDetailForm_ItemRequest::getNumPag…
This commit is contained in:
Guy Sartorelli 2023-02-20 17:27:52 +13:00 committed by GitHub
commit 86f889b938
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -665,11 +665,18 @@ class GridFieldDetailForm_ItemRequest extends RequestHandler
*/
private function getNumPages(GridField $gridField): int
{
return $gridField
->getConfig()
->getComponentByType(GridFieldPaginator::class)
->getTemplateParameters($gridField)
->toMap()['NumPages'];
/** @var GridFieldPaginator $component */
$component = $gridField
->getConfig()
->getComponentByType(GridFieldPaginator::class);
if (is_null($component)) {
return 1;
}
$params = $component->getTemplateParameters($gridField);
if (is_null($params)) {
return 1;
}
return $params->toMap()['NumPages'];
}
/**