Skip to content
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

PHP Fatal error: Uncaught TypeError: decbin(): Argument #1 ($num) must be of type int, string given #299

Closed
calliostro opened this issue Mar 20, 2021 · 6 comments

Comments

@calliostro
Copy link

calliostro commented Mar 20, 2021

Hello James Heinrich

Recently I get more and more often the error when reading files:

PHP Fatal error: Uncaught TypeError: decbin(): Argument #1 ($num) must be of type int, string given

Not to exclude that the MP3 files are not quite correct from the structure, on the other hand MP3 Diags can not find errors.

I help myself with additional check in the function \getid3_lib::Dec2Bin($number) whether the parameter really contains a number and get out otherwise.

getid3.lib.php:429

public static function Dec2Bin($number) {
    if (!is_numeric($number)) {
        trigger_error('TypeError: Dec2Bin(): Argument #1 ($number) must be numeric, '.gettype($number).' given', E_USER_WARNING);
        return '';
    }
    :
    :
}

Does it make sense to apply this change?

Many greetings
Joey

@JamesHeinrich
Copy link
Owner

I would be more comfortable seeing a sample file that exhibits this problem first, to see how or where it's being called inappropriately.

@JamesHeinrich
Copy link
Owner

I took a look at your sample file but didn't notice any such warnings. What version of PHP are you using?

@calliostro
Copy link
Author

Good tip, the error comes under PHP 8.0.3.

I just tried it with PHP 7.4.11, there it runs without problems.

That explains then why I have only been observing this for some time. I have not brought it in connection with the switch to PHP 8.

@paulijar
Copy link
Contributor

This issue seems to be the root cause of the issue owncloud/music#867. There, we can find also a stack trace showing that the bad call to Dec2Bin comes from here:

$rg_track_adjustment = getid3_lib::Dec2Bin(substr($parsedFrame['data'], $frame_offset, 2));

This line of code is obviously passing in a string while Dec2Bin expects to get an int. Older PHP versions probably apply an implicit type conversion when this string gets passed to decbin but PHP8 is more strict.

JamesHeinrich added a commit that referenced this issue Jun 22, 2021
@JamesHeinrich
Copy link
Owner

Please reopen this issue if 4e5bcaf doesn't fix your problem.

JamesHeinrich added a commit that referenced this issue Jul 1, 2021
@JamesHeinrich
Copy link
Owner

I just came across a sample MP3 file that exhibited this problem, related to code parsing the RGAD (replay gain) tag improperly. I have rewritten that section of the code in 0bc9aca.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants