Forums / Bug Reports / Admin page access fails with too many redirects

Admin page access fails with too many redirects

Views: 5,685

Results 1 to 20 of 29
6 Jul 2014, 12:02 PM
#1
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,718
Plugin Contributions:
56

Admin page access fails with too many redirects

The database configuration table row for SESSION_WRITE_DIRECTORY keeps getting reset to <my-renamed-admin>/includes/cache, and the admin page would not load until I created this directory and made it writable.

That Software Guy. My Store: Zen Cart Support
Available for hire - See my ad in Services
Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
Do you benefit from Zen Cart? Then please support the project.

6 Jul 2014, 1:25 PM
#2
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Admin page access fails with too many redirects

I've not seen this happen, at least not on a multitude of linux servers. What's your environment?

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

6 Jul 2014, 1:32 PM
#3
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,718
Plugin Contributions:
56

Re: Admin page access fails with too many redirects

Fedora Core 13, Apache, PHP 5.3.15.

That Software Guy. My Store: Zen Cart Support
Available for hire - See my ad in Services
Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
Do you benefit from Zen Cart? Then please support the project.

6 Jul 2014, 10:02 PM
#4
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Admin page access fails with too many redirects

I just did a test by changing the value for SESSION_WRITE_DIRECTORY to point to an invalid folder. Then went to the admin URL and it let me log in and work fine without any unexpected redirects.

Help me trigger the problem. Were you starting from a point of having just an import of an old database which had the wrong SESSION_WRITE_DIRECTORY set? Or was it an old configure.php that was pointing to wrong folders too? or both?

I would assume that all of the logic for the symptom you're reporting is handled by /admin/includes/init_includes/init_cache_key_check.php
Upon looking at it I can only think of one thing that might be a problem, and that's if you had put the init_cache_key_check.php file into the init_includes/overrides folder for some reason ... in which case it might generate the wrong path. We'll consider addressing that in a future version, but there should be no need to do an override on that file, so that issue feels minor.

Not sure how exactly to trigger what you're reporting though.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

6 Jul 2014, 10:07 PM
#5
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,718
Plugin Contributions:
56

Re: Admin page access fails with too many redirects

The only thing old was an old configure.php file, which I pulled from my 151 installation and updated the catalog dir, logs dir, db, etc. I didn't notice any new entries in this file that were added since 1.5.1, but maybe I missed something. The file is attached.

A new db with test data was used. No other changes from vanilla 1.5.3 were made.

That Software Guy. My Store: Zen Cart Support
Available for hire - See my ad in Services
Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
Do you benefit from Zen Cart? Then please support the project.

6 Jul 2014, 10:14 PM
#6
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Admin page access fails with too many redirects

Hmmmm. Even testing with that I can't seem to trigger it. :(

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

6 Jul 2014, 10:19 PM
#7
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,718
Plugin Contributions:
56

Re: Admin page access fails with too many redirects

If I rmdir , and then set SESSION_WRITE_DIRECTORY configuration_value to "/tmp" it happens.
I have to mkdir <my cart dir>/<my admin dir>/includes/cache then chmod 777 to make it work.

That Software Guy. My Store: Zen Cart Support
Available for hire - See my ad in Services
Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
Do you benefit from Zen Cart? Then please support the project.

6 Jul 2014, 11:00 PM
#8
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,718
Plugin Contributions:
56

Re: Admin page access fails with too many redirects

Why would SESSION_WRITE_DIRECTORY get set to <admin_dir>/includes/cache, a directory which doesn't exist in the default installation in the first place?

That Software Guy. My Store: Zen Cart Support
Available for hire - See my ad in Services
Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
Do you benefit from Zen Cart? Then please support the project.

7 Jul 2014, 5:46 AM
#9
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Admin page access fails with too many redirects

Okay, I've triggered it.
And I see why it's doing it. (wrong logic detecting the root folder, and then a redirect that always happens if the folder is missing. So ... don't delete the folder :P )
Now the challenge is determining how critical it is.

Wondering what the workflow process was that got you to the point of deleting the cache folder?

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

7 Jul 2014, 10:02 AM
#10
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,718
Plugin Contributions:
56

Re: Admin page access fails with too many redirects

The value of that db row when it's created is "/tmp". There is no admin/includes/cache folder in the default installation. So why did it get changed to a folder which doesn't exist?

That Software Guy. My Store: Zen Cart Support
Available for hire - See my ad in Services
Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
Do you benefit from Zen Cart? Then please support the project.

