Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

CP sidebar checks every site for each navigation

已关闭 适合新手
#15,667 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

已经有一个关联 PR 被合并了。

  • #15668 来自 @lazerg —— 已合并

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
78/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
laravel, mariadb, php

调研方向

阅读 src/CP/Navigation/CoreNav.php 中 issue 所示过滤器和映射附近的代码,然后将建议的调用与 #14988 中引入的单站点查询进行比较。确认侧边栏会检查所选站点上的导航是否可用,而不会扫描每个站点的导航树。完成标准是 CP 请求避免重复执行逐站点查询,同时导航可见性保持正确。

由索引模型根据 Issue 内容生成。

描述

multisite performance
Bug description

The CP gets slower as you add sites, even on pages unrelated to navigation.

I seeded 1,218 sites and 3 navigations. Each CP request ran ~3,670 queries. The queries came from src/CP/Navigation/CoreNav.php, which checks every site's tree to find out whether a navigation exists in the selected site.

Proposed fix

This follows the same approach as #14988, which made existsIn() a single-site lookup.

Before:

    ->filter(function ($nav) { // line 115
        return User::current()->can('configure navs')
            || $nav->sites()->contains(Site::selected()->handle());
    })
    ->map(function ($nav) {
        $availableInSelectedSite = Site::hasMultiple()
            ? $nav->sites()->contains(Site::selected()->handle())
            : true;

After:

    ->filter(function ($nav) {
        return User::current()->can('configure navs')
            || $nav->existsIn(Site::selected()->handle());
    })
    ->map(function ($nav) {
        $availableInSelectedSite = Site::hasMultiple()
            ? $nav->existsIn(Site::selected()->handle())
            : true;
How to reproduce
  1. Use multisite with a large number of sites (I seeder 1,218).
  2. Create a few navigations with a tree in one site.
  3. Log in as a super user and open any CP page.
Logs

Environment
Environment
Laravel Version: 13.35.0
PHP Version: 8.5.10
Composer Version: 2.10.2
Environment: local
Debug Mode: ENABLED
Maintenance Mode: OFF
Timezone: UTC
Locale: en

Cache
Config: NOT CACHED
Events: NOT CACHED
Routes: NOT CACHED
Views: CACHED

Drivers
Cache: file
Database: mariadb
Logs: stack / daily
Mail: log
Queue: redis
Session: file

Storage
public/storage: NOT LINKED

Laradocs
AI Chat: disabled
Banner: disabled
Caching: enabled
Docs Path: docs
Route Prefix: /communications/cms/help
Search Driver: auto
Theme: auto

Statamic
Addons: 4
License Key: Set
Sites: 1218 (Abbott, Fadel and Denesik, Abbott-Wiegand, Abernathy Group, and 1215 more)
Stache Watcher: Enabled (auto)
Static Caching: Disabled
Version: 6.35.1 PRO

Statamic Addons
statamic/audit-log: 1.1.1
statamic/collaboration: 2.0.1
statamic/eloquent-driver: 5.12.2
statamic/seo-pro: 7.15.1

Statamic Eloquent Driver
Addon Settings: eloquent
Asset Containers: eloquent
Assets: eloquent
Blueprints: eloquent
Collection Trees: eloquent
Collections: eloquent
Entries: eloquent
Fieldsets: file
Form Submissions: eloquent
Forms: eloquent
Global Sets: eloquent
Global Variables: eloquent
Navigation Trees: eloquent
Navigations: eloquent
Revisions: eloquent
Sites: eloquent
Taxonomies: eloquent
Terms: eloquent
Tokens: eloquent
Installation

Existing Laravel app

Additional details

No response

主要语言
PHP
星标
4.9k
派生
647
平均合并
1 天 13 小时
30 天内合并 PR
133

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

statamic/cms 的其他 Issue

查看 statamic/cms 的全部 Issue

相似的 Issue

更多 PHP Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。