|
1 | 1 | <?php
|
2 | 2 | /**
|
3 |
| - * Public media files entry point |
4 |
| - * |
5 | 3 | * Copyright © Magento, Inc. All rights reserved.
|
6 | 4 | * See COPYING.txt for license details.
|
7 | 5 | */
|
| 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 |
8 | 13 |
|
| 14 | +use Magento\Framework\App\Bootstrap; |
9 | 15 | use Magento\Framework\App\Cache\Frontend\Factory;
|
10 | 16 | use Magento\Framework\App\ObjectManagerFactory;
|
11 | 17 | use Magento\Framework\HTTP\PhpEnvironment\Request;
|
|
26 | 32 | return false;
|
27 | 33 | };
|
28 | 34 |
|
| 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 | + |
29 | 42 | $request = new \Magento\MediaStorage\Model\File\Storage\Request(
|
30 | 43 | new Request(
|
31 | 44 | new PhpCookieReader(),
|
|
56 | 69 | require_once 'errors/404.php';
|
57 | 70 | exit;
|
58 | 71 | }
|
| 72 | + |
| 73 | + // Need to run for object manager instantiation. |
| 74 | + $createBootstrap(); |
| 75 | + |
59 | 76 | $transfer = new \Magento\Framework\File\Transfer\Adapter\Http(
|
60 | 77 | new \Magento\Framework\HTTP\PhpEnvironment\Response(),
|
61 | 78 | new \Magento\Framework\File\Mime()
|
|
68 | 85 | }
|
69 | 86 |
|
70 | 87 | // Materialize file in application
|
71 |
| -$params = $_SERVER; |
| 88 | +$params = []; |
72 | 89 | if (empty($mediaDirectory)) {
|
73 | 90 | $params[ObjectManagerFactory::INIT_PARAM_DEPLOYMENT_CONFIG] = [];
|
74 | 91 | $params[Factory::PARAM_CACHE_FORCED_OPTIONS] = ['frontend_options' => ['disable_save' => true]];
|
75 | 92 | }
|
76 |
| -$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $params); |
| 93 | +$bootstrap = $createBootstrap($params); |
77 | 94 | /** @var \Magento\MediaStorage\App\Media $app */
|
78 | 95 | $app = $bootstrap->createApplication(
|
79 | 96 | \Magento\MediaStorage\App\Media::class,
|
|
0 commit comments