Skip to content

Commit 61373fd

Browse files
author
Anna Bukatar
committed
Merge branch 'ACP2E-276' of https://github.com/magento-l3/magento2ce into PR-2022-02-22
2 parents 5dca154 + d671338 commit 61373fd

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

pub/get.php

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
<?php
22
/**
3-
* Public media files entry point
4-
*
53
* Copyright © Magento, Inc. All rights reserved.
64
* See COPYING.txt for license details.
75
*/
6+
/**
7+
* Public media files entry point
8+
*/
9+
// phpcs:disable Magento2.Functions.DiscouragedFunction.DiscouragedWithAlternative
10+
// phpcs:disable Magento2.Functions.DiscouragedFunction.Discouraged
11+
// phpcs:disable Magento2.Security.IncludeFile.FoundIncludeFile
12+
// phpcs:disable Magento2.Security.LanguageConstruct.ExitUsage
813

14+
use Magento\Framework\App\Bootstrap;
915
use Magento\Framework\App\Cache\Frontend\Factory;
1016
use Magento\Framework\App\ObjectManagerFactory;
1117
use Magento\Framework\HTTP\PhpEnvironment\Request;
@@ -26,6 +32,13 @@
2632
return false;
2733
};
2834

35+
$createBootstrap = function (array $params = []) {
36+
// phpcs:ignore Magento2.Security.Superglobal.SuperglobalUsageWarning
37+
$params = array_merge($_SERVER, $params);
38+
39+
return Bootstrap::create(BP, $params);
40+
};
41+
2942
$request = new \Magento\MediaStorage\Model\File\Storage\Request(
3043
new Request(
3144
new PhpCookieReader(),
@@ -56,6 +69,10 @@
5669
require_once 'errors/404.php';
5770
exit;
5871
}
72+
73+
// Need to run for object manager instantiation.
74+
$createBootstrap();
75+
5976
$transfer = new \Magento\Framework\File\Transfer\Adapter\Http(
6077
new \Magento\Framework\HTTP\PhpEnvironment\Response(),
6178
new \Magento\Framework\File\Mime()
@@ -68,12 +85,12 @@
6885
}
6986

7087
// Materialize file in application
71-
$params = $_SERVER;
88+
$params = [];
7289
if (empty($mediaDirectory)) {
7390
$params[ObjectManagerFactory::INIT_PARAM_DEPLOYMENT_CONFIG] = [];
7491
$params[Factory::PARAM_CACHE_FORCED_OPTIONS] = ['frontend_options' => ['disable_save' => true]];
7592
}
76-
$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $params);
93+
$bootstrap = $createBootstrap($params);
7794
/** @var \Magento\MediaStorage\App\Media $app */
7895
$app = $bootstrap->createApplication(
7996
\Magento\MediaStorage\App\Media::class,

0 commit comments

Comments
 (0)