-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Update libmagic patch #4298
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update libmagic patch #4298
Conversation
Thanks for the PR. Could we please omit changes in the bundled libmagic files? Thanks. |
These changes of the bundled files are in the libmagic 5.37 release already... So, this is a sync as how the libmagic 5.37 should look like actually.
So, if I omit changes in the bundled files, then patch makes no sense? Or what do you mean here? |
What I mean, is that porting a new libmagic version is a time consuming process. Having a patch with unrelated customizations makes that porting one more bit harder :) There will be enough places to fail when it's applied to the next libmagic version. It is not our codebase after all, even if it needs to be patched. If there's no bugfix, there's no real reason to touch the bundled code. Also i think that the change to the configure.ac might break some external code that includes php.h, as the macros are not defined anymore. IMO there is no real benefit doing that in first place, but for sure these defines should be kept for BC. Core vs. external extensions and libs are different matters, need to be careful. Thanks. |
That's what this patch does. To make things easier to patch in the future. Without applying these changes (at least the libmagic related ones) it will be more difficult to patch libmagic 5.38, for example. These changes are all in the upstream https://github.com/file/file libmagic (a.k.a file library/tool)... already. To be more clear here: These aren't unrelated changes. These are syncs with the upstream version 5.37. Easiest to understand them is to apply them on the libmagic fork or a branch... With this patch (if I'm not mistaken) patching the 5.37 version is correct and the current patched version in the php-src is not correct. Well, I guess now I'll need to recheck this. Regarding the impact on the PHP extensions: When would then be the right time for this step according to you? I guess we can leave few of those left overs in the php config header file, yes, but also there are only few left now... These are pre-C89 (not even C89) stuff we're talking about here. |
Nice then. Sure some piece could have been missed in the port. Just the links in the description point to the php-src, not to the upstream. The configure.ac checks - well, they could be kept forewer, as they don't hurt at all. Or at least defer as much as possible, to the next major, etc? The topic seems not directly akin to the libmagic stuff, while ofc would affect if the defines are still respected upstream. Thanks. |
All these have been applied so far in the 5.37 version: Except for the ancient memory.h file issue - which will be removed in the 5.38 release (but this is not important for the php's libmagic.patch file since it is not in it)... Keeping such symbols for ever in php config header files or windows one for the same matter is actually problematic... I'll get back to you with a more clear understanding how minimal this impact actually is... |
Hello, so the results of the usages in the open source extensions:
Scanned so far: 160 extensions... Considering the results of these usages, I still think that it needs to be made more clear, that these symbols are prehistoric checks and don't need to be used like this anymore. So, all good to start removing these defines already in PHP 7.4. I'm also not so sure how really portable extensions are with relying on the symbols defined during the configuration of the build of PHP. Will it really work always if the extension is built on the system separately from PHP? Like cross compilations, shared uninstalled extensions etc. With these 3 symbols for example, yes, it would be ok, but extensions might rely on other symbols that depend on the system libraries, and behavior... |
Great research, thanks! For Also ping @Danack :) Thanks. |
@petk seems you'll need to rebase, i had to update it due to another issue. While on that, i was able to check your change to libmagic and it is fine. I would suggeest the following
One more note - i haven't noticed there was a script to automate the patch creation. I'm not sure it's quite correct, because the diff has to be done to the configured source, but probably even better to the built source. Perhaps it's something you or @nikic could look at, i'll do as well when having time. Thanks. |
This simplifies the libmagic patch: - in upstream the HAVE_STRERROR check has been removed - in upstream library the HAVE_SIGNAL_H has been removed - indentations syncs with the upstream library - some irrelevant changes removed from the patch (log comment), upstream has this correctly logged already so no need to patch the comment.
Added. How to check this pull request:
Redacted: one git checkout was missing. |
About the other changes mentioned to separate them, they now depend on this pull request, so then it's best to open them once this is merged... Hopefully this can be done on some reasonable quick time, so this gets to the PHP-7.4... Thanks. |
@petk nice level of detail :) Looks good AFM, thanks for cleaning the missed parts. Thanks. |
@petk sure. I didn't follow up as looked like you'd be able to merge yourself. Please merge when you've time. Thanks. |
Applied. Thanks. Worth noting that Otherwise, I'm not sure if this is necessary since the imagick library still needs to be patched anyway due to using HAVE_SPL symbol (cc @Danack). I think this is the only extension I could find on the whole to use the locale.h check from PHP... Also, pull request has been sent to Imagick/imagick#291 |
@petk nice you filed the PR to imagick. With locale and other C99 changes - C99 is enforced in master, with lower we're still on C89 formally. Having this going a bit finer route for a smoother BC seems not wrong therefore. As well as with the other changes that might affect external extensions. Thanks. |
This syncs the libmagic (file library) patch with recent changes:
Remove HAVE_SIGNAL_H from libmagic
Following left over since 5f89157
This syncs also libmagic patch with proper fixes of whitespaces errors,
versions, line numbers, etc.
Remove HAVE_LOCALE_H check
This was removed via e06836a and
file library update 622b10f.
Remove HAVE_STRERROR
Already removed via e6a6017 and
in the libmagic 5.37.