cosmetic nullsafe fix
This commit is contained in:
parent
085b01ed9f
commit
337bad9112
3 changed files with 40 additions and 6 deletions
|
@ -40,6 +40,11 @@ class Alias
|
|||
return $this->aliases;
|
||||
}
|
||||
|
||||
// nullsafe PHP < 8.0
|
||||
if (is_null(dcCore::app()->blog)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$sql = new SelectStatement();
|
||||
$rs = $sql->from(dcCore::app()->prefix . My::ALIAS_TABLE_NAME)
|
||||
->columns([
|
||||
|
@ -97,6 +102,11 @@ class Alias
|
|||
*/
|
||||
public function createAlias(string $url, string $destination, int $position): void
|
||||
{
|
||||
// nullsafe PHP < 8.0
|
||||
if (is_null(dcCore::app()->blog)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$url = trim($url);
|
||||
$destination = trim($destination);
|
||||
|
||||
|
@ -122,6 +132,11 @@ class Alias
|
|||
*/
|
||||
public function deleteAlias(string $url): void
|
||||
{
|
||||
// nullsafe PHP < 8.0
|
||||
if (is_null(dcCore::app()->blog)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$sql = new DeleteStatement();
|
||||
$sql->from(dcCore::app()->prefix . My::ALIAS_TABLE_NAME)
|
||||
->where('blog_id = ' . $sql->quote((string) dcCore::app()->blog->id))
|
||||
|
@ -134,6 +149,11 @@ class Alias
|
|||
*/
|
||||
public function deleteAliases(): void
|
||||
{
|
||||
// nullsafe PHP < 8.0
|
||||
if (is_null(dcCore::app()->blog)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$sql = new DeleteStatement();
|
||||
$sql->from(dcCore::app()->prefix . My::ALIAS_TABLE_NAME)
|
||||
->where('blog_id = ' . $sql->quote((string) dcCore::app()->blog->id))
|
||||
|
|
|
@ -27,6 +27,7 @@ class Backend extends dcNsProcess
|
|||
public static function init(): bool
|
||||
{
|
||||
static::$init = defined('DC_CONTEXT_ADMIN')
|
||||
&& !is_null(dcCore::app()->auth) && !is_null(dcCore::app()->blog) //nullsafe PHP < 8.0
|
||||
&& dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([
|
||||
dcCore::app()->auth::PERMISSION_ADMIN,
|
||||
]), dcCore::app()->blog->id);
|
||||
|
@ -40,6 +41,11 @@ class Backend extends dcNsProcess
|
|||
return false;
|
||||
}
|
||||
|
||||
// nullsafe PHP < 8.0
|
||||
if (is_null(dcCore::app()->auth) || is_null(dcCore::app()->blog) || is_null(dcCore::app()->adminurl)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
dcCore::app()->menu[dcAdmin::MENU_PLUGINS]->addItem(
|
||||
My::name(),
|
||||
dcCore::app()->adminurl->get('admin.plugin.' . My::id()),
|
||||
|
|
|
@ -40,12 +40,10 @@ class Manage extends dcNsProcess
|
|||
public static function init(): bool
|
||||
{
|
||||
static::$init = defined('DC_CONTEXT_ADMIN')
|
||||
&& dcCore::app()->auth->check(
|
||||
dcCore::app()->auth->makePermissions([
|
||||
dcCore::app()->auth::PERMISSION_ADMIN,
|
||||
]),
|
||||
dcCore::app()->blog->id
|
||||
);
|
||||
&& !is_null(dcCore::app()->auth) && !is_null(dcCore::app()->blog) //nullsafe PHP < 8.0
|
||||
&& dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([
|
||||
dcCore::app()->auth::PERMISSION_ADMIN,
|
||||
]), dcCore::app()->blog->id);
|
||||
|
||||
return static::$init;
|
||||
}
|
||||
|
@ -56,6 +54,11 @@ class Manage extends dcNsProcess
|
|||
return false;
|
||||
}
|
||||
|
||||
// nullsafe PHP < 8.0
|
||||
if (is_null(dcCore::app()->auth) || is_null(dcCore::app()->blog) || is_null(dcCore::app()->adminurl)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (empty($_POST) || empty($_POST['a']) && empty($_POST['alias_url'])) {
|
||||
return true;
|
||||
}
|
||||
|
@ -94,6 +97,11 @@ class Manage extends dcNsProcess
|
|||
return;
|
||||
}
|
||||
|
||||
// nullsafe PHP < 8.0
|
||||
if (is_null(dcCore::app()->blog) || is_null(dcCore::app()->adminurl)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$alias = new Alias();
|
||||
$aliases = $alias->getAliases();
|
||||
|
||||
|
|
Loading…
Reference in a new issue