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

Implicit conversion from float 3988292384 to int loses precision Error in PHP 8.1 #6115

Closed
devParry opened this issue Apr 26, 2023 · 2 comments
Assignees
Labels
api: storage Issues related to the Cloud Storage API. priority: p2 Moderately-important priority. Fix may not be included in next release.

Comments

@devParry
Copy link

Environment details

  • OS: Window 11
  • PHP version: 8.1.18
  • Package name and version: google/cloud-storage : "^1.30"

Steps to reproduce

  1. We are uploading media files on Firebase storage. It was working fine with PHP 7.3 version.
Code example
$object = $bucket->upload(file_get_contents($file), [ 
                                                           'name' => $foldername . '/' . $filename, 
                                                           'metadata' => ['contentType' => $filetype]
                                            ]); 
       $upload_info = $object->info();
  1. But now we have upgraded to PHP 8.1. After the version upgrade, we are facing an error while uploading files.
    E.g: Message: Implicit conversion from float 3988292384 to int loses precision

Please check the Screen-shot as well :

image

Could you please let us know how we can fix this?

Thanks!

@bshaffer
Copy link
Contributor

bshaffer commented Apr 28, 2023

I've filed an issue with the https://github.com/google/php-crc32 repo here. The function being called here is

    protected function supportsBuiltinCrc32c()
    {
        return Builtin::supports(CRC32::CASTAGNOLI);
    }

And I see nothing wrong with that code. It could be a problem that only occurs on Windows, as I cannot duplicate the warning on Mac OSX or Linux:

var_dump(Google\CRC32\CRC32::CASTAGNOLI);
// int(2197175160)

As this value is an int and not a float, I don't see how the warning could be thrown. Maybe on Windows RC32::CASTAGNOLI is being interpreted as a float?

Edit: The difference in behavior could be dependent on whether or not the crc32c extension is installed.

@vishwarajanand
Copy link
Contributor

Should be fixed now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: storage Issues related to the Cloud Storage API. priority: p2 Moderately-important priority. Fix may not be included in next release.
Projects
None yet
Development

No branches or pull requests

4 participants