-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MAGETWO-70840: more safe includes on application start #3129
- Loading branch information
Showing
5 changed files
with
53 additions
and
24 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
/** | ||
* Glob patterns relative to the project root directory, used by | ||
* registration.php to generate a list of includes. | ||
*/ | ||
return [ | ||
'app/code/*/*/cli_commands.php', | ||
'app/code/*/*/registration.php', | ||
'app/design/*/*/*/registration.php', | ||
'app/i18n/*/*/registration.php', | ||
'lib/internal/*/*/registration.php', | ||
'lib/internal/*/*/*/registration.php', | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
//Register components (via a list of glob patterns) | ||
namespace Magento\NonComposerComponentRegistration; | ||
|
||
use RuntimeException; | ||
|
||
/** | ||
* Include files from a list of glob patterns | ||
* | ||
* @throws RuntimeException | ||
* @return void | ||
*/ | ||
function main() | ||
{ | ||
$globPatterns = require __DIR__ . '/etc/registration_globlist.php'; | ||
$baseDir = dirname(__DIR__) . '/'; | ||
|
||
foreach ($globPatterns as $globPattern) { | ||
// Sorting is disabled intentionally for performance improvement | ||
$files = glob($baseDir . $globPattern, GLOB_NOSORT); | ||
if ($files === false) { | ||
throw new RuntimeException("glob(): error with '$baseDir$globPattern'"); | ||
} | ||
array_map(function ($file) { require_once $file; }, $files); | ||
} | ||
} | ||
|
||
main(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters