photo / frontend

The official @github repository of the Trovebox frontend software. A photo sharing and photo management web interface for data stored "in the cloud" (i.e. Amazon S3, Rackspace CloudFiles, Google Storage).
https://trovebox.com
Apache License 2.0
1.37k stars 244 forks source link

Missing Photos in default Album Listing, even after successful upload PLUS duplication of some other photos #1576

Open ashwingj opened 9 years ago

ashwingj commented 9 years ago

I created an album containing 96 photos (actually it was 97 and i deleted one). Then i noticed

Other symptoms

Looks like a paging bug.

ashwingj commented 9 years ago

On dumping the $filters variable in the ApiPhotoController list_() function I noticed that

  1. On initially clicking on the Album and performing a page load $filter is
{"sortBy":"dateUploaded,desc","album":"7","returnSizes":"960x180,870x870,180x180xCR","__route__":"\/photos\/album-7\/list"}
  1. Scrolling down to the end of the Album causes the incremental load json query, which results in $filter being
{"sortBy":"dateTaken,asc","album":"7","__route__":"\/photos\/album-7\/list.json","returnSizes":"960x180,870x870,180x180xCR","page":"2"}

Surprising that the sortBy is different on the incremental load

ashwingj commented 9 years ago

The PhotoController::list_() function seems to want to set 'dateTaken,asc' behaviour when listing an Album OR Tag versus default listing ... See code snippet below

    if($isAlbum || $isTags)
    {
      if(!isset($getParams['sortBy']))
        $additionalParams['sortBy'] = 'dateTaken,asc';

      if($isAlbum)
        $additionalParams['pageSize'] = '0';
    }

This IF condition is however not entered and $isAlbum and $isTag are both raising PHP Notice: Undefined variable errors in the error log. Could this be the problem?

ashwingj commented 9 years ago

While looking for client side behaviour, came across this code (4.0.2\tbx.js)

          load: function() {
            var _this = TBX.init.pages.photos, async = typeof(arguments[0]) === 'undefined' ? true : arguments[0], concat = _this.pageLocation.search.length == 0 ? '?' : '&';
            // since sort order for the API is static and onload changes the sort order for albums and gallery we need to mimic the controller behavior in JS
            if(_this.pageLocation.search.search('sortBy') === -1) {
              if(_this.pageLocation.pathname.search('/album-') === -1) // gallery
                _this.pageLocation.search += concat + 'sortBy=dateUploaded,desc';
              else // album
                _this.pageLocation.search += concat + 'sortBy=dateTaken,asc';
            }

            util.load(_this, async);
          },

This looks contrary to the server side code. The 'dateTaken,asc' behaviour is applied only to album listings. Tag listings (/tags-) and gallery listings both default to dateUploaded.

As expected, I cannot reproduce the original bug in either the gallery listing or tag listing as the incremental loads maintain the sorting behaviour of the initial load.

ashwingj commented 9 years ago

@jmathai, I can't find where $isAlbum and $isTag are to be set (on the server side). A simple text search of the code did not reveal any place where either of those variables were being assigned. Can you perhaps shed some light?