Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

How to do.diff


pdh

Recommended Posts

Posted

Can somebody tell me (in simple language) how to use a diff file from a contribution to modify a file rather than just replacing it. Sorry if this is a real newbie question but I just haven't got a clue.

 

Paul.

Posted

Usually the contribution will say something like "Find this code at line XX." The line numbers rarely match, at least in my shop, but the code can be found with a search. There's no way to do a search and replace automatically since each shop is potentially different. A person has to look at the code to decide exactly where it should go.

 

Another way to find the changes is to use a program like Compare & Merge or Beyond Compare. They both have trial periods but are not free. There are some free, less easier to use, ones available too.

 

Jack

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

All of My Addons

Get the latest versions of my addons

Recommended SEO Addons

Posted
Usually the contribution will say something like "Find this code at line XX."  The line numbers rarely match, at least in my shop, but the code can be found with a search.  There's no way to do a search and replace automatically since each shop is potentially different.  A person has to look at the code to decide exactly where it should go.

 

Another way to find the changes is to use a program like Compare & Merge or Beyond Compare.  They both have trial periods but are not free. There are some free, less easier to use, ones available too. 

 

Jack

 

This contribution has a file called categories.diff but it's full of code and numbers e.g.

 

234a235,257

> // Update Product Attributes

> $rows = 0;

> $options_query = tep_db_query("select products_options_id, products_options_name from " . TABLE_PRODUCTS_OPTIONS . " where language_id = '" . $languages_id . "' order by products_options_name");

> while ($options = tep_db_fetch_array($options_query)) {

> $values_query = tep_db_query("select pov.products_options_values_id, pov.products_options_values_name from " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov, " . TABLE_PRODUCTS_OPTIONS_VALUES_TO_PRODUCTS_OPTIONS . " p2p where pov.products_options_values_id = p2p.products_options_values_id and p2p.products_options_id = '" . $options['products_options_id'] . "' and pov.language_id = '" . $languages_id . "'");

> while ($values = tep_db_fetch_array($values_query)) {

> $rows ++;

> $attributes_query = tep_db_query("select products_attributes_id, options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . $products_id . "' and options_id = '" . $options['products_options_id'] . "' and options_values_id = '" . $values['products_options_values_id'] . "'");

> if (tep_db_num_rows($attributes_query) > 0) {

> $attributes = tep_db_fetch_array($attributes_query);

> if ($HTTP_POST_VARS['option'][$rows]) {

> if ( ($HTTP_POST_VARS['prefix'][$rows] <> $attributes['price_prefix']) || ($HTTP_POST_VARS['price'][$rows] <> $attributes['options_values_price']) ) {

> tep_db_query("update " . TABLE_PRODUCTS_ATTRIBUTES . " set options_values_price = '" . $HTTP_POST_VARS['price'][$rows] . "', price_prefix = '" . $HTTP_POST_VARS['prefix'][$rows] . "' where products_attributes_id = '" . $attributes['products_attributes_id'] . "'");

> }

> } else {

> tep_db_query("delete from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_attributes_id = '" . $attributes['products_attributes_id'] . "'");

> }

> } elseif ($HTTP_POST_VARS['option'][$rows]) {

> tep_db_query("insert into " . TABLE_PRODUCTS_ATTRIBUTES . " values ('', '" . $products_id . "', '" . $options['products_options_id'] . "', '" . $values['products_options_values_id'] . "', '" . $HTTP_POST_VARS['price'][$rows] . "', '" . $HTTP_POST_VARS['prefix'][$rows] . "')");

> }

> }

> }

>

478a502,552

> <td><table border="0" cellspacing="0" cellpadding="2">

> <tr valign="top">

 

I guess the numbers tell something where the code goes but there are no instructions.

 

Paul.

Posted

A diff file is made up of line tuples.

One line starting with the minus sign, this is the line to be replaced

and another line starting with the plus sign, this is the line that needs to be added.

So translating the instructions into plain english is done by replacing "-" by "Find the following" and "+" by "and replace by"

 

You also get an indication of the line numbers where you should find the code; but as Jack pointed , that often doesn't match with your store when you already made some changes.

KEEP CALM AND CARRY ON

I do not use the responsive bootstrap version since i coded my responsive version earlier, but i have bought every 28d of code package to support burts effort and keep this forum alive (albeit more like on life support).

So if you are still here ? What are you waiting for ?!

 

Find the most frequent unique errors to fix:

grep "PHP" php_error_log.txt | sed "s/^.* PHP/PHP/g" |grep "line" |sort | uniq -c | sort -r > counterrors.txt

Posted
A diff file is made up of line tuples.

One line starting with the minus sign, this is the line to be replaced

and another line starting with the plus sign, this is the line that needs to be added.

So translating the instructions into plain english is done by replacing "-" by "Find the following" and "+" by "and replace by"

 

You also get an indication of the line numbers where you should find the code; but as Jack pointed , that often doesn't match with your store when you already made some changes.

 

Looks like this one has some numbers but no + or - . I'll have a look and see if the numbers match up with any line numbers.

 

Thanks Paul.

Posted

It's telling you to insert the code at certain line numbers. For example, where it says

478a502,552

> <td><table border="0" cellspacing="0" cellpadding="2">

> <tr valign="top">

it is saying to insert
<td><table border="0" cellspacing="0" cellpadding="2">
<tr valign="top">

at lines 478a502,552. But you cannot take this as accurate. If you have made one change to the beginning of the file, all of the numbers can be off. That's why I said you have to search for the code to be changed. Unfortunately, if those are the only instructions you may have a hard time of it. The author took the easy way out and used a diff program to generate the instructions and assumed the contribution would be installed on a clean shop.

 

Jack

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

All of My Addons

Get the latest versions of my addons

Recommended SEO Addons

Posted
It's telling you to insert the code at certain line numbers.  For example, where it saysit is saying to insert
<td><table border="0" cellspacing="0" cellpadding="2">
<tr valign="top">

at lines 478a502,552.  But you cannot take this as accurate.  If you have made one change to the beginning of the file, all of the numbers can be off. That's why I said you have to search for the code to be changed.  Unfortunately, if those are the only instructions you may have a hard time of it.  The author took the easy way out and used a diff program to generate the instructions and assumed the contribution would be installed on a clean shop.

 

Jack

 

 

Yes, I've had some success in getting it to work but I'm missing something as currently I can't write the updates back to the database. I'm going to compare the original OSC 2003 file to the modified file that works with that version to try and see were it changed and then compare that to the MR2 version I'm trying to get to work. If I succeed I'll post it as contribution. It appears that MR2 uses some different code and naming conventions to the 2003 version that I currently have and that this contribution works with. Not being much of a programmer I'm struggling but I suppose it's worth knowing how something works not just that it does. B)

Archived

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

×
×
  • Create New...