Skip to content

Commit 5b7fed8

Browse files
author
Oleksii Korshenko
committed
MAGETWO-70840: more safe includes on application start #3129
- updated glob list to use the path relative to project root - fixed tests
1 parent b293562 commit 5b7fed8

File tree

3 files changed

+17
-22
lines changed

3 files changed

+17
-22
lines changed

app/etc/registration_globlist.php

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
<?php
22
/**
3-
* Glob patterns relative to this files parent directory, used by
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
/**
8+
* Glob patterns relative to the project root directory, used by
49
* registration.php to generate a list of includes.
510
*/
611
return [
7-
'code/*/*/cli_commands.php',
8-
'code/*/*/registration.php',
9-
'design/*/*/*/registration.php',
10-
'i18n/*/*/registration.php',
11-
'../lib/internal/*/*/registration.php',
12-
'../lib/internal/*/*/*/registration.php',
12+
'app/code/*/*/cli_commands.php',
13+
'app/code/*/*/registration.php',
14+
'app/design/*/*/*/registration.php',
15+
'app/i18n/*/*/registration.php',
16+
'lib/internal/*/*/registration.php',
17+
'lib/internal/*/*/*/registration.php',
1318
];

app/registration.php

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
<?php
22
/**
3-
* Register components (via a list of glob patterns)
4-
*
5-
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
3+
* Copyright © Magento, Inc. All rights reserved.
64
* See COPYING.txt for license details.
75
*/
86

7+
//Register components (via a list of glob patterns)
98
namespace Magento\NonComposerComponentRegistration;
109

1110
use RuntimeException;
@@ -19,25 +18,16 @@
1918
function main()
2019
{
2120
$globPatterns = require __DIR__ . '/etc/registration_globlist.php';
22-
$baseDir = __DIR__ . '/';
21+
$baseDir = dirname(__DIR__) . '/';
2322

2423
foreach ($globPatterns as $globPattern) {
2524
// Sorting is disabled intentionally for performance improvement
2625
$files = glob($baseDir . $globPattern, GLOB_NOSORT);
2726
if ($files === false) {
2827
throw new RuntimeException("glob(): error with '$baseDir$globPattern'");
2928
}
30-
array_map(__NAMESPACE__ . '\file', $files);
29+
array_map(function ($file) { require_once $file; }, $files);
3130
}
3231
}
3332

34-
/**
35-
* Isolated include with it's own variable scope
36-
*
37-
* @return void
38-
*/
39-
function file() {
40-
include func_get_arg(0);
41-
}
42-
4333
main();

lib/internal/Magento/Framework/App/Test/Unit/_files/test.composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
"": "app/code/"
5656
},
5757
"files": [
58-
"app/etc/NonComposerComponentRegistration.php"
58+
"app/registration.php"
5959
]
6060
},
6161
"autoload-dev": {

0 commit comments

Comments
 (0)