7 Jul 2014, 4:10 PM
#11
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Admin page access fails with too many redirects

  1. It's a bug.
  2. It's an attempt to integrate the logic for fix_cache_key into core so people don't need to run that separate util if they switch servers.
  3. This is what it was doing:
  • if the directory named by SESSION_WRITE_DIRECTORY doesn't exist, it was detecting what folder the script was running in so that it could guess what the correct "store root" was, and then appending /cache to it (since if the one in the db didn't exist then the best guess after that is /cache). The bug is that the file doing the detection is 2 levels under the admin folder, and thus was incorrectly guessing that it needed to use /admin/includes/ instead of just /

**It's easy to avoid encountering the bug:

  • create the /cache folder (or any other writable folder)
  • set SESSION_WRITE_DIRECTORY to point to it**

The fix to have it guess the correct /cache folder is to change the file I mentioned above, and alter the realpath(dirname(__FILE)) to be realpath(dirname($_SERVER['SCRIPT_FILENAME'])) .... but the redirect will still happen if you don't actually have the /cache folder.

But I'm reluctant to commit a code fix for the above, because I'm wondering if the original need for this has maybe expired, and even using fix_cache_key may no longer be necessary, given that sessions are now only stored in the database, not the filesystem.
Further research is required to determine the optimum solution.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

7 Jul 2014, 4:13 PM
#12
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,718
Plugin Contributions:
56

Re: Admin page access fails with too many redirects

What if you just set the default value for SESSION_WRITE_DIRECTORY in the mysql script to DIR_FS_CATALOG/cache? That exists.

That Software Guy. My Store: Zen Cart Support
Available for hire - See my ad in Services
Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
Do you benefit from Zen Cart? Then please support the project.

7 Jul 2014, 4:49 PM
#13
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Admin page access fails with too many redirects

Will consider it.

It's just strange that in all the testing we've done with multiple environments and upgrades we never triggered this issue.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

7 Jul 2014, 4:58 PM
#14
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,718
Plugin Contributions:
56

Re: Admin page access fails with too many redirects

ok. I created the known bugs in 1.5.3 thread and added a pointer to this thread.

That Software Guy. My Store: Zen Cart Support
Available for hire - See my ad in Services
Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
Do you benefit from Zen Cart? Then please support the project.

7 Jul 2014, 5:41 PM
#15
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Admin page access fails with too many redirects

Here's a replacement file which should resolve the issue:
Simply unzip and upload to your server as **/admin/includes/init_includes/init_cache_key_check.php

THIS FILE SHOULD ONLY BE USED ON ZC v1.5.3. .... DO NOT put it on any other version!**

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

8 Jul 2014, 1:19 AM
#16
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,718
Plugin Contributions:
56

Re: Admin page access fails with too many redirects

I wonder if the issue is that the /cache folder by default isn't writable. Could the installer check this condition and block progress as it does with configure.php files?

That Software Guy. My Store: Zen Cart Support
Available for hire - See my ad in Services
Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
Do you benefit from Zen Cart? Then please support the project.

8 Jul 2014, 4:16 PM
#17
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Admin page access fails with too many redirects

swguy:

I wonder if the issue is that the /cache folder by default isn't writable. Could the installer check this condition and block progress as it does with configure.php files?
It does already point out that the folder isn't writable when running zc_install, on the System Inspection page.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

14 Jan 2015, 10:01 AM
#18
heathenmagic avatar

heathenmagic

Totally Zenned

Join Date:
May 2005
Location:
England
Posts:
733
Plugin Contributions:
0

Re: Admin page access fails with too many redirects

Hello there,

I originally posted here, when I first noticed the error it was a blank page, and then I went to 1.5.4 and it was 'too many redirects' on admin.

http://www.zen-cart.com/showthread.php?215767-Admin-suddenly-blank-page&highlight=blank+admin

I am going crazy here, lol. I have found this thread and can see there must be something wrong with my setup. I have had the same cache directory pointed to for ten year in configure:-

define('DIR_FS_SQL_CACHE', '/home/******/public_html/cache');

Is there a way to stop this check? I am sure the above is valid, I haven't changed it. I created more cache folders in admin as swguy put, and all permissions are 777. Hope somebody may be able to help please. thanks in advance.

14 Jan 2015, 5:17 PM
#20
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Admin page access fails with too many redirects

So where is it at now?

  • what ZC version are you using?

  • which init_cache_key_check.php file are you now using?

  • are you actually getting just "blank page"? or are you really getting the "too many redirects"?

  • Is your webserver running Linux/Ubuntu/CentOS/Windows/... what? If you don't know the answer to that, normally you could get it via your Admin, but since that's where your problem is, you could ask your hosting company to tell you what operating-system your server is using. They can answer the PHP questions too, if you don't know the answers:

  • what's your PHP version? Is it running "PHP as CGI"? or "suPHP"? or simply as an Apache module?

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.