Skip to content

Commit

Permalink
fix for some deprecations in modern php (#1839)
Browse files Browse the repository at this point in the history
  • Loading branch information
monkeyiq committed Mar 26, 2024
1 parent d01d850 commit b0ba279
Show file tree
Hide file tree
Showing 29 changed files with 1,274 additions and 12 deletions.
2 changes: 2 additions & 0 deletions classes/rest/RestRequest.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ class RestInput
* Body data holder
*/
private $data = array();

public $mime_type = '';

/**
* Recursive crawler that converts raw data into browsable data
Expand Down
3 changes: 3 additions & 0 deletions classes/rest/RestServer.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ public static function process()
if (!$type && array_key_exists('HTTP_CONTENT_TYPE', $_SERVER)) {
$type = $_SERVER['HTTP_CONTENT_TYPE'];
}
if(!$type) {
$type = '';
}

// Parse content type
$type_parts = array_map('trim', explode(';', $type));
Expand Down
1 change: 1 addition & 0 deletions classes/utils/Browser.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class Browser
protected $isChrome = false;
protected $isFirefox = false;
protected $isSafari = false;
protected $isEdge = false;
protected $allowStreamSaver = false;
protected $allowFileSystemWritableFileStream = false;

Expand Down
11 changes: 6 additions & 5 deletions classes/utils/Lang.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,6 @@ class Lang
*/
private $translation = '';

/**
* Does the translation allows replacements
*/
private $allow_replace = true;

/**
* Get available languages
Expand Down Expand Up @@ -540,7 +536,7 @@ public static function tr($id)
public static function trWithConfigOverride($id)
{
$v = Config::get('tr_' . $id);
if( strlen($v)) {
if( $v && strlen($v)) {
return new Translation($v);
}
return self::tr($id);
Expand Down Expand Up @@ -723,6 +719,11 @@ class Translation
* Raw mode
*/
private $raw = false;

/**
* Does the translation allows replacements
*/
private $allow_replace = true;

/**
* Constructor
Expand Down
5 changes: 3 additions & 2 deletions classes/utils/Utilities.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

require_once(FILESENDER_BASE.'/lib/random_compat/lib/random.php');
require_once(FILESENDER_BASE.'/lib/vendor/autoload.php');

use function PHP81_BC\strftime;

/**
* Utility functions holder
Expand Down Expand Up @@ -192,7 +192,8 @@ public static function formatDate($timestamp = null, $with_time = false)
$dateFormat = '%d %b %Y %T';
}

return utf8_encode(strftime($dateFormat, $timestamp));
$ts = strftime($dateFormat, (int)$timestamp);
return mb_convert_encoding( $ts, 'UTF-8' );
}

/**
Expand Down
4 changes: 2 additions & 2 deletions lib/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"guzzlehttp/psr7": "2.6.2",
"maennchen/zipstream-php": "2.4.0",
"owasp/csrf-protector-php": "^1.0",
"ramsey/uuid": "^4.7"

"ramsey/uuid": "^4.7",
"php81_bc/strftime": "^0.7.4"
}
}
46 changes: 45 additions & 1 deletion lib/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions lib/vendor/composer/autoload_files.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
'7b11c4dc42b3b3023073cb14e519683c' => $vendorDir . '/ralouphie/getallheaders/src/getallheaders.php',
'6e3fae29631ef280660b3cdad06f25a8' => $vendorDir . '/symfony/deprecation-contracts/function.php',
'37a3dc5111fe8f707ab4c132ef1dbc62' => $vendorDir . '/guzzlehttp/guzzle/src/functions_include.php',
'9e71c1459ef1226520e4b26dac3a180d' => $vendorDir . '/php81_bc/strftime/src/php-8.1-strftime.php',
'e39a8b23c42d4e1452234d762b03835a' => $vendorDir . '/ramsey/uuid/src/functions.php',
);
1 change: 1 addition & 0 deletions lib/vendor/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class ComposerStaticInit278b8b2a471333aff04b3f0c8233c3f3
'7b11c4dc42b3b3023073cb14e519683c' => __DIR__ . '/..' . '/ralouphie/getallheaders/src/getallheaders.php',
'6e3fae29631ef280660b3cdad06f25a8' => __DIR__ . '/..' . '/symfony/deprecation-contracts/function.php',
'37a3dc5111fe8f707ab4c132ef1dbc62' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/functions_include.php',
'9e71c1459ef1226520e4b26dac3a180d' => __DIR__ . '/..' . '/php81_bc/strftime/src/php-8.1-strftime.php',
'e39a8b23c42d4e1452234d762b03835a' => __DIR__ . '/..' . '/ramsey/uuid/src/functions.php',
);

Expand Down
47 changes: 47 additions & 0 deletions lib/vendor/composer/installed.json
Original file line number Diff line number Diff line change
Expand Up @@ -852,6 +852,53 @@
},
"install-path": "../phenx/php-svg-lib"
},
{
"name": "php81_bc/strftime",
"version": "0.7.4",
"version_normalized": "0.7.4.0",
"source": {
"type": "git",
"url": "https://github.com/alphp/strftime.git",
"reference": "10c13faf2f65bfaec17dfa769918e0c7a4c9b3cc"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/alphp/strftime/zipball/10c13faf2f65bfaec17dfa769918e0c7a4c9b3cc",
"reference": "10c13faf2f65bfaec17dfa769918e0c7a4c9b3cc",
"shasum": ""
},
"require": {
"ext-intl": "*",
"php": ">=7.1.0"
},
"require-dev": {
"phpunit/phpunit": "@stable"
},
"time": "2024-03-12T11:46:29+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
"files": [
"src/php-8.1-strftime.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fernando Herrero",
"homepage": "https://github.com/alphp/strftime/graphs/contributors"
}
],
"description": "Locale-formatted strftime using IntlDateFormatter (PHP 8.1 compatible)",
"support": {
"issues": "https://github.com/alphp/strftime/issues",
"source": "https://github.com/alphp/strftime"
},
"install-path": "../php81_bc/strftime"
},
{
"name": "psr/http-client",
"version": "1.0.3",
Expand Down
13 changes: 11 additions & 2 deletions lib/vendor/composer/installed.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
'name' => '__root__',
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'reference' => '91637aaa74aa5ee104a6bb0c27bc022bd4b96917',
'reference' => 'd01d850b6f7d762d9f1e496c0e494a109774f366',
'type' => 'library',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
Expand All @@ -13,7 +13,7 @@
'__root__' => array(
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'reference' => '91637aaa74aa5ee104a6bb0c27bc022bd4b96917',
'reference' => 'd01d850b6f7d762d9f1e496c0e494a109774f366',
'type' => 'library',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
Expand Down Expand Up @@ -127,6 +127,15 @@
'aliases' => array(),
'dev_requirement' => false,
),
'php81_bc/strftime' => array(
'pretty_version' => '0.7.4',
'version' => '0.7.4.0',
'reference' => '10c13faf2f65bfaec17dfa769918e0c7a4c9b3cc',
'type' => 'library',
'install_path' => __DIR__ . '/../php81_bc/strftime',
'aliases' => array(),
'dev_requirement' => false,
),
'psr/http-client' => array(
'pretty_version' => '1.0.3',
'version' => '1.0.3.0',
Expand Down
24 changes: 24 additions & 0 deletions lib/vendor/php81_bc/strftime/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
; This file is for unifying the coding style for different editors and IDEs.
; More information at http://editorconfig.org

root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

[*.bat]
end_of_line = crlf

[*.yml]
indent_style = space
indent_size = 2

[*.twig]
insert_final_newline = false

[Makefile]
indent_style = tab
51 changes: 51 additions & 0 deletions lib/vendor/php81_bc/strftime/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Define the line ending behavior of the different file extensions
# Set default behavior, in case users don't have core.autocrlf set.
* text=auto
* text eol=lf

# Explicitly declare text files we want to always be normalized and converted
# to native line endings on checkout.
*.php text
*.default text
*.ctp text
*.sql text
*.md text
*.po text
*.js text
*.css text
*.ini text
*.properties text
*.txt text
*.xml text
*.svg text
*.yml text
.htaccess text

# Declare files that will always have CRLF line endings on checkout.
*.bat eol=crlf

# Declare files that will always have LF line endings on checkout.
*.pem eol=lf

# Denote all files that are truly binary and should not be modified.
*.dbf binary
*.prj binary
*.shp binary
*.shx binary
*.sld binary
*.png binary
*.jpg binary
*.gif binary
*.ico binary
*.mo binary
*.pdf binary
*.phar binary
*.woff binary
*.woff2 binary
*.ttf binary
*.otf binary
*.eot binary
*.gz binary
*.bz2 binary
*.7z binary
*.zip binary
53 changes: 53 additions & 0 deletions lib/vendor/php81_bc/strftime/.github/workflows/php.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: PHP Composer

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

permissions:
contents: read

jobs:
build:

runs-on: ${{ matrix.operating-system }}

strategy:
matrix:
operating-system: [ubuntu-latest, windows-latest, macOS-latest]
php-versions: ['7.4', '8.0', '8.1', '8.2', '8.3']

name: PHP ${{ matrix.php-versions }} Test on ${{ matrix.operating-system }}

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
extensions: intl

- name: Validate composer.json and composer.lock
run: composer validate --strict

- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v4
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-
- name: Install dependencies
run: composer install --prefer-dist --no-progress

# Add a test script to composer.json, for instance: "test": "vendor/bin/phpunit"
# Docs: https://getcomposer.org/doc/articles/scripts.md

- name: Run test suite
run: composer run-script test
Loading

0 comments on commit b0ba279

Please sign in to comment.