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

Navs return everything in cases where nothing should be returned #11392

Open
efc opened this issue Jan 24, 2025 · 0 comments
Open

Navs return everything in cases where nothing should be returned #11392

efc opened this issue Jan 24, 2025 · 0 comments
Labels

Comments

@efc
Copy link

efc commented Jan 24, 2025

Bug description

The nav tag includes a from parameter that is documented as, "If unspecified, it'll start from the top."

However, it will return everything even if from is specified but empty or nonsensical.

The from parameter is supposed to accept "the URI of the entry to be used as the starting point for your navigation". But when supplied with a non-existent URI, such as "bob", it will still return everything. Specifying a non-existent URI is not "unspecified." For example, the URI may have once existed and been changed. In such cases it is unlikely that the artisan expects "everything" to suddenly be returned. In fact, this behavior makes bugs harder to discover, since at a glance stuff is being returned. It would be much easier to notice that the value supplied was not a valid URI if it returned empty.

It is correct for the actually unspecified default behavior to return everything, this is a good default.

But it is a problem for every specified value that is not a URI to also return everything.

How to reproduce

Add the following code to your default template...

{{ nav:collection:pages from="bob"}}
    <a href="{{ url }}">{{ title }}</a>
{{ /nav:collection:pages }}

Notice that even if you have no URI "bob" you will get all your pages in the result.

Logs

Environment

Environment
Application Name: Playground
Laravel Version: 11.37.0
PHP Version: 8.3.16
Composer Version: 2.8.4
Environment: local
Debug Mode: ENABLED
URL: play.test
Maintenance Mode: OFF
Timezone: America/Chicago
Locale: en

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

Drivers
Broadcasting: log
Cache: file
Database: sqlite
Logs: stack / single
Mail: log
Queue: sync
Session: file

Statamic
Addons: 3
Sites: 1
Stache Watcher: Enabled (auto)
Static Caching: Disabled
Version: 5.45.0 Solo

Statamic Addons
doefom/statamic-export: 0.4.1
statamic/importer: 1.7.2
statamic/ssg: 3.1.0

Installation

Fresh statamic/statamic site via CLI

Additional details

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants