5

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

Nathaniel Ford
  • 20,545
  • 20
  • 91
  • 102
Joe
  • 71
  • 1
  • 1
  • 4

2 Answers2

7

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.
Shiplu Mokaddim
  • 56,364
  • 17
  • 141
  • 187
  • .. and after that you'll have to build PHP, just .. to make sure the asker understands that. :-) There might also be better ways to do it depending on the distribution used (if on linux) which will allow you to use the existing build procedure and source. – MatsLindh Jan 16 '13 at 07:59
  • Thanks. Added that information – Shiplu Mokaddim Jan 16 '13 at 08:09
  • How would one do this in a Windows environment? – user752746 May 16 '19 at 19:38
  • @user752746 the process is same. There is a [patch utility for window](https://stackoverflow.com/questions/4780282/linux-patch-command-utility-for-windows). And see php.net for compiling PHP on windows. – Shiplu Mokaddim May 17 '19 at 07:06
  • Thanks @Shiplu Mokaddim! I'll check it out. – user752746 May 17 '19 at 16:09
1

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.

Nathaniel Ford
  • 20,545
  • 20
  • 91
  • 102