mirror of
https://github.com/getgrav/grav-plugin-admin.git
synced 2025-11-01 10:56:08 +01:00
Fixed fatal error in admin if POST request has data in it [#2074]
This commit is contained in:
@@ -1,3 +1,9 @@
|
||||
# v1.10.5
|
||||
## dd/mm/2021
|
||||
|
||||
1. [](#bugfix)
|
||||
* Fixed fatal error in admin if POST request has `data` in it [#2074](https://github.com/getgrav/grav-plugin-admin/issues/2074)
|
||||
|
||||
# v1.10.4
|
||||
## 02/17/2021
|
||||
|
||||
|
||||
@@ -269,7 +269,7 @@ class Admin
|
||||
$name = $file->getBasename('.yaml');
|
||||
|
||||
// Check that blueprint exists and is not hidden.
|
||||
$data = $admin->data('config/'. $name);
|
||||
$data = $admin->data('config/'. $name, null);
|
||||
if (!is_callable([$data, 'blueprints'])) {
|
||||
continue;
|
||||
}
|
||||
@@ -838,12 +838,12 @@ class Admin
|
||||
* Gets configuration data.
|
||||
*
|
||||
* @param string $type
|
||||
* @param array $post
|
||||
* @param array|null $post
|
||||
*
|
||||
* @return mixed
|
||||
* @return object
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
public function data($type, array $post = [])
|
||||
public function data($type, ?array $post = [])
|
||||
{
|
||||
static $data = [];
|
||||
|
||||
@@ -851,9 +851,11 @@ class Admin
|
||||
return $data[$type];
|
||||
}
|
||||
|
||||
if (!$post) {
|
||||
$post = $this->grav['uri']->post();
|
||||
$post = $post['data'] ?? [];
|
||||
if (null !== $post && !$post) {
|
||||
$post = $this->grav['uri']->post()['data'] ?? null;
|
||||
if (!is_array($post)) {
|
||||
$post = [];
|
||||
}
|
||||
}
|
||||
|
||||
// Check to see if a data type is plugin-provided, before looking into core ones
|
||||
|
||||
@@ -2695,9 +2695,8 @@ class AdminController extends AdminBaseController
|
||||
protected function prepareData(array $data)
|
||||
{
|
||||
$type = trim("{$this->view}/{$this->admin->route}", '/');
|
||||
$data = $this->admin->data($type, $data);
|
||||
|
||||
return $data;
|
||||
return $this->admin->data($type, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user