Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Install a Patch in PHP [closed]

Tags:

php

I need to install this patch in my PHP code:

https://bugs.php.net/patch-display.php?bug_id=44522&patch=uploads_larger_than_2g_HEAD_v2&revision=latest

Can any body explain how?

My PHP Version : 5.4.10

like image 754
Joe Avatar asked Jan 16 '13 07:01

Joe


2 Answers

You must have the source and patch file before you can patch it. Its quite simple.

  1. Go to the root directory of PHP 5.4 source code
  2. Run patch -p0 < /path/to/patch.patch
  3. If it shows an error, undo it by patch -R < /path/to/patch.patch. and adjust the -p num value. and go to step 2. Here -p is the smallest prefix containing num leading slashes from each file name found in the patch file. A sequence of one or more adjacent slashes is counted as a single slash. This controls how file names found in the patch file are treated, in case you keep your files in a different directory than the person who sent out the patch. For example, supposing the file name in the patch file was

    /u/howard/src/blurfl/blurfl.c
    

    setting -p0 gives the entire file name unmodified, -p1 gives

    u/howard/src/blurfl/blurfl.c
    

    without the leading slash, -p4 gives

    blurfl/blurfl.c
    

    and not specifying -p at all just gives you blurfl.c. Whatever you end up with is looked for either in the current directory, or the directory specified by the -d option. The number after -p can be determined by following

  4. After that you need to compile this patched version of PHP. Compiling instructions are included PHP source directory. To build it in Unix use README.UNIX-BUILD-SYSTEM file and for Windows use README.WIN32-BUILD-SYSTEM file.
like image 186
Shiplu Mokaddim Avatar answered Oct 02 '22 14:10

Shiplu Mokaddim


Download your file as something like php_upload_larger_than_2g.patch.

Place it on your system.

Run: patch /path/to/patch/php_upload_larger_than_2g.patch /path/to/patching/file/whatever.php

This should 'patch' that file. Note this only works in Unix-like systems.

like image 33
Nathaniel Ford Avatar answered Oct 02 '22 12:10

Nathaniel Ford