[ic] Standard catalog forum bug
Gert van der Spoel
ic at 3edge.com
Wed Mar 15 19:01:32 EST 2006
Salvador Caballe writes:
I found a problem in forum products, when you send a new product
comment always erases the old comment.
This is caused by the following snippet of code in
'pages/forum/submit.html':
if($CGI->{parent}) {
my $existing = $db->query("select * from forum where parent =
'$CGI->{parent}'");
if($existing and ! @$existing) {
$v{artid} = $CGI->{parent};
$code = $CGI->{parent};
$v{parent} = 0;
}
else {
$v{parent} = $CGI->{parent};
}
}
1) In 'include/forum/submit_form' (which is called in submit.html) the
following line can be found:
<input TYPE="HIDDEN" NAME="parent" VALUE="[loop-code]">
Suppose the product SKU is XXX then parent is automatically set to
XXX (loop-code is the mv_arg that is passed from the flypage)
2) Basically $CGI->{parent} therefor always exists so the loop if above is
always true.
3) First time you come the database has no entries so the following line:
my $existing = $db->query("select * from forum where parent =
'$CGI->{parent}'");
will not be giving any results so the if construction becomes true setting:
$code = $CGI->{parent};
$v{parent} = 0;
4) You submit and go back to the product page
5) You do another comment and 2) directly goes
6) Second time you come the database has 1 entry, but we have set parent to
0 ... So once again $existing will not be giving any results in this case
setting $code to $CGI->{parent}; ... The table is having code being the
primary unique key .. so it will be overwriting the previous item.
I've created the following workaround (patchfile below):
- old:
my $existing = $db->query("select * from forum where parent =
'$CGI->{parent}'");
- new:
my $existing = $db->query("select * from forum where parent =
'$CGI->{parent}' or (parent = '0' and code = '$CGI->{parent}')");
This seemed to work on the quick test I've done to check it. I think the
issue is more on a technical design level where you can have more than 1
comment starting a thread, but the display and database seem to hang on the
code / sku to be present at least once before displaying.
Oh and I don't know if the 'or' in the sql statement is causing a problem on
other databases.
Anyway hope this helps sorting your issue.
CU,
Gert
Index: submit.html
===================================================================
RCS file: /var/cvs/interchange/dist/standard/pages/forum/submit.html,v
retrieving revision 1.5
diff -u -r1.5 submit.html
--- submit.html 22 Sep 2005 18:00:31 -0000 1.5
+++ submit.html 15 Mar 2006 23:55:48 -0000
@@ -145,7 +145,8 @@
my $code;
if($CGI->{parent}) {
- my $existing = $db->query("select * from forum where parent
= '$
CGI->{parent}'");
+ my $existing = $db->query("select * from forum where parent
= '
$CGI->{parent}' or (parent = '0' and code = '$CGI->{parent}')");
+
if($existing and ! @$existing) {
$v{artid} = $CGI->{parent};
$code = $CGI->{parent};
More information about the interchange-users
mailing list