From b0d38b87de07f4ae117dd7e8e437aac2e8d842b1 Mon Sep 17 00:00:00 2001 From: Bernd Bestel Date: Mon, 5 Jul 2021 17:48:34 +0200 Subject: [PATCH] PHP 8 support --- README.md | 2 +- changelog/62_UNRELEASED_xxxx-xx-xx.md | 2 + composer.json | 4 +- composer.lock | 107 +++++++++++++------------- services/LocalizationService.php | 9 ++- services/StockService.php | 7 +- 6 files changed, 72 insertions(+), 59 deletions(-) diff --git a/README.md b/README.md index f8728d26..7ce8a3a8 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ grocy is technically a pretty simple PHP application, so the basic notes to get - Include `try_files $uri /index.php$is_args$query_string;` in your location block if you use nginx - Or disable URL rewriting (see the option `DISABLE_URL_REWRITING` in `data/config.php`) - Based on user reports, the minmimum required/working runtime is PHP 7.2 with SQLite 3.9.0 - - However, I don't really care about supporting old runtime stuff, currently everything is only tested against (means 100 % works with) PHP 7.4 with SQLite 3.27.2 + - However, I don't really care about supporting old runtime stuff, currently everything is only tested against (means 100 % works with) PHP 8.0 with SQLite 3.27.2 - → Default login is user `admin` with password `admin`, please change the password immediately (user menu at the top right corner) Alternatively clone this repository (the `release` branch always references the latest released version, or checkout the latest tagged revision) and install Composer and Yarn dependencies manually. diff --git a/changelog/62_UNRELEASED_xxxx-xx-xx.md b/changelog/62_UNRELEASED_xxxx-xx-xx.md index 1c9aac34..ae701289 100644 --- a/changelog/62_UNRELEASED_xxxx-xx-xx.md +++ b/changelog/62_UNRELEASED_xxxx-xx-xx.md @@ -1,5 +1,7 @@ > ⚠️ The following PHP extensions are now additionally required: `json`, `intl`, `zlib` +> ⚠️ PHP 8 is now supported and from now on the only tested runtime version (but as of now, PHP 7.2 should still work). + ### New feature: (Own) Product and stock entry labels/barcodes ("grocycode") - Print own labels/barcodes for products and/or every stock entry and then scan that code on every place a product or stock entry can be selected - Can be printed (or downloaded) via diff --git a/composer.json b/composer.json index 51e23fb4..48fd95a3 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "require": { - "php": ">=7.4", + "php": ">=8.0", "slim/slim": "^4.0", "slim/psr7": "^1.0", "slim/http": "^1.0", @@ -12,7 +12,7 @@ "erusev/parsedown": "^1.7", "gumlet/php-image-resize": "^2.0", "ezyang/htmlpurifier": "^4.13", - "jucksearm/php-barcode": "^1.0", + "interficieis/php-barcode": "^2.0.2", "guzzlehttp/guzzle": "^7.0", "mike42/escpos-php": "^3.0" }, diff --git a/composer.lock b/composer.lock index 32ef21d5..b9b05d1d 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "c7a5c489ba3fd76ced0829ff004909c0", + "content-hash": "733105b1e5f4a01701131e045bc01be9", "packages": [ { "name": "berrnd/slim-blade-view", @@ -1420,6 +1420,57 @@ }, "time": "2021-06-15T17:58:52+00:00" }, + { + "name": "interficieis/php-barcode", + "version": "v2.0.2", + "source": { + "type": "git", + "url": "https://github.com/InterficieIS/php-barcode.git", + "reference": "99326664e7c23780f8b4ce47859215537a41bd0d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/InterficieIS/php-barcode/zipball/99326664e7c23780f8b4ce47859215537a41bd0d", + "reference": "99326664e7c23780f8b4ce47859215537a41bd0d", + "shasum": "" + }, + "require": { + "php": ">=7.4.0" + }, + "require-dev": { + "phpunit/phpunit": "^9.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "jucksearm\\barcode\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL-3.0-only" + ], + "authors": [ + { + "name": "David Martínez", + "email": "david.martinez@interficie.com" + } + ], + "description": "Barcode Generation Package inspired by Nicola Asuni.", + "keywords": [ + "CODE 128", + "barcode", + "datamatrix", + "pdf417", + "php barcode", + "qr code", + "qrcode" + ], + "support": { + "source": "https://github.com/InterficieIS/php-barcode/tree/v2.0.2" + }, + "time": "2021-02-23T13:25:22+00:00" + }, { "name": "jenssegers/blade", "version": "v1.4.0", @@ -1482,58 +1533,6 @@ ], "time": "2020-09-17T08:25:26+00:00" }, - { - "name": "jucksearm/php-barcode", - "version": "1.0.1", - "source": { - "type": "git", - "url": "https://github.com/jucksearm/php-barcode.git", - "reference": "066a58776ec9e94dd6d5843c0fb9a3ff95e74d8b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/jucksearm/php-barcode/zipball/066a58776ec9e94dd6d5843c0fb9a3ff95e74d8b", - "reference": "066a58776ec9e94dd6d5843c0fb9a3ff95e74d8b", - "shasum": "" - }, - "require": { - "php": ">=5.4.0" - }, - "require-dev": { - "phpunit/phpunit": "^6.1" - }, - "type": "library", - "autoload": { - "psr-4": { - "jucksearm\\barcode\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "LGPLv3" - ], - "authors": [ - { - "name": "jucksearm", - "email": "jucksearm.bkk@gmail.com" - } - ], - "description": "Barcode Generation Package inspired by Nicola Asuni.", - "keywords": [ - "CODE 128", - "barcode", - "datamatrix", - "pdf417", - "php barcode", - "qr code", - "qrcode" - ], - "support": { - "issues": "https://github.com/jucksearm/php-barcode/issues", - "source": "https://github.com/jucksearm/php-barcode/tree/1.0.0" - }, - "time": "2017-06-05T04:41:51+00:00" - }, { "name": "mike42/escpos-php", "version": "v3.0", @@ -3606,7 +3605,7 @@ "prefer-stable": false, "prefer-lowest": false, "platform": { - "php": ">=7.4" + "php": ">=8.0" }, "platform-dev": [], "plugin-api-version": "2.1.0" diff --git a/services/LocalizationService.php b/services/LocalizationService.php index 1bf1d274..7a19d633 100644 --- a/services/LocalizationService.php +++ b/services/LocalizationService.php @@ -86,7 +86,14 @@ class LocalizationService } else { - return vsprintf($this->Translator->gettext($text), ...$placeholderValues); + if (is_array(...$placeholderValues)) + { + return vsprintf($this->Translator->gettext($text), ...$placeholderValues); + } + else + { + return sprintf($this->Translator->gettext($text), array_shift($placeholderValues)); + } } } diff --git a/services/StockService.php b/services/StockService.php index 2300c454..afbffe39 100644 --- a/services/StockService.php +++ b/services/StockService.php @@ -777,7 +777,7 @@ class StockService extends BaseService return $this->getDatabase()->stock()->where('id', $entryId)->fetch(); } - public function InventoryProduct(int $productId, float $newAmount, $bestBeforeDate, $locationId = null, $price = null, $shoppingLocationId = null, $purchasedDate) + public function InventoryProduct(int $productId, float $newAmount, $bestBeforeDate, $locationId = null, $price = null, $shoppingLocationId = null, $purchasedDate = null) { if (!$this->ProductExists($productId)) { @@ -796,6 +796,11 @@ class StockService extends BaseService $shoppingLocationId = $productDetails->last_shopping_location_id; } + if ($purchasedDate == null) + { + $purchasedDate = date('Y-m-d'); + } + // Tare weight handling // The given amount is the new total amount including the container weight (gross) // So assume that the amount in stock is the amount also including the container weight