Skip to content

PHP 8.4: Incorrect MIME content type #17039

Closed

Description

@natanfelles

Description

The following code:

<?php

class Foo
{
    public function bar()
    {
        $this->baz(function () {});
    }
}

echo mime_content_type(__FILE__);

Resulted in this output in PHP 8.4:

application/javascript

But I expected this output, as in PHP <= 8.3:

text/x-php

Note that when you remove the function () {} snippet, it detects it as text/x-php.

Thank you!

PHP Version

PHP 8.4.1

Operating System

Ubuntu 24.04

Activity

  1. devnexen commented on Dec 4, 2024

    @devnexen
    Member

    So it might seem a database update issue, if I take data_file.c from 8.3 I get the proper mime type. @petk thoughts ?

  2. cmb69 commented on Dec 4, 2024

    @cmb69
    Member

    One can check what file(1) reports (the version of file(1) is usually relevant). PHP 8.4 and master are currently using a patched 5.45; 5.46 has been recently released. We should likely update master, and possibly back-port a fix for this issue.

  3. devnexen commented on Dec 4, 2024

    @devnexen
    Member

    Good point file from debian unstable/ubuntu 24.10 is 5.45 both returns the same result whereas file on my mac, 5.41, returns php.

  4. cmb69 commented on Dec 4, 2024

    @cmb69
    Member

    Looks like the issue has already been fixed for 5.46:

    cmb@ELEPHPANT:~$ PATH=/home/cmb/file-5.46/bin:$PATH file -m ~/file-5.46/share/misc/magic.mgc -v file-5.46
    magic file from /home/cmb/file-5.46/share/misc/magic.mgc
    cmb@ELEPHPANT:~$ PATH=/home/cmb/file-5.46/bin:$PATH file -m ~/file-5.46/share/misc/magic.mgc --mime-type /mnt/c/php-sdk/phpdev/vs17/x64/gh17039.php
    /mnt/c/php-sdk/phpdev/vs17/x64/gh17039.php: text/x-php
    
  5. ndossche commented on Dec 4, 2024

    @ndossche
    Member

    I have experience with updating fileinfo and patching it, I'll handle this.

  6. self-assigned this
    on Dec 4, 2024
  7. ndossche commented on Dec 4, 2024

    @ndossche
    Member

    I'll do the necessary backport for fixing this, but hold off the 5.46 update on master until a later time, just in case that a newer file version would be released before PHP8.5 enters feature freeze (to avoid double work)
    EDIT: identified commit needed for backport: file/file@ad925d3

  8. added a commit that references this issue on Dec 4, 2024
    5186df7
  9. added a commit that references this issue on Dec 8, 2024
    f1b24da
  10. added a commit that references this issue on Dec 8, 2024
    751eabb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions