Topic: Undefined Offset?

When I try to delete a couple of files I'm getting this:

And the files are not deleted.
Never happened before.

Re: Undefined Offset?

It looks like you might be reaching your PHP max_input_vars limit.
Each image in a Showkase gallery page has 6 different variables associated with it so in order to process a large gallery, you will need to ensure that max_input_vars is at least 6 x the number of images in the gallery.
For example, if you have a gallery with 200 images, then the max_input_vars will need to be at least 1200.
I notice in your screenshot that the undefined offsets begin at 166 which equates to a max_input_vars value of 996 (166 x 6 = 996) so it sounds like your max_input_vars might currently be set to 1000 (and it needs to be higher for your site).

You should be able to check your PHP settings using phpinfo() as follows:

  • Create a new file in a plain text editor with the following code: <?php phpinfo(); ?>

  • Save the file with a .php file extension (for example, 'phpinfo.php').

  • Upload the file to your web server and open it in a browser.

You should be able to change PHP values using a php.ini file, via an .htaccess file or via your web hosting online Control Panel.
If you have trouble changing any PHP values, your web host should be able to help you out.

Hopefully increasing max_input_vars will solve your problem.

If this does not help, then here are other things that you can try.

(1) Please try installing and running the Showkase Server Compatibility Test to check that your server has all the features Showkase needs.
If any of the tests fail, there are troubleshooting tips on the test's support page (link above).
Even if you ran the test before installing Showkase, please try again in case your web host has made any changes recently.

(2) If you are not already using the latest version of Showkase (v1.6.1), please try upgrading to see if this helps.
For a list of changes between versions, please see the Version History.
Full instructions for upgrading Showkase can be found here.

(3) Try going to 'System -> Repairs' and clicking the 'Repair' button to rebuild the page records.

(4) If the error message happens only when deleting images from certain gallery pages, try editing the pages in question, going to the 'Advanced' tab and clicking the 'Rebuild' button to rebuild the gallery.

(5) Check and increase your PHP memory_limit directive (in a similar way to max_input_vars above).

(4) If none of the above helps, then try running Showkase in debug mode to see if a more informative error message is displayed when the problem occurs.
Open your 'showkase/admin/settings/constants.php' file in a plain text editor and change line 12 from:

define('DEBUG', false);

... to:

define('DEBUG', true);

This should help to track down the exact cause of the problem.
Please note that the line number above refers to the current version of Showkase (v1.6.1).

I would also recommend that you make a complete backup of your site before you change anything, just in case anything goes wrong and you need to reinstate the original files at a later date.

I hope one of my suggestions above helps to solve your problem.

3 (edited by mrjw34 2017-01-21 00:45:00)

Re: Undefined Offset?

Using the latest Showkase.
I changed the max_input_vars to 1200. There are around 180 images in this gallery.
Still get the problem.
Did Repairs. Still there.
Turned on Debug and get an additional line of: (, line 132)

So a complete line would read:
Notice: Undefined offset: 166 (, line 132)

Line 32 of that file is:
$this->imageObjects[$key]->setImageAttributes($titles[$key], $captions[$key], $links[$key], $targets[$key], $purchase[$key], $i);

Re: Undefined Offset?

Thanks for the additional information.

The line you noted above sets several attributes for each image so it certainly looks like my initial suggestion regarding max_input_vars might be in the right ballpark.
Try increasing max_input_vars further (to something much larger such as 2000) to see it this solves the problem.
If I was out by just one and max_input_vars needs to be 7 x the number of images, then 1200 would not be enough for a 180 image gallery.
I was pretty sure that 6 x the number for images is all that should be required when I posted earlier but there is no harm in trying a larger amount in case I was wrong. What you say in your latest post certainly points towards a low max_input_vars being the cause of the problem.

I have just done some testing of my own and in a gallery of 33 images, a max_input_vars of 200 results in an undefined offset (when clicking 'Save' on the 'Images' page tab) but a max_input_vars of 201 works fine. Neither 200 nor 201 divide exactly by 33 but they are both just over 6 so trying a larger value (such as 7 x the number of images) might yet work.

Also, if you have not yet tried increasing your PHP memory_limit, this might also be worth a shot.

Re: Undefined Offset?

Finally had a chance to get back to this.
Increased max_input_vars  to 2500. Still happens.
Changed memory_limit from 128m to 256m. Still happens.

Sort of frustrating.

Re: Undefined Offset?

I'd be happy to investigate further but it would help if I had access to your web server and Showkase site.
If you are agreeable to this, then please let me know and I will send you an email address where you can forward me your FTP and Showkase login details.

In the meantime, how are you setting your PHP directives? It might be worth checking (with phpinfo() to see if the new values are actually being used.

Also, try running the Showkase Server Compatibility Test. Even if you ran the test before installing Showkase, please try again in case your web host has made any changes recently. The results might give us a clue as to the nature of the problem.

Re: Undefined Offset?

Thank you very much for taking the time to resolve this issue.

I have galleries with literally thousands of images, for which I need to use the file name for titles. But it was not working as I expected, and was becoming a real headache.

The solution for max_input_vars, using .htaccess to up the number to 20,000 variables, my server was set to 1,000. The problem was solved, and what I saw as an insurmountable problem and on the surface a limitation of showKase / JuiceBox, was in fact just a limitation of my host.

I can not express my happiness when 4,000 images were titled in literally seconds, and that was just one page!

php.ini was not available for me to edit, but the .htaccess trick with the line "php_value max_input_vars 20000" sorted it out.

Absolutely delighted, thanks for the great support.

Re: Undefined Offset?


I'm really glad that you've been able to find the solution to your problem here in the forum (and that the fix was an easy one).
Thank you for sharing your experience!

Incidentally, according to this web page, the default value for max_input_vars is 1,000 so it looks like your web host was just using the default value (rather than purposely choosing a low value).

In any case, I'm happy to hear that your Showkase site is running well!