Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix after clean install and misc #392

Draft
wants to merge 9 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions app/Managers/CategoryManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

namespace App\Managers;

use App\Entities\Category;
use App\Entities\User;
use App\Models\CategoryModel;

class CategoryManager
Expand All @@ -16,7 +14,8 @@ public function loadCategoryPermissions(?int $categoryId = null, bool $permissio
$cacheKey = 'category-permissions-' . (int) $permissionsOnly;

if (! $permissions = cache($cacheKey)) {
$categories = model(CategoryModel::class)->findAllPermissions();
$permissions = [];
$categories = model(CategoryModel::class)->findAllPermissions();

foreach ($categories as $category) {
if ($permissionsOnly) {
Expand Down
16 changes: 12 additions & 4 deletions app/Models/CategoryModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ public function children()
*/
public function findAllNested(array $categoryIds): array
{
if ($categoryIds === []) {
return [[], []];
}

$selects = [
'categories.*',
'threads.title as last_thread_title',
Expand All @@ -87,17 +91,17 @@ public function findAllNested(array $categoryIds): array
->parents()
->whereIn("{$this->table}.id", $categoryIds)
->select(implode(', ', $selects))
->join('threads', 'threads.id = categories.last_thread_id')
->join('users', 'users.id = threads.author_id')
->join('threads', 'threads.id = categories.last_thread_id', 'LEFT')
neznaika0 marked this conversation as resolved.
Show resolved Hide resolved
->join('users', 'users.id = threads.author_id', 'LEFT')
->findAll();

$allChildren = $this
->active()
->children()
->whereIn("{$this->table}.id", $categoryIds)
->select(implode(', ', $selects))
->join('threads', 'threads.id = categories.last_thread_id')
->join('users', 'users.id = threads.author_id')
->join('threads', 'threads.id = categories.last_thread_id', 'LEFT')
->join('users', 'users.id = threads.author_id', 'LEFT')
->orderBy('order', 'asc')
->findAll();

Expand All @@ -109,6 +113,10 @@ public function findAllNested(array $categoryIds): array
*/
public function findAllNestedDropdown(array $categoryIds): array
{
if ($categoryIds === []) {
return [];
}

$selects = [
'id', 'title', 'parent_id', 'permissions',
];
Expand Down
6 changes: 6 additions & 0 deletions env.example
Original file line number Diff line number Diff line change
Expand Up @@ -155,3 +155,9 @@ imageupload.fileSize = 2048
#--------------------------------------------------------------------

# curlrequest.shareOptions = true

#--------------------------------------------------------------------
# Cache
#--------------------------------------------------------------------

cache.handler = file
2 changes: 1 addition & 1 deletion themes/admin/_top_nav.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
</div>

<!-- Site Name -->
<a class="btn btn-ghost normal-case text-xl text-primary-content">
<a href="<?= site_url() ?>" class="btn btn-ghost normal-case text-xl text-primary-content">
<?= config('App')->siteName ?>
</a>
</div>
Expand Down
2 changes: 1 addition & 1 deletion themes/default/_app_nav.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
</div>

<!-- Site Name -->
<a class="btn btn-ghost normal-case text-xl text-primary-content">
<a href="<?= site_url() ?>" class="btn btn-ghost normal-case text-xl text-primary-content">
<?= config('App')->siteName ?>
</a>
</div>
Expand Down
2 changes: 1 addition & 1 deletion themes/default/discussions/threads/_thread.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="thread px-6 pb-4">
<div id="thread" class="thread px-6 pb-4">
<h3 class="text-3xl leading-loose font-bold pb-2">
<a href="<?= esc($thread->link(), 'attr') ?>">
<?= esc($thread->title) ?>
Expand Down
Loading