set_display_context_callback() and incorrect pagination

Mike Miller <[email protected]> Sat, 26 Jan 2013 21:40:22 +0200
Newsgroups gmane.comp.web.gallery.devel
Message-ID <CAGYq59cMK0tSrZJJ2QBu-j6gmOqrfFbO49=7pPT89=W50=rYiA@mail.gmail.com>
Hi All,

I think I've identified a bug (mostly cosmetic in Wind, fatal in Grey
Dragon), but I'm not sure how to fix it.

The original symptom I noticed (in Grey Dragon) is that if I use
either the dynamic or the latestalbums modules to see recent items,
and then click on one of the images, the page aborts loading right
after the heading. If I click on the parent album (using a breadcrumb
or by typing a URL manually), and then try to return to the photo's
page again, it loads properly.

A quick investigation revealed that GD's paginator is trying to load
each sibling, and although sibling_count is 11912 for me (the number
of items in my gallery), it fails to retrieve a specific sibling
(corresponding to the the number of items in the album (i.e., the
actual sibling count) plus 1). It seems that when the items are loaded
via latestupdates or dynamic, a call to set_display_context_callback()
is made, and this sets the function that returns the "global variable"
$total which is based on sibling_count (in
modules/gallery/libraries/Gallery_View.php). If I examine the
g3_caches table, I can confirm that when viewing the photo page, the
callback is set to something like
latestupdates_Controller::get_display_context. Opening the album page
resets this (in modules/gallery/controllers/albums.php) and then the
count is set correctly.

In Wind, it's less severe; the paginator doesn't try to retrieve
information about the sibling, so the only effect is that despite the
fact that the URL is /path/to/actual/album/name/PHOTO, the paginator
says "XXX of <TOTAL NUMBER>" rather than "XXX of <ITEMS IN ALBUM>"

If this was a G2 like setup where I was accessing a URL as
/latestupdates/PHOTO_NAME instead of /album/name/PHOTO_NAME, I could
understand the need to show it as part of the virtual album. But in
G3, once I've clicked to a full URL, the fact that I was once upon a
time in /latestupdates/ presumably shouldn't matter; there's no
indication to the user who see /album/name/PHOTO_NAME in his browser
that the information is being calculated as though he's paging through
latestupdates's listing.

That said, without disabling the call to Cache::instance()->set() in
set_display_context_callback (in modules/gallery/helpers/item.php),
I'm not sure how to fix this.

Any ideas?

-- Mike

------------------------------------------------------------------------------
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnnow-d2d
__[ g a l l e r y - d e v e l ]_________________________

[ list info/archive --> http://gallery.sf.net/lists.php ]
[ gallery info/FAQ/download --> http://gallery.sf.net ]