fix nullsafe warnings
This commit is contained in:
parent
1b1ea26327
commit
28ccb5fd0c
3 changed files with 22 additions and 2 deletions
|
@ -10,7 +10,7 @@
|
||||||
* @copyright Jean-Christian Denis
|
* @copyright Jean-Christian Denis
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
* @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;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ $this->registerModule(
|
||||||
[
|
[
|
||||||
'requires' => [['core', '2.25']],
|
'requires' => [['core', '2.25']],
|
||||||
'permissions' => dcCore::app()->auth->makePermissions([
|
'permissions' => dcCore::app()->auth->makePermissions([
|
||||||
dcAuth::PERMISSION_CONTENT_ADMIN,
|
dcCore::app()->auth::PERMISSION_CONTENT_ADMIN,
|
||||||
]),
|
]),
|
||||||
'type' => 'plugin',
|
'type' => 'plugin',
|
||||||
'support' => 'http://forum.dotclear.org/viewtopic.php?pid=333002#p333002',
|
'support' => 'http://forum.dotclear.org/viewtopic.php?pid=333002#p333002',
|
||||||
|
|
|
@ -114,6 +114,11 @@ class BackendBehaviors
|
||||||
|
|
||||||
public static function adminAfterDashboardOptionsUpdate(?string $user_id): void
|
public static function adminAfterDashboardOptionsUpdate(?string $user_id): void
|
||||||
{
|
{
|
||||||
|
// nullsafe
|
||||||
|
if (is_null(dcCore::app()->auth) || is_null(dcCore::app()->auth->user_prefs)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
dcCore::app()->auth->user_prefs->get('dashboard')->put(
|
dcCore::app()->auth->user_prefs->get('dashboard')->put(
|
||||||
'topWriterPostsItems',
|
'topWriterPostsItems',
|
||||||
!empty($_POST['topWriterPostsItems']),
|
!empty($_POST['topWriterPostsItems']),
|
||||||
|
@ -149,6 +154,11 @@ class BackendBehaviors
|
||||||
|
|
||||||
private static function setDefaultPref(): array
|
private static function setDefaultPref(): array
|
||||||
{
|
{
|
||||||
|
// nullsafe
|
||||||
|
if (is_null(dcCore::app()->auth) || is_null(dcCore::app()->auth->user_prefs)) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
if (!dcCore::app()->auth->user_prefs->get('dashboard')->prefExists('topWriterPostsItems')) {
|
if (!dcCore::app()->auth->user_prefs->get('dashboard')->prefExists('topWriterPostsItems')) {
|
||||||
dcCore::app()->auth->user_prefs->get('dashboard')->put(
|
dcCore::app()->auth->user_prefs->get('dashboard')->put(
|
||||||
'topWriterPostsItems',
|
'topWriterPostsItems',
|
||||||
|
|
|
@ -24,6 +24,11 @@ class Utils
|
||||||
{
|
{
|
||||||
public static function posts(string $period, int $limit, bool $sort_desc = true): array
|
public static function posts(string $period, int $limit, bool $sort_desc = true): array
|
||||||
{
|
{
|
||||||
|
// nullsafe
|
||||||
|
if (is_null(dcCore::app()->blog)) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
$req = 'SELECT COUNT(*) AS count, U.user_id ' .
|
$req = 'SELECT COUNT(*) AS count, U.user_id ' .
|
||||||
'FROM ' . dcCore::app()->prefix . dcBlog::POST_TABLE_NAME . ' P ' .
|
'FROM ' . dcCore::app()->prefix . dcBlog::POST_TABLE_NAME . ' P ' .
|
||||||
'INNER JOIN ' . dcCore::app()->prefix . dcAuth::USER_TABLE_NAME . ' U ON U.user_id = P.user_id ' .
|
'INNER JOIN ' . dcCore::app()->prefix . dcAuth::USER_TABLE_NAME . ' U ON U.user_id = P.user_id ' .
|
||||||
|
@ -82,6 +87,11 @@ class Utils
|
||||||
|
|
||||||
public static function comments(string $period, int $limit, bool $sort_desc = true, bool $exclude = false): array
|
public static function comments(string $period, int $limit, bool $sort_desc = true, bool $exclude = false): array
|
||||||
{
|
{
|
||||||
|
// nullsafe
|
||||||
|
if (is_null(dcCore::app()->blog)) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
$req = 'SELECT COUNT(*) AS count, comment_email ' .
|
$req = 'SELECT COUNT(*) AS count, comment_email ' .
|
||||||
'FROM ' . dcCore::app()->prefix . dcBlog::POST_TABLE_NAME . ' P, ' . dcCore::app()->prefix . dcBlog::COMMENT_TABLE_NAME . ' C ' .
|
'FROM ' . dcCore::app()->prefix . dcBlog::POST_TABLE_NAME . ' P, ' . dcCore::app()->prefix . dcBlog::COMMENT_TABLE_NAME . ' C ' .
|
||||||
'WHERE P.post_id=C.post_id ' .
|
'WHERE P.post_id=C.post_id ' .
|
||||||
|
|
Loading…
Reference in a new issue