endroid / qr-code

QR Code Generator
https://endroid.nl
MIT License
4.45k stars 726 forks source link

Index invalid or out of range #362

Closed PhoenixBWS closed 2 years ago

PhoenixBWS commented 2 years ago

When run on PHP 8.0 or PHP 8.1, it causes a Fatal Error. Please add support for PHP 8.1.

endroid commented 2 years ago

Hi @PhoenixBWS I am running it under PHP 8.1 and am not getting any errors. Also, all checks under PHP 8.x are successful, see https://github.com/endroid/qr-code/actions/runs/1660408990. What version do you have installed and what is the error message?

PhoenixBWS commented 2 years ago

@endroid It throws the following error: Fatal error: Uncaught RuntimeException: Index invalid or out of range in /public_html/vendor/bacon/bacon-qr-code/src/Encoder/MaskUtil.php:106 Stack trace: #0 /public_html/vendor/bacon/bacon-qr-code/src/Encoder/Encoder.php(181): BaconQrCode\Encoder\MaskUtil::applyMaskPenaltyRule3() #1 /public_html/vendor/bacon/bacon-qr-code/src/Encoder/Encoder.php(228): BaconQrCode\Encoder\Encoder::calculateMaskPenalty() #2 /public_html/vendor/bacon/bacon-qr-code/src/Encoder/Encoder.php(119): BaconQrCode\Encoder\Encoder::chooseMaskPattern() #3 /public_html/vendor/endroid/qr-code/src/Bacon/MatrixFactory.php(18): BaconQrCode\Encoder\Encoder::encode() #4 /public_html/vendor/endroid/qr-code/src/Writer/PngWriter.php(29): Endroid\QrCode\Bacon\MatrixFactory->create() #5 /public_html/components/generator.php(27): Endroid\QrCode\Writer\PngWriter->write() #6 /public_html/index.php(27): include('...') #7 {main} thrown in /public_html/vendor/bacon/bacon-qr-code/src/Encoder/MaskUtil.php on line 106

PhoenixBWS commented 2 years ago

In composer.json, I see the version listed there is:

"endroid/qr-code": "^4.4"

In composer.lock I found the actual version no. i.e. 4.4.7

And my PHP Version is 8.1.1

endroid commented 2 years ago

And what bacon qr code library version do you have in your lock file? As it appears to be some issue in that code.

PhoenixBWS commented 2 years ago

Yes, it looks like that. By the way, the Bacon QR Code library version looks like below in my composer.lock

"name": "bacon/bacon-qr-code", "version": "2.0.4"

I also found an issue there but that was not resolved yet.

endroid commented 2 years ago

Ah that must be it then. Hope it will be resolved soon. Thank you!

PhoenixBWS commented 2 years ago

Can you please tell me which bacon/bacon-qr-code version is working with php8.1 so that we can use your QR Code library?

endroid commented 2 years ago

@PhoenixBWS As I mentioned all my tests are running successfully under PHP 8.x and with bacon qr code lib 2.0.4 so I think the error only occurs for specific use cases which are not covered by the tests. If you can provide a failing test case (or complete code fragment that results in the issue) I can see if I can reproduce the issue and we can use that information to help the author of the library which has the bug to reproduce and solve it.