Reading phpBB patch files

phpBB patch files are distributed using the diff context format.

You need a text editor like notepad++ .
Open the patch file using such editor and you’ll have a long string of text

Which file to edit?

diff -x images -x imageset -crNEB phpbb302/includes/acp/acp_bbcodes.php phpbb303/includes/acp/acp_bbcodes.php
*** phpbb302/includes/acp/acp_bbcodes.php	Wed Nov 12 21:27:13 2008
--- phpbb303/includes/acp/acp_bbcodes.php	Wed Nov 12 21:25:52 2008

Changes will happen in file

includes/acp/acp_bbcodes.php

and this is a diff from phpBB 3.0.2 and 3.0.3

Line replacement

***************
*** 2,8 ****
  /**
  *
  * @package acp
! * @version $Id: acp_bbcodes.php 8479 2008-03-29 00:22:48Z naderman $
  * @copyright (c) 2005 phpBB Group
  * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  *
--- 2,8 ----
  /**
  *
  * @package acp
! * @version $Id: acp_bbcodes.php 8743 2008-08-12 16:03:18Z Kellanved $
  * @copyright (c) 2005 phpBB Group
  * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  *

We have listed lines from 2 to 8 of the old file and lines from 2 to 8 of the new file
The line to be replaced is preceeded by

!

To update your old file
FIND (around line 5)

* @version $Id: acp_bbcodes.php 8479 2008-03-29 00:22:48Z naderman $

REPLACE WITH

! * @version $Id: acp_bbcodes.php 8743 2008-08-12 16:03:18Z Kellanved $

New piece of code added

***************
*** 168,173 ****
--- 168,179 ----
  				{
  					trigger_error($user->lang['BBCODE_TAG_DEF_TOO_LONG'] . adm_back_link($this->u_action), E_USER_WARNING);
  				}
+ 				
+ 				
+ 				if (strlen($bbcode_helpline) > 255)
+ 				{
+ 					trigger_error($user->lang['BBCODE_HELPLINE_TOO_LONG'] . adm_back_link($this->u_action), E_USER_WARNING);
+ 				}
 
  				$sql_ary = array(
  					'bbcode_tag'				=> $data['bbcode_tag'],

We should go from lines 168 to 173 of the old file.
We can implement this directive in two ways:
Way 1
FIND (line 168)

  				{
  					trigger_error($user->lang['BBCODE_TAG_DEF_TOO_LONG'] . adm_back_link($this->u_action), E_USER_WARNING);
  				}

AFTER ADD

 
 				if (strlen($bbcode_helpline) > 255)
 				{
 					trigger_error($user->lang['BBCODE_HELPLINE_TOO_LONG'] . adm_back_link($this->u_action), E_USER_WARNING);
 				}

OR … way 2

FIND

  				$sql_ary = array(
  					'bbcode_tag'				=> $data['bbcode_tag'],

BEFORE ADD

 
 				if (strlen($bbcode_helpline) > 255)
 				{
 					trigger_error($user->lang['BBCODE_HELPLINE_TOO_LONG'] . adm_back_link($this->u_action), E_USER_WARNING);
 				}

The final result should be the same

Please note that this kind of command can be used to indicate the addition of an entire new file.
Of course picking it from the full package doesn’t hurt ;)

Line removal

Another example.
The file is language/en/acp/common.php

***************
*** 688,696 ****
  	'LOG_WORD_EDIT'			=> '<strong>Edited word censor</strong><br />» %s',
  ));
 
- // Two language keys with the same text were used in different locations
- // LOG_DELETE_TOPIC is the correct one, this line is here so that existing
- // log entries are not broken. Ensure it is included in your language file.
- $lang['LOG_TOPIC_DELETED'] = $lang['LOG_DELETE_TOPIC'];
- 
  ?>
\ No newline at end of file
--- 688,691 ----

translates as

FIND (around line 688)

// Two language keys with the same text were used in different locations
// LOG_DELETE_TOPIC is the correct one, this line is here so that existing
// log entries are not broken. Ensure it is included in your language file.
$lang['LOG_TOPIC_DELETED'] = $lang['LOG_DELETE_TOPIC'];

REPLACE WITH

nothing … just delete the lines

Please note that this command might be used to report a file deletion. In such case, simply delete the file

Have fun!


Rate this site