composer-patches icon indicating copy to clipboard operation
composer-patches copied to clipboard

Backward compatibility of #334 for 1.x

Open pesc opened this issue 3 years ago • 7 comments

Hi

Some time ago, I've created the pull request: #334 which was merged to master branch. The problem is, the most used version is 1.x. So we need to fix it for this version too. Cherry-picking wasn't a option, because the #334 version only works for PHP 7.2+.

So my approach is based on the new PHP_OS_FAMILY (PHP 7.2+) mixed with older PHP_OS detection and the help of this issue: https://github.com/sebastianbergmann/environment/issues/21

@cweagans What do you think?

manual of patch: https://man.netbsd.org/patch.1 https://man.openbsd.org/patch.1 https://www.freebsd.org/cgi/man.cgi?patch(1)

pesc avatar Feb 19 '22 07:02 pesc

Closes #182 Closes #184

pesc avatar Feb 19 '22 07:02 pesc

@cweagans any thoughts on this PR?

pesc avatar Mar 29 '22 09:03 pesc

I tested this on FreeBSD and it didn't actually work for me - it seems to run patch '-p4' '--posix --batch' -d 'web/core' < '/tmp//6252865cb0bbf.patch'

which results in patch: unrecognized option `--posix --batch'

I guess because escapeshellarg(), which adds single quotes, is run on the options as if they were one argument.

mfb avatar Apr 10 '22 07:04 mfb

The approach in #402 would work here too - building an array of options which can be escaped individually.

mfb avatar Apr 10 '22 19:04 mfb

@mfb Yeah could be, but actually you're talking about a different issue. Without #334 or this #396 it wouldn't even work on FreeBSD. I'll have a look on the changes in #402 and see if I can update this PR to the 1.X branch

pesc avatar Apr 11 '22 06:04 pesc

Well, the point is that #334 and this PR #396 don't yet work on FreeBSD, but I think we're getting close - #402 is now able to get the master branch working on FreeBSD, and we need similar code for this PR on the 1.x branch.

mfb avatar Apr 11 '22 07:04 mfb

@mfb Ok, I see the issue. I'll wait until #402 is merged and will then adjust the backport

pesc avatar Apr 25 '22 17:04 pesc

#447 has explicit support for BSD patch. Please take a look at src/Patcher/* - let me know if that works for you.

cweagans avatar Feb 04 '23 07:02 cweagans

hmm @cweagans...in this PR the goal was to backport the BSD Patch feature to 1.X but #447 is only for 2.X

pesc avatar Mar 13 '23 08:03 pesc