Search…

X3 Photo Gallery Support Forums

Search…
 
locher
Topic Author
Posts: 14
Joined: 17 Jan 2011, 11:57

"Undefined index" error on custom sort

14 Nov 2016, 06:09

Hi,

I've encountered an error while using the custom sort order in the gallery.
I ordered images manually on the "Gallery" tab and then selected "Sort Images by = Custom"  in the settings of the gallery module of the page.

When I open this gallery I see the following error after page's description, before the actual gallery:

Notice: Undefined index: in /home/www/z114793/htdocs/x3/extensions/twig-extensions.inc.php on line 170 Notice: Undefined index: in /home/www/z114793/htdocs/x3/extensions/twig-extensions.inc.php on line 170 Notice: Undefined index: in /home/www/z114793/htdocs/x3/extensions/twig-extensions.inc.php on line 170 Notice: Undefined index: in /home/www/z114793/htdocs/x3/extensions/twig-extensions.inc.php on line 170
This may be seen here: http://locher.ru/travel/europe/spain/toledo_cs/
The same gallery with the default, name-based sort works fine (http://locher.ru/travel/europe/spain/toledo/)
 
User avatar
mjau-mjau
X3 Wizard
Posts: 13998
Joined: 30 Sep 2006, 03:37

Re: "Undefined index" error on custom sort

14 Nov 2016, 11:00

First of all, this is a NOTICE not an error. It wouldn't display if your server had normal error_reporting without reporting "notices", which do no harm.

Of course, I would like to look into this. Could be PHP 5.3 related ... I can't seem to reference the error "on line 170" to anything related to sorting. Could you please send me your twig-extensions.inc.php file? I would like to see what is there just to make sure.

For version 0.20.1, twig-extensions.inc.php from line 168-170 looks like this:
Code
function shortcode($value) {
    return str_replace('[contact]',
    "<form data-abide class=contactform>
...
This has nothing to do with any custom sorting.

Thanks for reporting.
 
locher
Topic Author
Posts: 14
Joined: 17 Jan 2011, 11:57

Re: "Undefined index" error on custom sort

14 Nov 2016, 12:01

Strange... my version of twig-extensions.inc.php has the following at 168-173, this looks exactly sorting related. 
 public function custom_str_sort($a, $b) {
  $x = $a[$this->sortby_value] ?: $a[$this->sortby_default_value];
  $y = $b[$this->sortby_value] ?: $b[$this->sortby_default_value];
    return strnatcasecmp($x, $y);
    //strnatcmp($a[$this->sortby_value], $b[$this->sortby_value]);
  }
The full file is at http://locher.ru/extensions/twig-extensions.inc

Is there any way to change the notice reporting behaviour of the server?
 
User avatar
mjau-mjau
X3 Wizard
Posts: 13998
Joined: 30 Sep 2006, 03:37

Re: "Undefined index" error on custom sort

14 Nov 2016, 13:35

Sorry my fault, I was mixing two different twig-extension files. The code in your file is correct. Question: Did you add new images after you initially made the custom sort and saved?

I think we can conclude the following:
  • You may have added new files after you did an initial custom sort, and new images will not contain a sort index. How many images do you see in that page from the panel?
  • Since you have error_reporting = ALL, your PHP will output this as a notice when it encounters images without a sorting index.
Of course, none of the above is your fault. Can you try to go to the gallery tab for that page in panel, click to "Custom sort", and click "save", and see if that sorts out the issue?

In either case, I will look into it within a few days.
 
locher
Topic Author
Posts: 14
Joined: 17 Jan 2011, 11:57

Re: "Undefined index" error on custom sort

15 Nov 2016, 05:28

Question: Did you add new images after you initially made the custom sort and saved?
Well, the gallery tab has the "custom" sort mode initially, i.e. when I create an empty folder (don't know where the default for this behaviour is set) it is on "custom" by default. When I upload the pictures it stays on "custom", so I reorder some of uploaded pictures and click "save" at the bottom. Since the default for "sort images by" in the gallery is "name", the custom order is not effective in the page view. So, I go to the gallery module settings for the page, change sort order there from "name" to "custom", save the settings, reload the page - and see the correct order of the pictures - but the notice is displayed above them. 
Can you try to go to the gallery tab for that page in panel, click to "Custom sort", and click "save", and see if that sorts out the issue?
Nope, it does not.
 
User avatar
mjau-mjau
X3 Wizard
Posts: 13998
Joined: 30 Sep 2006, 03:37

Re: "Undefined index" error on custom sort

15 Nov 2016, 06:00

Well, the gallery tab has the "custom" sort mode initially, i.e. when I create an empty folder (don't know where the default for this behaviour is set) it is on "custom" by default. When I upload the pictures it stays on "custom", so I reorder some of uploaded pictures and click "save" at the bottom.
This has nothing to do with your settings, and is just the "current view state" of your gallery tab, which is stored/remembered in your browser. Even if it's set to "custom", it does not mean your images will use the custom sort, until you actually set custom sort in gallery settings.

Anyway, nothing wrong in what you are doing. I will look into this issue within tomorrow.
 
User avatar
mjau-mjau
X3 Wizard
Posts: 13998
Joined: 30 Sep 2006, 03:37

Re: "Undefined index" error on custom sort  Topic is solved

16 Nov 2016, 07:36

This issue has now been fixed in X3 Release [0.21.2]
https://forum.photo.gallery/viewtopic.php?f=51&t=9157

The problem was because CUSTOM sorting index for images has no $default value ... Either an image is sorted or not. Since you had error_reporting set to display notices, "undefined index" for $default is output in the document. This is fixed now.