Re: Odd link problem after upgrade
G'day Rob,
Methinks I'm getting closer.
Check your file
/includes/functions/html_output.php
Specifically look for the lines that follow
// clean up the link before processing (line#72) and
// clean up the link after processing (line#91)
This is where the URL strings are cleaned up.
Also, double check that this file is the *correct* one.
There is another similar file, also called html_output.php in the /admin/includes/function/ folder.
I image it would be quite easy to edit the wrong one of these two files if not careful (much like the two configure.php files).
Although not pretty, if you find the line
return $link ; (line #96) then just befor that add
echo $link ;
You'll see all the links being dumped to screen (when you visit the site) with or without the errors.
Also, in the lines before that you'll see several places where the ampersands get manipulated/processed. If you comment out these one by one (with the echo line still in place) you will be able to quickly narrow down exactly which one of these is causing the problem... That assuming you need to continue to fault find rather than replacing the offending file.
Back in your hands now :)
Cheers
Rod
Re: Odd link problem after upgrade
Thanks Rod. You poked me in the right direction.
I checked the /includes/functions/html_output.php file against a clean copy from my untouched 1.3.9h files and it is, as I suspected, just the default one. I also checked all mods installed, and the few that added anything to the includes/functions folder did so correctly, by using the extra_functions folder, and none of them modified that particular file anyway. But...
Looking at that file, just above where you said to insert the echo line (which I tried, but no lightbulbs went off over my head), I saw this line...
$link = preg_replace('/&/', '&', $link);
I'm not much of a hand at PHP but that seemed to me to be replacing an escaped ampersand with the offending HTML entity ampersand. So I commented that line out and reloaded the page. Et voila! The problem disappeared, all links seem to be written correctly and all work correctly.
I think it's safe to leave everything like this, since there is clearly another line above that one which is concatenating any extra ampersands properly. I'll test all the way through an order just to be sure. But now the question becomes, why would I have to do that to a default ZC file which works fine as is on other sites? Or maybe, why was the New Products For [Month] box bypassing that clean up routine when it too is standard ZC? Or maybe the real question is, how many lines of code does Zen Cart contain? :shocking:
Rob
Re: Odd link problem after upgrade
Quote:
Originally Posted by
rstevenson
Looking at that file, just above where you said to insert the echo line (which I tried, but no lightbulbs went off over my head), I saw this line...
$link = preg_replace('/&/', '&', $link);
I was wondering about that too. Hense my suggestion to comment out such lines one by one until you find the 'right' one. :)
Quote:
Originally Posted by
rstevenson
I'm not much of a hand at PHP but that seemed to me to be replacing an escaped ampersand with the offending HTML entity ampersand. So I commented that line out and reloaded the page. Et voila! The problem disappeared, all links seem to be written correctly and all work correctly.
I think it's safe to leave everything like this,
I'd like to seek advice from the dev team before I'd be assuming this is 'safe'.
Quote:
Originally Posted by
rstevenson
since there is clearly another line above that one which is concatenating any extra ampersands properly. I'll test all the way through an order just to be sure. But now the question becomes, why would I have to do that to a default ZC file which works fine as is on other sites? Or maybe, why was the New Products For [Month] box bypassing that clean up routine when it too is standard ZC?
These are questions I also asked myself, which is why my gut feeling is that this 'fix' is actually *hiding* the real source of the problem (which I've not been able to duplicate). Hiding the symptom without knowing the cause is risky business. It would be interesting to know/see what the $link variable looks like as it entered this function. It probably contains some kind of weird character or formatting that isn't being correctly processed during the pre-processing, which in turn would indicate the additional code is needed to take care of such situations. The post processing (the line you have commented out) is/was actually doing what it was supposed to be doing in 'trapping' such errors before they could cause any damage.
Input from one of the dev team is probably essential at this point.
Cheers
Rod
Re: Odd link problem after upgrade
I've done a rather cursory quick-read of this thread.
What I'm not clear about is the origin of the problem.
Does the problem manifest when using only core ZC files? Or only when using a certain addon?
Re: Odd link problem after upgrade
Well, the core files work fine of course, so it has to be one of the add-ons. But the problem exists in the New Products For May section on any page that displays that, but doesn't manifest itself in any other link, not even the New products... links.
What I'd better do is un-comment that "fix" and then switch to the Classic template just to make sure. Just a sec ... ... .
As expected, the Classic template outputs the New Products For May links just fine. So it's coming from a mod. Now how do I find out which one? Most of the mods installed would have nothing to do with outputting links. Here's a list of them in case you can spot a likely culprit...
Admin Login As Customer 2.2
Blank_Sidebox_2.0
categories_dressing_2-7-3
column_divider_pro_cdp_v0-4
credit_card_by_phone_or_fax_ccbyfax_1-8b
currency_dropdown_header
Direct Bank Deposit v1.1
EasyPopulate-4.0-9773477 (just for downloads)
Geotrust
HoverBox
LiveHelp
netregistry
ozpost_V2-0-5
reward_point_full_suite_1-33a
reward_points_page 1.0
search_log_2-1
single_listing_template_1-8
Rob
Re: Odd link problem after upgrade
Quote:
Originally Posted by
rstevenson
As expected, the Classic template outputs the New Products For May links just fine. So it's coming from a mod. Now how do I find out which one?
Disable them one by one until the problem goes away :)
Quote:
Originally Posted by
rstevenson
Most of the mods installed would have nothing to do with outputting links. Here's a list of them in case you can spot a likely culprit...
If I had to take a punt on where to start, I'd go for:
1) categories_dressing_2-7-3
2) column_divider_pro_cdp_v0-4
I've only included 2) because I know nothing about this one.
Categories dressing is my first choice for 2 reasons. 1) It was developed for Zen 1.3.8 and hasn't had an update since 2009, which makes it pretty ancient, and 2) it is the only one in the list that appears to have anything to do with the category links, and since 'new products' is essentially just another category type it wouldn't be hard to imagine how this could get things a little wrong.
This really is nothing more than a stab in the dark though.
Cheers
Rod
Re: Odd link problem after upgrade
Quote:
Originally Posted by
RodG
... and 2) it is the only one in the list that appears to have anything to do with the category links, and since 'new products' is essentially just another category type it wouldn't be hard to imagine how this could get things a little wrong.
Just want to make sure we're not talking at cross purposes here. "New products...", the link down at the bottom of the left column, below the Categories links, goes to a page on which all the links work fine. The problem is showing up only in the New Products For May box, on any page which shows that box.
I'll check with the site owner about disabling the mods one by one. But I'll try those two first.
Rob
Re: Odd link problem after upgrade
Okay, we can eliminate the Categories Dressing mod from consideration. It was working in a previous template but is not used in this one. Also I tested the Column Divider Pro mod and removing it had no effect on the problem.
Rob
Re: Odd link problem after upgrade
Two down, sixteen to go... Hmm, make that 15... you can eliminate ozpost. :)
These can probably be rules out too.
-------------
credit_card_by_phone_or_fax_ccbyfax_1-8b
currency_dropdown_header
Direct Bank Deposit v1.1
EasyPopulate-4.0-9773477 (just for downloads)
--------------------
Cheers
Rod
ps. Don't forget to clear your cache after removing/changing ANY of the modules. (Shift F5 is usually enough). I've lost count of the number of times I've changed something and seen no immediate difference, and gone around and around in circles as a result. :(
Re: Odd link problem after upgrade
I think I found it. In the Single Listing Template mod, in the file includes/modules/TEMPLATE/new_products.php the bit of code that collects up the product id is this...
'cPath=' . $productsInCategory[$new_products->fields['products_id']] . '&products_id=' . $new_products->fields['products_id']
But in the file includes/functions/extra_functions/index_listing.php, it's this...
'cPath=' . $productsInCategory[$products->fields['products_id']] . '&products_id=' . $products->fields['products_id']
Note the ampersand as an entity instead of just an ampersand.
Now to change that and see what happens... ... ... . Bingo! That fixed the problem -- correctly, this time, I think.
Thanks Rod for the pushes in the right direction.
Rob