verbb / events

Craft CMS Plugin for events management and ticketing.
Other
21 stars 12 forks source link

QR generation error #117

Closed dimetechgroup closed 1 year ago

dimetechgroup commented 1 year ago

Describe the bug

On updating to the latest version, getting Too few arguments to function Endroid\QrCode\QrCode::__construct()

Steps to reproduce

  1. Update Craft
  2. Update events

Craft CMS version

4.3.6.1

Plugin version

2.0.0-beta.8

Multi-site?

No

Additional context

This happens due to outdated call to endroid/qrcode in getQrCode() method of PurchasedTicket element type

I solved it using the code below:

public function getQrCode(): string
    {
        $url = UrlHelper::actionUrl('events/ticket/checkin', ['sku' => $this->ticketSku]);

        $writer = new PngWriter();

        // Create QR code
        $qrCode = QrCode::create($url)
            //->setEncoding(new Encoding('UTF-8'))
            ->setErrorCorrectionLevel(new ErrorCorrectionLevelMedium())
            ->setSize(300)
            ->setMargin(10)
            ->setRoundBlockSizeMode(new RoundBlockSizeModeMargin())
            ->setForegroundColor(new Color(0, 0, 0))
            ->setBackgroundColor(new Color(255, 255, 255));

        $result = $writer->write($qrCode);

        return $result->getDataUri();
    }
engram-design commented 1 year ago

Fixed for the next release - we're still updating a few things like the QR code dependancy. To get the fix early, change your verbb/events requirement in composer.json to:

"require": {
  "verbb/events": "dev-craft-4 as 2.0.0-beta.8",
  "...": "..."
}

Then run composer update.

engram-design commented 1 year ago

Updated in 2.0.0-beta.9