Skip to content

Commit 3fce359

Browse files
committed
fix: use OCP\Server
Signed-off-by: John Molakvoæ <skjnldsv@users.noreply.github.com>
1 parent d20cab3 commit 3fce359

File tree

5 files changed

+101
-11
lines changed

5 files changed

+101
-11
lines changed

lib/composer/composer/InstalledVersions.php

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@
2626
*/
2727
class InstalledVersions
2828
{
29+
/**
30+
* @var string|null if set (by reflection by Composer), this should be set to the path where this class is being copied to
31+
* @internal
32+
*/
33+
private static $selfDir = null;
34+
2935
/**
3036
* @var mixed[]|null
3137
* @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 @@ public static function reload($data)
322328
self::$installedIsLocalDir = false;
323329
}
324330

331+
/**
332+
* @return string
333+
*/
334+
private static function getSelfDir()
335+
{
336+
if (self::$selfDir === null) {
337+
self::$selfDir = strtr(__DIR__, '\\', '/');
338+
}
339+
340+
return self::$selfDir;
341+
}
342+
325343
/**
326344
* @return array[]
327345
* @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 @@ private static function getInstalled()
336354
$copiedLocalDir = false;
337355

338356
if (self::$canGetVendors) {
339-
$selfDir = strtr(__DIR__, '\\', '/');
357+
$selfDir = self::getSelfDir();
340358
foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) {
341359
$vendorDir = strtr($vendorDir, '\\', '/');
342360
if (isset(self::$installedByVendor[$vendorDir])) {
Lines changed: 66 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,68 @@
11
{
2-
"packages": [],
3-
"dev": false,
4-
"dev-package-names": []
2+
"packages": [
3+
{
4+
"name": "bamarni/composer-bin-plugin",
5+
"version": "1.8.2",
6+
"version_normalized": "1.8.2.0",
7+
"source": {
8+
"type": "git",
9+
"url": "https://github.com/bamarni/composer-bin-plugin.git",
10+
"reference": "92fd7b1e6e9cdae19b0d57369d8ad31a37b6a880"
11+
},
12+
"dist": {
13+
"type": "zip",
14+
"url": "https://api.github.com/repos/bamarni/composer-bin-plugin/zipball/92fd7b1e6e9cdae19b0d57369d8ad31a37b6a880",
15+
"reference": "92fd7b1e6e9cdae19b0d57369d8ad31a37b6a880",
16+
"shasum": ""
17+
},
18+
"require": {
19+
"composer-plugin-api": "^2.0",
20+
"php": "^7.2.5 || ^8.0"
21+
},
22+
"require-dev": {
23+
"composer/composer": "^2.0",
24+
"ext-json": "*",
25+
"phpstan/extension-installer": "^1.1",
26+
"phpstan/phpstan": "^1.8",
27+
"phpstan/phpstan-phpunit": "^1.1",
28+
"phpunit/phpunit": "^8.5 || ^9.5",
29+
"symfony/console": "^2.8.52 || ^3.4.35 || ^4.4 || ^5.0 || ^6.0",
30+
"symfony/finder": "^2.8.52 || ^3.4.35 || ^4.4 || ^5.0 || ^6.0",
31+
"symfony/process": "^2.8.52 || ^3.4.35 || ^4.4 || ^5.0 || ^6.0"
32+
},
33+
"time": "2022-10-31T08:38:03+00:00",
34+
"type": "composer-plugin",
35+
"extra": {
36+
"class": "Bamarni\\Composer\\Bin\\BamarniBinPlugin"
37+
},
38+
"installation-source": "dist",
39+
"autoload": {
40+
"psr-4": {
41+
"Bamarni\\Composer\\Bin\\": "src"
42+
}
43+
},
44+
"notification-url": "https://packagist.org/downloads/",
45+
"license": [
46+
"MIT"
47+
],
48+
"description": "No conflicts for your bin dependencies",
49+
"keywords": [
50+
"composer",
51+
"conflict",
52+
"dependency",
53+
"executable",
54+
"isolation",
55+
"tool"
56+
],
57+
"support": {
58+
"issues": "https://github.com/bamarni/composer-bin-plugin/issues",
59+
"source": "https://github.com/bamarni/composer-bin-plugin/tree/1.8.2"
60+
},
61+
"install-path": "../bamarni/composer-bin-plugin"
62+
}
63+
],
64+
"dev": true,
65+
"dev-package-names": [
66+
"bamarni/composer-bin-plugin"
67+
]
568
}

lib/composer/composer/installed.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,30 @@
33
'name' => '__root__',
44
'pretty_version' => 'dev-master',
55
'version' => 'dev-master',
6-
'reference' => 'b7422ba97b7b42a9955a52031a32457ca521d740',
6+
'reference' => 'c2cf24c4bc7f69c61df1ac5693311da15716673c',
77
'type' => 'library',
88
'install_path' => __DIR__ . '/../../../',
99
'aliases' => array(),
10-
'dev' => false,
10+
'dev' => true,
1111
),
1212
'versions' => array(
1313
'__root__' => array(
1414
'pretty_version' => 'dev-master',
1515
'version' => 'dev-master',
16-
'reference' => 'b7422ba97b7b42a9955a52031a32457ca521d740',
16+
'reference' => 'c2cf24c4bc7f69c61df1ac5693311da15716673c',
1717
'type' => 'library',
1818
'install_path' => __DIR__ . '/../../../',
1919
'aliases' => array(),
2020
'dev_requirement' => false,
2121
),
22+
'bamarni/composer-bin-plugin' => array(
23+
'pretty_version' => '1.8.2',
24+
'version' => '1.8.2.0',
25+
'reference' => '92fd7b1e6e9cdae19b0d57369d8ad31a37b6a880',
26+
'type' => 'composer-plugin',
27+
'install_path' => __DIR__ . '/../bamarni/composer-bin-plugin',
28+
'aliases' => array(),
29+
'dev_requirement' => true,
30+
),
2231
),
2332
);

lib/private/AppFramework/Http/Request.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,7 @@ private function isOverwriteCondition(): bool {
638638
*/
639639
public function getServerProtocol(): string {
640640
$proto = 'http';
641-
641+
642642
if ($this->config->getSystemValueString('overwriteprotocol') !== ''
643643
&& $this->isOverwriteCondition()
644644
) {
@@ -660,12 +660,12 @@ public function getServerProtocol(): string {
660660

661661
if ($proto !== 'https' && $proto !== 'http') {
662662
// log unrecognized value so admin has a chance to fix it
663-
\OC::$server->get(LoggerInterface::class)->critical(
663+
\OCP\Server::get(LoggerInterface::class)->critical(
664664
'Server protocol is malformed [falling back to http] (check overwriteprotocol and/or X-Forwarded-Proto to remedy): ' . $proto,
665665
['app' => 'core']
666666
);
667667
}
668-
668+
669669
// default to http if provided an invalid value
670670
return $proto === 'https' ? 'https' : 'http';
671671
}

tests/lib/AppFramework/Http/RequestTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -816,7 +816,7 @@ public function testGetServerProtocolWithOverrideInValid(): void {
816816

817817
$this->assertSame('http', $request->getServerProtocol());
818818
}
819-
819+
820820
public function testGetServerProtocolWithProtoValid(): void {
821821
$this->config
822822
->method('getSystemValue')

0 commit comments

Comments
 (0)