Difference between revisions of "X-Cart:To apply a patch manually"

From X-Cart 4 Classic
Jump to: navigation, search
Line 6: Line 6:
  
 
: where:
 
: where:
 +
 
:* 67 - indicates the number of the line of the code where the changes start
 
:* 67 - indicates the number of the line of the code where the changes start
:* 7 - indicates the number of the lines in the hunk before patch applying
+
:* 7 - indicates the number of the lines in the hunk before patch application
:* 10 - indicates the number of the lines in the hunk after patch applying
+
:* 10 - indicates the number of the lines in the hunk after patch application
  
: Then follows the file code marked with "+" and "-" signs. Lines marked with "+" are the lines that you need to add in the file that you should patch. Lines marked with "-" are the lines that you need to remove from the file that you should patch.
+
: Then follows the file code including lines marked with "+" and "-" signs. Lines marked with "+" are the lines that you need to add in the file that you should patch. Lines marked with "-" are the lines that you need to remove from the file that you should patch.
  
 
: Under 'Index:' you will find the name of the file that you should patch, for example:
 
: Under 'Index:' you will find the name of the file that you should patch, for example:
Line 16: Line 17:
 
<pre>Index: admin/category_modify.php</pre>
 
<pre>Index: admin/category_modify.php</pre>
  
: Here is an example of complete diff file:
+
: Here is an example of a complete diff file:
  
<pre>
+
<pre>Index: admin/category_modify.php
Index: admin/category_modify.php
 
 
@@ -67,7 +67,10 @@
 
@@ -67,7 +67,10 @@
 
#
 
#
  
 
if ($shop_language == $config['default_admin_language']) {
 
if ($shop_language == $config['default_admin_language']) {
-
+
- func_array2update("categories", $category_lng, "categoryid = '$cat'");
func_array2update("categories", $category_lng, "categoryid = '$cat'");
 
 
+ $_category_lng = $category_lng;
 
+ $_category_lng = $category_lng;
+
+
+ if (empty($_category_lng['category']))
if (empty($_category_lng['category']))
+
+ func_unset($_category_lng, 'category');
+
+
+ func_array2update("categories", $_category_lng, "categoryid = '$cat'");
func_unset($_category_lng, 'category');
 
+
 
func_array2update("categories", $_category_lng, "categoryid = '$cat'");
 
 
}
 
}
  
 
$category_lng['code'] = $shop_language;
 
$category_lng['code'] = $shop_language;
 
 
</pre>
 
</pre>
  
 
2. Edit the file (in our example, admin/category_modify.php):
 
2. Edit the file (in our example, admin/category_modify.php):
  
:* Find the lines, which are marked by "-" in the text of patch, and remove them.
+
:* Find the lines, which are marked by "-" in the text of the patch, and remove them.
:* Insert the lines, which are marked by "+" in the text of patch.
+
:* Insert the lines, which are marked by "+" in the text of the patch.
 
 
If you cannot apply the patch in these ways it means the file that needs to be patched has been modified or this file is from another version of X-Cart and cannot be patched by this patch. Ask technical support to help you.
 
  
 
[[Category:X-Cart user manual]]
 
[[Category:X-Cart user manual]]

Revision as of 09:53, 30 September 2010

1. Open the diff file in a text editor;

Diff files are divided into parts ("hunks"). Each "hunk" starts with a line like this:
@@ -67,7 +67,10 @@
where:
  • 67 - indicates the number of the line of the code where the changes start
  • 7 - indicates the number of the lines in the hunk before patch application
  • 10 - indicates the number of the lines in the hunk after patch application
Then follows the file code including lines marked with "+" and "-" signs. Lines marked with "+" are the lines that you need to add in the file that you should patch. Lines marked with "-" are the lines that you need to remove from the file that you should patch.
Under 'Index:' you will find the name of the file that you should patch, for example:
Index: admin/category_modify.php
Here is an example of a complete diff file:
Index: admin/category_modify.php
@@ -67,7 +67,10 @@
#

if ($shop_language == $config['default_admin_language']) {
-			func_array2update("categories", $category_lng, "categoryid = '$cat'");
+			$_category_lng = $category_lng;
+			if (empty($_category_lng['category']))
+				func_unset($_category_lng, 'category');
+			func_array2update("categories", $_category_lng, "categoryid = '$cat'");
}

$category_lng['code'] = $shop_language;

2. Edit the file (in our example, admin/category_modify.php):

  • Find the lines, which are marked by "-" in the text of the patch, and remove them.
  • Insert the lines, which are marked by "+" in the text of the patch.