Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

I think I found the bug -- code explanation needed


rudolfl

Recommended Posts

Hi, all

 

I have a weird problem in admin area. (osComemrce 2.2-MS2)

When I look at some of my products, I can not see category they are in. For example, I have item1 in category1. I want to copy it to category2. When I click on Copy button, I see that item1 is only in Top category. Looking at database, I can see that item1 in category1. Some items behave normally, some not.

 

Time to look at the code.

/admin/categories.php about line 1126, there is following code that is being processed when someone clicks on Copy button:

 

case 'copy_to':

$heading[] = array('text' => '<b>' . TEXT_INFO_HEADING_COPY_TO . '</b>');

 

$contents = array('form' => tep_draw_form('copy_to', FILENAME_CATEGORIES, 'action=copy_to_confirm&cPath=' . $cPath) . tep_draw_hidden_field('products_id', $pInfo->products_id));

 

I tried to look at $pInfo. When I have an issue, it is NULL, explaining why I have the problem. But I can not find place where this pInfo is getting information about the product. I can not find a place where is is being declared or initialised!!! Can someone enlighten me where this variable is being set?

 

Thanks a lot,

Rudolf

Link to comment
Share on other sites

$pInfo is defined in several places. The definition used depends on what you have done before.

 

2.2MS2 is very old code with many bugs and security vulnerabilities. You should consider replacing it with a modern version, such as 2.3.1. If you really want to keep this old code, there is an Addon to upgrade it to 2.2RC2a, and you can then apply the patches for 2.3.1 using the upgrade document in that package. I wouldn't waste time trying to debug this ancient code until you've done the upgrades.

 

Regards

Jim

See my profile for a list of my addons and ways to get support.

Link to comment
Share on other sites

My steps are simple:

1. Search for a product.

2. Click on the product I want.

3. Click on Copy

 

I was thinking about upgrade, but I quite heavily modified the site, so upgrade is not an easy thing. I will look at the add-on yo mentioned and see if I can apply the changes.

Another problem is -- our busiest season is starting, so I do not want to modify the site yet. I will be doing it after season ends.

 

In the meantime, I will really appreciate if someone can tell me where that pInfo is supposed to be initialised. At the moment I put dirty hack in that ignores pInfo and reads product ID from GET variables, but would like to fix the root of the problem.

 

Thanks,

Rudolf

 

 

$pInfo is defined in several places. The definition used depends on what you have done before.

 

2.2MS2 is very old code with many bugs and security vulnerabilities. You should consider replacing it with a modern version, such as 2.3.1. If you really want to keep this old code, there is an Addon to upgrade it to 2.2RC2a, and you can then apply the patches for 2.3.1 using the upgrade document in that package. I wouldn't waste time trying to debug this ancient code until you've done the upgrades.

 

Regards

Jim

Link to comment
Share on other sites

Search for $pInfo = in the code. As I said, it's used in several places. Add print_r($pInfo); after each one to see what it's been set to. That will eventually lead you to the problem.

 

If my memory is correct, there's a bug in the search function on that page, so that may be your problem. I don't recall a code fix. I think I just used the pulldown to find the product category, since that always works.

 

Regards

Jim

See my profile for a list of my addons and ways to get support.

Link to comment
Share on other sites

Hi,

 

Jim, I think you are right about bug in search.

If search returns more than 1 result, COPY TO button of first result has a link with 'cID' in it that is of the last search result. If first item is not part of that last category, then I have problem. pInfo is supposed to be filled with information from database and information is extracted for a product with certain category and product id. In my case, there will be no such as product (as category id is wrong). So, whole thing would go south.

 

Recently I had to have duplicates of some products. Not a copy, but duplicates. With copies, I would not see the fault, but with duplicates I do.

 

Now to finding a way to fix it properly.

 

Rudolf

Link to comment
Share on other sites

Fixed.

 

When infobox with product details is rendered, category ID for the links is taken from $cPath which is wrong at this instance. Should be taken from $pInfo->categories_id instead. Then all is good.

 

Rudolf

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...