PHP 8 support

This commit is contained in:
Bernd Bestel 2021-07-05 17:48:34 +02:00
parent d9470cb377
commit b0d38b87de
No known key found for this signature in database
GPG Key ID: 71BD34C0D4891300
6 changed files with 72 additions and 59 deletions

View File

@ -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.

View File

@ -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

View File

@ -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"
},

107
composer.lock generated
View File

@ -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"

View File

@ -85,9 +85,16 @@ class LocalizationService
return $this->Translator->gettext($text);
}
else
{
if (is_array(...$placeholderValues))
{
return vsprintf($this->Translator->gettext($text), ...$placeholderValues);
}
else
{
return sprintf($this->Translator->gettext($text), array_shift($placeholderValues));
}
}
}
public static function getInstance(string $culture)

View File

@ -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