File tree Expand file tree Collapse file tree 10 files changed +385
-12
lines changed
libraries/src/Service/Provider
tests/Unit/Libraries/Cms/Service/Provider Expand file tree Collapse file tree 10 files changed +385
-12
lines changed Original file line number Diff line number Diff line change 1111
1212use Joomla \CMS \Version ;
1313use Joomla \Utilities \IpHelper ;
14+ use Symfony \Component \Dotenv \Dotenv ;
1415
1516// System includes
1617require_once JPATH_LIBRARIES . '/bootstrap.php ' ;
3839 exit ;
3940}
4041
42+ // Load .env files
43+ if (file_exists (JPATH_ROOT . '/.env.local.php ' ) || file_exists (JPATH_ROOT . '/.env ' )) {
44+ (new Dotenv ('JOOMLA_ENV ' , 'JOOMLA_DEBUG ' ))->bootEnv (JPATH_ROOT . '/.env ' , 'prod ' );
45+ }
46+
4147// Pre-Load configuration. Don't remove the Output Buffering due to BOM issues, see JCode 26026
4248ob_start ();
4349require_once JPATH_CONFIGURATION . '/configuration.php ' ;
4450ob_end_clean ();
4551
52+ // getenv() is not thread-safe and it can cause segmentaion fault, so we should try $_SERVER first
53+ $ envs = !empty ($ _SERVER ) ? $ _SERVER : getenv ();
54+
4655// System configuration.
47- $ config = new JConfig ();
56+ $ config = new JConfig ();
57+ $ config ->error_reporting = $ envs ['JOOMLA_ERROR_REPORTING ' ] ?? $ config ->error_reporting ;
58+ $ config ->debug = (bool ) ($ envs ['JOOMLA_DEBUG ' ] ?? $ config ->debug );
59+ if (isset ($ envs ['JOOMLA_LOG_DEPRECATED ' ])) {
60+ $ config ->log_deprecated = (int ) $ envs ['JOOMLA_LOG_DEPRECATED ' ];
61+ }
62+ if (isset ($ envs ['JOOMLA_BEHIND_LOADBALANCER ' ])) {
63+ $ config ->behind_loadbalancer = (bool ) $ envs ['JOOMLA_BEHIND_LOADBALANCER ' ];
64+ }
65+ unset($ envs );
4866
4967// Set the error_reporting, and adjust a global Error Handler
5068switch ($ config ->error_reporting ) {
Original file line number Diff line number Diff line change 1111
1212use Joomla \CMS \Version ;
1313use Joomla \Utilities \IpHelper ;
14+ use Symfony \Component \Dotenv \Dotenv ;
1415
1516// System includes
1617require_once JPATH_LIBRARIES . '/bootstrap.php ' ;
3839 exit ;
3940}
4041
42+ // Load .env files
43+ if (file_exists (JPATH_ROOT . '/.env.local.php ' ) || file_exists (JPATH_ROOT . '/.env ' )) {
44+ (new Dotenv ('JOOMLA_ENV ' , 'JOOMLA_DEBUG ' ))->bootEnv (JPATH_ROOT . '/.env ' , 'prod ' );
45+ }
46+
4147// Pre-Load configuration. Don't remove the Output Buffering due to BOM issues, see JCode 26026
4248ob_start ();
4349require_once JPATH_CONFIGURATION . '/configuration.php ' ;
4450ob_end_clean ();
4551
52+ // getenv() is not thread-safe and it can cause segmentaion fault, so we should try $_SERVER first
53+ $ envs = !empty ($ _SERVER ) ? $ _SERVER : getenv ();
54+
4655// System configuration.
47- $ config = new JConfig ();
56+ $ config = new JConfig ();
57+ $ config ->error_reporting = $ envs ['JOOMLA_ERROR_REPORTING ' ] ?? $ config ->error_reporting ;
58+ $ config ->debug = (bool ) ($ envs ['JOOMLA_DEBUG ' ] ?? $ config ->debug );
59+ if (isset ($ envs ['JOOMLA_LOG_DEPRECATED ' ])) {
60+ $ config ->log_deprecated = (int ) $ envs ['JOOMLA_LOG_DEPRECATED ' ];
61+ }
62+ if (isset ($ envs ['JOOMLA_BEHIND_LOADBALANCER ' ])) {
63+ $ config ->behind_loadbalancer = (bool ) $ envs ['JOOMLA_BEHIND_LOADBALANCER ' ];
64+ }
65+ unset($ envs );
4866
4967// Set the error_reporting
5068switch ($ config ->error_reporting ) {
Original file line number Diff line number Diff line change 1414 "php" : " 8.1.0"
1515 },
1616 "vendor-dir" : " libraries/vendor" ,
17- "github-protocols" : [" https" ]
17+ "github-protocols" : [
18+ " https"
19+ ]
1820 },
1921 "support" : {
2022 "issues" : " https://issues.joomla.org/" ,
2628 {
2729 "type" : " vcs" ,
2830 "url" : " https://github.com/joomla-backports/json-api-php.git" ,
29- "no-api" : true
31+ "no-api" : true
3032 },
3133 {
3234 "type" : " vcs" ,
109111 "jfcherng/php-diff" : " ^6.16.2" ,
110112 "voku/portable-utf8" : " dev-joomla-5.3 as 6.0.13" ,
111113 "php-tuf/php-tuf" : " ^1.0.2" ,
112- "php-debugbar/php-debugbar" : " ^2.1"
114+ "php-debugbar/php-debugbar" : " ^2.1" ,
115+ "symfony/dotenv" : " ^6.4"
113116 },
114117 "require-dev" : {
115118 "phpunit/phpunit" : " ^9.6.22" ,
135138 },
136139 "scripts" : {
137140 "post-install-cmd" : [
138- " php build/update_fido_cache.php"
141+ " php build/update_fido_cache.php"
139142 ]
140143 }
141144}
Original file line number Diff line number Diff line change 1+ JOOMLA_DEBUG=1
2+ JOOMLA_DEBUG_LANG=0
3+ JOOMLA_DEBUG_LANG_CONST=0
4+ JOOMLA_ERROR_REPORTING='maximum'
5+ JOOMLA_LOG_DEPRECATED=1
6+ JOOMLA_LOG_EVERYTHING=1
Original file line number Diff line number Diff line change 1+ # In all environments, the following files are loaded if they exist,
2+ # the latter taking precedence over the former:
3+ #
4+ # * .env contains default values for the environment variables needed by the app
5+ # * .env.local uncommitted file with local overrides
6+ # * .env.$JOOMLA_ENV committed environment-specific defaults
7+ # * .env.$JOOMLA_ENV.local uncommitted environment-specific overrides
8+ #
9+ # Real environment variables win over .env files.
10+ #
11+ # DO NOT DEFINE PRODUCTION SECRETS IN THIS FILE NOR IN ANY OTHER COMMITTED FILES.
12+ #
13+ # To set a configuration value use format JOOMLA_$KEY:
14+ #
15+ # JOOMLA_OFFLINE=1
16+ # JOOMLA_SITENAME='Joomla!'
17+ #
18+ # All available configuration values are listed in installation/configuration.php-dist.
19+
20+ JOOMLA_ENV=dev
21+
22+ # Database configuration
23+ #
24+ # JOOMLA_DBTYPE='mysqli'
25+ # JOOMLA_DBHOST='localhost'
26+ # JOOMLA_DBNAME='db'
27+ # JOOMLA_DBUSER='db'
28+ # JOOMLA_DBPASSWORD='db'
29+ # JOOMLA_DBPREFIX='jos_'
Original file line number Diff line number Diff line change 1212use Joomla \CMS \Uri \Uri ;
1313use Joomla \CMS \Version ;
1414use Joomla \Utilities \IpHelper ;
15+ use Symfony \Component \Dotenv \Dotenv ;
1516
1617// System includes
1718require_once JPATH_LIBRARIES . '/bootstrap.php ' ;
3940 exit ;
4041}
4142
43+ // Load .env files
44+ if (file_exists (JPATH_ROOT . '/.env.local.php ' ) || file_exists (JPATH_ROOT . '/.env ' )) {
45+ (new Dotenv ('JOOMLA_ENV ' , 'JOOMLA_DEBUG ' ))->bootEnv (JPATH_ROOT . '/.env ' , 'prod ' );
46+ }
47+
4248// Pre-Load configuration. Don't remove the Output Buffering due to BOM issues, see JCode 26026
4349ob_start ();
4450require_once JPATH_CONFIGURATION . '/configuration.php ' ;
4551ob_end_clean ();
4652
53+ // getenv() is not thread-safe and it can cause segmentaion fault, so we should try $_SERVER first
54+ $ envs = !empty ($ _SERVER ) ? $ _SERVER : getenv ();
55+
4756// System configuration.
48- $ config = new JConfig ();
57+ $ config = new JConfig ();
58+ $ config ->error_reporting = $ envs ['JOOMLA_ERROR_REPORTING ' ] ?? $ config ->error_reporting ;
59+ $ config ->debug = (bool ) ($ envs ['JOOMLA_DEBUG ' ] ?? $ config ->debug );
60+ if (isset ($ envs ['JOOMLA_LOG_DEPRECATED ' ])) {
61+ $ config ->log_deprecated = (int ) $ envs ['JOOMLA_LOG_DEPRECATED ' ];
62+ }
63+ if (isset ($ envs ['JOOMLA_BEHIND_LOADBALANCER ' ])) {
64+ $ config ->behind_loadbalancer = (bool ) $ envs ['JOOMLA_BEHIND_LOADBALANCER ' ];
65+ }
66+ unset($ envs );
4967
5068// Set the error_reporting, and adjust a global Error Handler
5169switch ($ config ->error_reporting ) {
Original file line number Diff line number Diff line change 1010
1111\defined ('_JEXEC ' ) or die;
1212
13- // Ensure sensible default for JDEBUG is set.
14- const JDEBUG = false ;
13+ use Symfony \Component \Dotenv \Dotenv ;
1514
1615// Check if a configuration file already exists.
1716if (
2625// Import the Joomla Platform.
2726require_once JPATH_LIBRARIES . '/bootstrap.php ' ;
2827
28+ // Load .env files
29+ if (file_exists (JPATH_ROOT . '/.env.local.php ' ) || file_exists (JPATH_ROOT . '/.env ' )) {
30+ (new Dotenv ('JOOMLA_ENV ' , 'JOOMLA_DEBUG ' ))->bootEnv (JPATH_ROOT . '/.env ' , 'prod ' );
31+ }
32+
33+ // Ensure sensible default for JDEBUG is set.
34+ \define ('JDEBUG ' , (bool ) ($ _SERVER ['JOOMLA_DEBUG ' ] ?? getenv ('JOOMLA_DEBUG ' )));
35+
2936// If debug mode enabled, set new Exception handler with debug enabled.
3037if (JDEBUG ) {
3138 $ errorHandler ->setExceptionHandler (
You can’t perform that action at this time.
0 commit comments