fix nullsafe warnings
parent
1d1156d438
commit
73bd0522d4
|
@ -10,7 +10,7 @@
|
|||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
if (!defined('DC_RC_PATH')) {
|
||||
if (!defined('DC_RC_PATH') || is_null(dcCore::app()->auth)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,7 @@ $this->registerModule(
|
|||
[
|
||||
'requires' => [['core', '2.25']],
|
||||
'permissions' => dcCore::app()->auth->makePermissions([
|
||||
dcAuth::PERMISSION_ADMIN,
|
||||
dcCore::app()->auth::PERMISSION_ADMIN,
|
||||
]),
|
||||
'type' => 'plugin',
|
||||
'support' => 'https://github.com/JcDenis/' . basename(__DIR__),
|
||||
|
|
|
@ -15,7 +15,6 @@ declare(strict_types=1);
|
|||
namespace Dotclear\Plugin\postslistOptions;
|
||||
|
||||
use ArrayObject;
|
||||
use dcAuth;
|
||||
use dcCore;
|
||||
use dcNsProcess;
|
||||
use dcPostsActions;
|
||||
|
@ -29,8 +28,12 @@ class Backend extends dcNsProcess
|
|||
{
|
||||
public static function init(): bool
|
||||
{
|
||||
static::$init = defined('DC_CONTEXT_ADMIN') && dcCore::app()->auth->check(
|
||||
dcCore::app()->auth->makePermissions([dcAuth::PERMISSION_ADMIN]),
|
||||
static::$init = defined('DC_CONTEXT_ADMIN')
|
||||
&& !is_null(dcCore::app()->auth) && !is_null(dcCore::app()->blog)
|
||||
&& dcCore::app()->auth->check(
|
||||
dcCore::app()->auth->makePermissions([
|
||||
dcCore::app()->auth::PERMISSION_ADMIN,
|
||||
]),
|
||||
dcCore::app()->blog->id
|
||||
);
|
||||
|
||||
|
|
|
@ -51,6 +51,11 @@ class BackendBehaviors
|
|||
|
||||
public static function commentsDelete(dcPostsActions $pa, ArrayObject $post): void
|
||||
{
|
||||
//nullsafe
|
||||
if (is_null(dcCore::app()->blog)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$ids = self::getPostsIds($pa);
|
||||
|
||||
if (empty($_POST['confirmdeletecomments'])) {
|
||||
|
@ -108,6 +113,11 @@ class BackendBehaviors
|
|||
|
||||
public static function trackbacksDelete(dcPostsActions $pa, ArrayObject $post): void
|
||||
{
|
||||
//nullsafe
|
||||
if (is_null(dcCore::app()->blog)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$ids = self::getPostsIds($pa);
|
||||
|
||||
if (empty($_POST['confirmdeletetrackbacks'])) {
|
||||
|
@ -157,6 +167,11 @@ class BackendBehaviors
|
|||
|
||||
private static function updPostOption(int $id, string $option, int $value): void
|
||||
{
|
||||
//nullsafe
|
||||
if (is_null(dcCore::app()->blog)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$id = abs((int) $id);
|
||||
$cur = dcCore::app()->con->openCursor(dcCore::app()->prefix . dcBlog::POST_TABLE_NAME);
|
||||
|
||||
|
@ -172,6 +187,11 @@ class BackendBehaviors
|
|||
|
||||
private static function delPostComments(int $id, bool $tb = false): void
|
||||
{
|
||||
//nullsafe
|
||||
if (is_null(dcCore::app()->blog)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$params = [
|
||||
'no_content' => true,
|
||||
'post_id' => abs((int) $id),
|
||||
|
|
Loading…
Reference in New Issue