fix: use `OCP\Server`

Signed-off-by: John Molakvoæ <skjnldsv@users.noreply.github.com>
pull/50099/head
John Molakvoæ 9 months ago committed by skjnldsv
parent 14b4d0327e
commit 4829ac57c1
  1. 20
      lib/composer/composer/InstalledVersions.php
  2. 69
      lib/composer/composer/installed.json
  3. 15
      lib/composer/composer/installed.php
  4. 6
      lib/private/AppFramework/Http/Request.php
  5. 2
      tests/lib/AppFramework/Http/RequestTest.php

@ -26,6 +26,12 @@ use Composer\Semver\VersionParser;
*/
class InstalledVersions
{
/**
* @var string|null if set (by reflection by Composer), this should be set to the path where this class is being copied to
* @internal
*/
private static $selfDir = null;
/**
* @var mixed[]|null
* @psalm-var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}|array{}|null
@ -322,6 +328,18 @@ class InstalledVersions
self::$installedIsLocalDir = false;
}
/**
* @return string
*/
private static function getSelfDir()
{
if (self::$selfDir === null) {
self::$selfDir = strtr(__DIR__, '\\', '/');
}
return self::$selfDir;
}
/**
* @return array[]
* @psalm-return list<array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>}>
@ -336,7 +354,7 @@ class InstalledVersions
$copiedLocalDir = false;
if (self::$canGetVendors) {
$selfDir = strtr(__DIR__, '\\', '/');
$selfDir = self::getSelfDir();
foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) {
$vendorDir = strtr($vendorDir, '\\', '/');
if (isset(self::$installedByVendor[$vendorDir])) {

@ -1,5 +1,68 @@
{
"packages": [],
"dev": false,
"dev-package-names": []
"packages": [
{
"name": "bamarni/composer-bin-plugin",
"version": "1.8.2",
"version_normalized": "1.8.2.0",
"source": {
"type": "git",
"url": "https://github.com/bamarni/composer-bin-plugin.git",
"reference": "92fd7b1e6e9cdae19b0d57369d8ad31a37b6a880"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/bamarni/composer-bin-plugin/zipball/92fd7b1e6e9cdae19b0d57369d8ad31a37b6a880",
"reference": "92fd7b1e6e9cdae19b0d57369d8ad31a37b6a880",
"shasum": ""
},
"require": {
"composer-plugin-api": "^2.0",
"php": "^7.2.5 || ^8.0"
},
"require-dev": {
"composer/composer": "^2.0",
"ext-json": "*",
"phpstan/extension-installer": "^1.1",
"phpstan/phpstan": "^1.8",
"phpstan/phpstan-phpunit": "^1.1",
"phpunit/phpunit": "^8.5 || ^9.5",
"symfony/console": "^2.8.52 || ^3.4.35 || ^4.4 || ^5.0 || ^6.0",
"symfony/finder": "^2.8.52 || ^3.4.35 || ^4.4 || ^5.0 || ^6.0",
"symfony/process": "^2.8.52 || ^3.4.35 || ^4.4 || ^5.0 || ^6.0"
},
"time": "2022-10-31T08:38:03+00:00",
"type": "composer-plugin",
"extra": {
"class": "Bamarni\\Composer\\Bin\\BamarniBinPlugin"
},
"installation-source": "dist",
"autoload": {
"psr-4": {
"Bamarni\\Composer\\Bin\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"description": "No conflicts for your bin dependencies",
"keywords": [
"composer",
"conflict",
"dependency",
"executable",
"isolation",
"tool"
],
"support": {
"issues": "https://github.com/bamarni/composer-bin-plugin/issues",
"source": "https://github.com/bamarni/composer-bin-plugin/tree/1.8.2"
},
"install-path": "../bamarni/composer-bin-plugin"
}
],
"dev": true,
"dev-package-names": [
"bamarni/composer-bin-plugin"
]
}

@ -3,21 +3,30 @@
'name' => '__root__',
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'reference' => 'b7422ba97b7b42a9955a52031a32457ca521d740',
'reference' => 'c2cf24c4bc7f69c61df1ac5693311da15716673c',
'type' => 'library',
'install_path' => __DIR__ . '/../../../',
'aliases' => array(),
'dev' => false,
'dev' => true,
),
'versions' => array(
'__root__' => array(
'pretty_version' => 'dev-master',
'version' => 'dev-master',
'reference' => 'b7422ba97b7b42a9955a52031a32457ca521d740',
'reference' => 'c2cf24c4bc7f69c61df1ac5693311da15716673c',
'type' => 'library',
'install_path' => __DIR__ . '/../../../',
'aliases' => array(),
'dev_requirement' => false,
),
'bamarni/composer-bin-plugin' => array(
'pretty_version' => '1.8.2',
'version' => '1.8.2.0',
'reference' => '92fd7b1e6e9cdae19b0d57369d8ad31a37b6a880',
'type' => 'composer-plugin',
'install_path' => __DIR__ . '/../bamarni/composer-bin-plugin',
'aliases' => array(),
'dev_requirement' => true,
),
),
);

@ -638,7 +638,7 @@ class Request implements \ArrayAccess, \Countable, IRequest {
*/
public function getServerProtocol(): string {
$proto = 'http';
if ($this->config->getSystemValueString('overwriteprotocol') !== ''
&& $this->isOverwriteCondition()
) {
@ -660,12 +660,12 @@ class Request implements \ArrayAccess, \Countable, IRequest {
if ($proto !== 'https' && $proto !== 'http') {
// log unrecognized value so admin has a chance to fix it
\OC::$server->get(LoggerInterface::class)->critical(
\OCP\Server::get(LoggerInterface::class)->critical(
'Server protocol is malformed [falling back to http] (check overwriteprotocol and/or X-Forwarded-Proto to remedy): ' . $proto,
['app' => 'core']
);
}
// default to http if provided an invalid value
return $proto === 'https' ? 'https' : 'http';
}

@ -816,7 +816,7 @@ class RequestTest extends \Test\TestCase {
$this->assertSame('http', $request->getServerProtocol());
}
public function testGetServerProtocolWithProtoValid(): void {
$this->config
->method('getSystemValue')

Loading…
Cancel
Save