dynamicalbum: let the sort field be configured per album type - #186
Open
martinbogo wants to merge 1 commit into
Open
dynamicalbum: let the sort field be configured per album type#186martinbogo wants to merge 1 commit into
martinbogo wants to merge 1 commit into
Conversation
UpdatesAlbumView::getChildIds() accepts an $orderBy argument but is only ever called without one, so the "Latest Updates" album is always sorted by creationTimestamp - when an item was added to Gallery. For a gallery built by import that field is close to useless: every item lands within the same import run, so they share a timestamp and the album comes back in no meaningful order. On the install this was found on, all 2195 photos carry a 2007 creationTimestamp while their originationTimestamp - when the photo was actually taken - spans 1999 to 2007. Add an orderBy.<type> parameter alongside the existing size.<type> and type.<type>, exposed in the site admin as "Sort By" with the same choices core already offers for ordinary albums. Defaults preserve today's behaviour exactly (creationTimestamp / viewCount / random), and an unset or empty value leaves the caller's argument alone, so the Popular and Random subclasses that pass an explicit sort are unaffected. Verified on 2.3.2 / PHP 8.2: with orderBy.date = originationTimestamp the album returns items in descending date-taken order across every album. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015pPeWCa9ToJFseWqbPrDH4
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The date album sorts by
creationTimestamp, which is when an item wasadded to the gallery rather than when the photo was taken. Those are the
same thing for a gallery filled in one photo at a time, and very different
for one filled by import: bulk-imported items commonly share a single
creation timestamp across thousands of items, which leaves the date album
in no meaningful order at all.
This adds an
orderBy.<type>parameter for each dynamic album type,selectable in Site Admin, so the date album can be pointed at
originationTimestamp(when the photo was taken) where that is the usefulkey.
Choices offered: Date added, Date taken, Date modified, Title, Name, View
count, Random.
Backward compatible. The new parameters default to exactly the current
behaviour (
creationTimestamp,viewCount,random), andUpdatesAlbumonly overrides its sort when the parameter is set and non-empty, so a
subclass passing an explicit sort is unaffected and an existing install
sees no change until someone changes the setting.
Module version bumped 1.0.3 -> 1.0.4.
Tested on a ~4,300-item gallery built entirely by import, where the date
album was previously in arbitrary order and now sorts by capture date.
🤖 Generated with Claude Code
https://claude.ai/code/session_015pPeWCa9ToJFseWqbPrDH4