Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
D
drupal
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Custom Issue Tracker
Custom Issue Tracker
Labels
Merge Requests
291
Merge Requests
291
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
project
drupal
Commits
000966e0
Commit
000966e0
authored
Mar 24, 2014
by
alexpott
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue
#2219009
by pwolanin: Improve DX of Settings class.
parent
ec5aab42
Changes
39
Show whitespace changes
Inline
Side-by-side
Showing
39 changed files
with
140 additions
and
105 deletions
+140
-105
core/authorize.php
core/authorize.php
+3
-3
core/core.services.yml
core/core.services.yml
+1
-1
core/includes/bootstrap.inc
core/includes/bootstrap.inc
+4
-18
core/includes/common.inc
core/includes/common.inc
+4
-4
core/includes/database.inc
core/includes/database.inc
+2
-1
core/includes/file.inc
core/includes/file.inc
+4
-3
core/includes/install.core.inc
core/includes/install.core.inc
+2
-2
core/includes/install.inc
core/includes/install.inc
+1
-1
core/includes/mail.inc
core/includes/mail.inc
+2
-1
core/includes/session.inc
core/includes/session.inc
+11
-10
core/includes/theme.maintenance.inc
core/includes/theme.maintenance.inc
+4
-3
core/lib/Drupal/Component/Diff/DiffEngine.php
core/lib/Drupal/Component/Diff/DiffEngine.php
+2
-2
core/lib/Drupal/Component/PhpStorage/PhpStorageFactory.php
core/lib/Drupal/Component/PhpStorage/PhpStorageFactory.php
+1
-1
core/lib/Drupal/Component/Utility/Settings.php
core/lib/Drupal/Component/Utility/Settings.php
+32
-3
core/lib/Drupal/Core/Authentication/Provider/Cookie.php
core/lib/Drupal/Core/Authentication/Provider/Cookie.php
+2
-4
core/lib/Drupal/Core/Config/BootstrapConfigStorageFactory.php
.../lib/Drupal/Core/Config/BootstrapConfigStorageFactory.php
+2
-2
core/lib/Drupal/Core/CoreServiceProvider.php
core/lib/Drupal/Core/CoreServiceProvider.php
+4
-3
core/lib/Drupal/Core/Extension/ExtensionDiscovery.php
core/lib/Drupal/Core/Extension/ExtensionDiscovery.php
+1
-1
core/lib/Drupal/Core/Form/FormBuilder.php
core/lib/Drupal/Core/Form/FormBuilder.php
+2
-1
core/lib/Drupal/Core/Mail/Plugin/Mail/PhpMail.php
core/lib/Drupal/Core/Mail/Plugin/Mail/PhpMail.php
+2
-1
core/lib/Drupal/Core/StreamWrapper/PublicStream.php
core/lib/Drupal/Core/StreamWrapper/PublicStream.php
+3
-1
core/lib/Drupal/Core/StringTranslation/Translator/CustomStrings.php
...rupal/Core/StringTranslation/Translator/CustomStrings.php
+1
-1
core/lib/Drupal/Core/Template/TwigNodeTrans.php
core/lib/Drupal/Core/Template/TwigNodeTrans.php
+2
-1
core/modules/simpletest/lib/Drupal/simpletest/DrupalUnitTestBase.php
...s/simpletest/lib/Drupal/simpletest/DrupalUnitTestBase.php
+1
-1
core/modules/simpletest/lib/Drupal/simpletest/TestBase.php
core/modules/simpletest/lib/Drupal/simpletest/TestBase.php
+4
-4
core/modules/system/lib/Drupal/system/Tests/DrupalKernel/DrupalKernelTest.php
...lib/Drupal/system/Tests/DrupalKernel/DrupalKernelTest.php
+2
-3
core/modules/system/lib/Drupal/system/Tests/File/UnmanagedCopyTest.php
...system/lib/Drupal/system/Tests/File/UnmanagedCopyTest.php
+6
-4
core/modules/system/lib/Drupal/system/Tests/File/UnmanagedMoveTest.php
...system/lib/Drupal/system/Tests/File/UnmanagedMoveTest.php
+4
-2
core/modules/system/lib/Drupal/system/Tests/KeyValueStore/StorageTestBase.php
...lib/Drupal/system/Tests/KeyValueStore/StorageTestBase.php
+1
-1
core/modules/system/lib/Drupal/system/Tests/Mail/HtmlToTextTest.php
...es/system/lib/Drupal/system/Tests/Mail/HtmlToTextTest.php
+2
-1
core/modules/system/lib/Drupal/system/Tests/System/SettingsRewriteTest.php
...em/lib/Drupal/system/Tests/System/SettingsRewriteTest.php
+2
-1
core/modules/system/system.install
core/modules/system/system.install
+4
-3
core/modules/update/update.module
core/modules/update/update.module
+3
-1
core/rebuild.php
core/rebuild.php
+3
-2
core/scripts/rebuild_token_calculator.sh
core/scripts/rebuild_token_calculator.sh
+2
-1
core/scripts/run-tests.sh
core/scripts/run-tests.sh
+1
-1
core/tests/Drupal/Tests/Component/Utility/SettingsTest.php
core/tests/Drupal/Tests/Component/Utility/SettingsTest.php
+7
-7
core/themes/engines/twig/twig.engine
core/themes/engines/twig/twig.engine
+2
-1
core/update.php
core/update.php
+4
-4
No files found.
core/authorize.php
View file @
000966e0
...
@@ -20,7 +20,7 @@
...
@@ -20,7 +20,7 @@
* @link authorize Authorized operation helper functions @endlink
* @link authorize Authorized operation helper functions @endlink
*/
*/
use
Symfony\Component\HttpFoundation\Request
;
use
Drupal\Component\Utility\Settings
;
// Change the directory to the Drupal root.
// Change the directory to the Drupal root.
chdir
(
'..'
);
chdir
(
'..'
);
...
@@ -46,9 +46,9 @@
...
@@ -46,9 +46,9 @@
* TRUE if the current user can run authorize.php, and FALSE if not.
* TRUE if the current user can run authorize.php, and FALSE if not.
*/
*/
function
authorize_access_allowed
()
{
function
authorize_access_allowed
()
{
require_once
DRUPAL_ROOT
.
'/'
.
settings
()
->
get
(
'session_inc'
,
'core/includes/session.inc'
);
require_once
DRUPAL_ROOT
.
'/'
.
Settings
::
get
(
'session_inc'
,
'core/includes/session.inc'
);
drupal_session_initialize
();
drupal_session_initialize
();
return
settings
()
->
get
(
'allow_authorize_operations'
,
TRUE
)
&&
user_access
(
'administer software updates'
);
return
Settings
::
get
(
'allow_authorize_operations'
,
TRUE
)
&&
user_access
(
'administer software updates'
);
}
}
// *** Real work of the script begins here. ***
// *** Real work of the script begins here. ***
...
...
core/core.services.yml
View file @
000966e0
...
@@ -144,7 +144,7 @@ services:
...
@@ -144,7 +144,7 @@ services:
settings
:
settings
:
class
:
Drupal\Component\Utility\Settings
class
:
Drupal\Component\Utility\Settings
factory_class
:
Drupal\Component\Utility\Settings
factory_class
:
Drupal\Component\Utility\Settings
factory_method
:
get
Singleton
factory_method
:
get
Instance
state
:
state
:
class
:
Drupal\Core\KeyValueStore\State
class
:
Drupal\Core\KeyValueStore\State
arguments
:
[
'
@keyvalue'
]
arguments
:
[
'
@keyvalue'
]
...
...
core/includes/bootstrap.inc
View file @
000966e0
...
@@ -621,20 +621,6 @@ function drupal_get_filename($type, $name, $filename = NULL) {
...
@@ -621,20 +621,6 @@ function drupal_get_filename($type, $name, $filename = NULL) {
}
}
}
}
/**
* Returns a setting.
*
* Settings can be set in settings.php in the $settings array and requested
* by this function. Settings should be used over configuration for read-only,
* possibly low bootstrap configuration that is environment specific.
*
* @return \Drupal\Component\Utility\Settings
* The settings object.
*/
function
settings
()
{
return
Settings
::
getSingleton
();
}
/**
/**
* Gets the page cache cid for this request.
* Gets the page cache cid for this request.
*
*
...
@@ -946,7 +932,7 @@ function drupal_serve_page_from_cache(stdClass $cache, Response $response, Reque
...
@@ -946,7 +932,7 @@ function drupal_serve_page_from_cache(stdClass $cache, Response $response, Reque
// fields that fully determines whether a cache is permitted to use the
// fields that fully determines whether a cache is permitted to use the
// response to reply to a subsequent request for a given URL without
// response to reply to a subsequent request for a given URL without
// revalidation.
// revalidation.
if
(
!
isset
(
$boot_headers
[
'vary'
])
&&
!
settings
()
->
get
(
'omit_vary_cookie'
))
{
if
(
!
isset
(
$boot_headers
[
'vary'
])
&&
!
Settings
::
get
(
'omit_vary_cookie'
))
{
$response
->
setVary
(
'Cookie'
,
FALSE
);
$response
->
setVary
(
'Cookie'
,
FALSE
);
}
}
...
@@ -1514,7 +1500,7 @@ function drupal_get_user_timezone() {
...
@@ -1514,7 +1500,7 @@ function drupal_get_user_timezone() {
* A salt based on information in settings.php, not in the database.
* A salt based on information in settings.php, not in the database.
*/
*/
function
drupal_get_hash_salt
()
{
function
drupal_get_hash_salt
()
{
$hash_salt
=
settings
()
->
get
(
'hash_salt'
);
$hash_salt
=
Settings
::
get
(
'hash_salt'
);
// This should never happen, as it breaks user logins and many other services.
// This should never happen, as it breaks user logins and many other services.
// Therefore, explicitly notify the user (developer) by throwing an exception.
// Therefore, explicitly notify the user (developer) by throwing an exception.
if
(
empty
(
$hash_salt
))
{
if
(
empty
(
$hash_salt
))
{
...
@@ -1642,7 +1628,7 @@ function _drupal_bootstrap_page_cache() {
...
@@ -1642,7 +1628,7 @@ function _drupal_bootstrap_page_cache() {
require_once
__DIR__
.
'/database.inc'
;
require_once
__DIR__
.
'/database.inc'
;
// Check for a cache mode force from settings.php.
// Check for a cache mode force from settings.php.
if
(
settings
()
->
get
(
'page_cache_without_database'
))
{
if
(
Settings
::
get
(
'page_cache_without_database'
))
{
$cache_enabled
=
TRUE
;
$cache_enabled
=
TRUE
;
}
}
else
{
else
{
...
@@ -2113,7 +2099,7 @@ function drupal_classloader($class_loader = NULL) {
...
@@ -2113,7 +2099,7 @@ function drupal_classloader($class_loader = NULL) {
// findFile() method, but none of the others. The actual registry is still
// findFile() method, but none of the others. The actual registry is still
// in ClassLoader.
// in ClassLoader.
if
(
!
isset
(
$class_loader
))
{
if
(
!
isset
(
$class_loader
))
{
$class_loader
=
settings
()
->
get
(
'class_loader'
,
'default'
);
$class_loader
=
Settings
::
get
(
'class_loader'
,
'default'
);
}
}
if
(
$class_loader
===
'apc'
)
{
if
(
$class_loader
===
'apc'
)
{
require_once
__DIR__
.
'/../vendor/symfony/class-loader/Symfony/Component/ClassLoader/ApcClassLoader.php'
;
require_once
__DIR__
.
'/../vendor/symfony/class-loader/Symfony/Component/ClassLoader/ApcClassLoader.php'
;
...
...
core/includes/common.inc
View file @
000966e0
...
@@ -207,7 +207,7 @@ function drupal_get_profile() {
...
@@ -207,7 +207,7 @@ function drupal_get_profile() {
}
}
}
}
else
{
else
{
$profile
=
settings
()
->
get
(
'install_profile'
)
?:
'standard'
;
$profile
=
Settings
::
get
(
'install_profile'
)
?:
'standard'
;
}
}
return
$profile
;
return
$profile
;
...
@@ -496,7 +496,7 @@ function _external_url_is_local($url) {
...
@@ -496,7 +496,7 @@ function _external_url_is_local($url) {
* TRUE if a proxy should be used for this host.
* TRUE if a proxy should be used for this host.
*/
*/
function
_drupal_http_use_proxy
(
$host
)
{
function
_drupal_http_use_proxy
(
$host
)
{
$proxy_exceptions
=
settings
()
->
get
(
'proxy_exceptions'
,
array
(
'localhost'
,
'127.0.0.1'
));
$proxy_exceptions
=
Settings
::
get
(
'proxy_exceptions'
,
array
(
'localhost'
,
'127.0.0.1'
));
return
!
in_array
(
strtolower
(
$host
),
$proxy_exceptions
,
TRUE
);
return
!
in_array
(
strtolower
(
$host
),
$proxy_exceptions
,
TRUE
);
}
}
...
@@ -3077,11 +3077,11 @@ function drupal_valid_token($token, $value = '', $skip_anonymous = FALSE) {
...
@@ -3077,11 +3077,11 @@ function drupal_valid_token($token, $value = '', $skip_anonymous = FALSE) {
* Loads code for subsystems and modules, and registers stream wrappers.
* Loads code for subsystems and modules, and registers stream wrappers.
*/
*/
function
_drupal_bootstrap_code
()
{
function
_drupal_bootstrap_code
()
{
require_once
__DIR__
.
'/../../'
.
settings
()
->
get
(
'path_inc'
,
'core/includes/path.inc'
);
require_once
__DIR__
.
'/../../'
.
Settings
::
get
(
'path_inc'
,
'core/includes/path.inc'
);
require_once
__DIR__
.
'/module.inc'
;
require_once
__DIR__
.
'/module.inc'
;
require_once
__DIR__
.
'/theme.inc'
;
require_once
__DIR__
.
'/theme.inc'
;
require_once
__DIR__
.
'/pager.inc'
;
require_once
__DIR__
.
'/pager.inc'
;
require_once
__DIR__
.
'/../../'
.
settings
()
->
get
(
'menu_inc'
,
'core/includes/menu.inc'
);
require_once
__DIR__
.
'/../../'
.
Settings
::
get
(
'menu_inc'
,
'core/includes/menu.inc'
);
require_once
__DIR__
.
'/tablesort.inc'
;
require_once
__DIR__
.
'/tablesort.inc'
;
require_once
__DIR__
.
'/file.inc'
;
require_once
__DIR__
.
'/file.inc'
;
require_once
__DIR__
.
'/unicode.inc'
;
require_once
__DIR__
.
'/unicode.inc'
;
...
...
core/includes/database.inc
View file @
000966e0
<?php
<?php
use
Drupal\Component\Utility\Settings
;
use
Drupal\Core\Database\Database
;
use
Drupal\Core\Database\Database
;
use
Drupal\Core\Database\Query\Condition
;
use
Drupal\Core\Database\Query\Condition
;
...
@@ -933,7 +934,7 @@ function db_ignore_slave() {
...
@@ -933,7 +934,7 @@ function db_ignore_slave() {
// Five minutes is long enough to allow the slave to break and resume
// Five minutes is long enough to allow the slave to break and resume
// interrupted replication without causing problems on the Drupal site from
// interrupted replication without causing problems on the Drupal site from
// the old data.
// the old data.
$duration
=
settings
()
->
get
(
'maximum_replication_lag'
,
300
);
$duration
=
Settings
::
get
(
'maximum_replication_lag'
,
300
);
// Set session variable with amount of time to delay before using slave.
// Set session variable with amount of time to delay before using slave.
$_SESSION
[
'ignore_slave_server'
]
=
REQUEST_TIME
+
$duration
;
$_SESSION
[
'ignore_slave_server'
]
=
REQUEST_TIME
+
$duration
;
}
}
...
...
core/includes/file.inc
View file @
000966e0
...
@@ -7,6 +7,7 @@
...
@@ -7,6 +7,7 @@
use
Drupal\Core\StreamWrapper\LocalStream
;
use
Drupal\Core\StreamWrapper\LocalStream
;
use
Drupal\Component\PhpStorage\FileStorage
;
use
Drupal\Component\PhpStorage\FileStorage
;
use
Drupal\Component\Utility\Settings
;
use
Drupal\Component\Utility\String
;
use
Drupal\Component\Utility\String
;
use
Drupal\Core\StreamWrapper\PublicStream
;
use
Drupal\Core\StreamWrapper\PublicStream
;
...
@@ -1336,10 +1337,10 @@ function file_get_mimetype($uri, $mapping = NULL) {
...
@@ -1336,10 +1337,10 @@ function file_get_mimetype($uri, $mapping = NULL) {
function
drupal_chmod
(
$uri
,
$mode
=
NULL
)
{
function
drupal_chmod
(
$uri
,
$mode
=
NULL
)
{
if
(
!
isset
(
$mode
))
{
if
(
!
isset
(
$mode
))
{
if
(
is_dir
(
$uri
))
{
if
(
is_dir
(
$uri
))
{
$mode
=
settings
()
->
get
(
'file_chmod_directory'
,
FILE_CHMOD_DIRECTORY
);
$mode
=
Settings
::
get
(
'file_chmod_directory'
,
FILE_CHMOD_DIRECTORY
);
}
}
else
{
else
{
$mode
=
settings
()
->
get
(
'file_chmod_file'
,
FILE_CHMOD_FILE
);
$mode
=
Settings
::
get
(
'file_chmod_file'
,
FILE_CHMOD_FILE
);
}
}
}
}
...
@@ -1513,7 +1514,7 @@ function drupal_basename($uri, $suffix = NULL) {
...
@@ -1513,7 +1514,7 @@ function drupal_basename($uri, $suffix = NULL) {
*/
*/
function
drupal_mkdir
(
$uri
,
$mode
=
NULL
,
$recursive
=
FALSE
,
$context
=
NULL
)
{
function
drupal_mkdir
(
$uri
,
$mode
=
NULL
,
$recursive
=
FALSE
,
$context
=
NULL
)
{
if
(
!
isset
(
$mode
))
{
if
(
!
isset
(
$mode
))
{
$mode
=
settings
()
->
get
(
'file_chmod_directory'
,
FILE_CHMOD_DIRECTORY
);
$mode
=
Settings
::
get
(
'file_chmod_directory'
,
FILE_CHMOD_DIRECTORY
);
}
}
// If the URI has a scheme, don't override the umask - schemes can handle this
// If the URI has a scheme, don't override the umask - schemes can handle this
...
...
core/includes/install.core.inc
View file @
000966e0
...
@@ -294,7 +294,7 @@ function install_begin_request(&$install_state) {
...
@@ -294,7 +294,7 @@ function install_begin_request(&$install_state) {
require_once
__DIR__
.
'/file.inc'
;
require_once
__DIR__
.
'/file.inc'
;
require_once
__DIR__
.
'/install.inc'
;
require_once
__DIR__
.
'/install.inc'
;
require_once
__DIR__
.
'/schema.inc'
;
require_once
__DIR__
.
'/schema.inc'
;
require_once
__DIR__
.
'/../../'
.
settings
()
->
get
(
'path_inc'
,
'core/includes/path.inc'
);
require_once
__DIR__
.
'/../../'
.
Settings
::
get
(
'path_inc'
,
'core/includes/path.inc'
);
require_once
__DIR__
.
'/database.inc'
;
require_once
__DIR__
.
'/database.inc'
;
require_once
__DIR__
.
'/form.inc'
;
require_once
__DIR__
.
'/form.inc'
;
require_once
__DIR__
.
'/batch.inc'
;
require_once
__DIR__
.
'/batch.inc'
;
...
@@ -1777,7 +1777,7 @@ function install_load_profile(&$install_state) {
...
@@ -1777,7 +1777,7 @@ function install_load_profile(&$install_state) {
*/
*/
function
install_bootstrap_full
()
{
function
install_bootstrap_full
()
{
drupal_bootstrap
(
DRUPAL_BOOTSTRAP_FULL
);
drupal_bootstrap
(
DRUPAL_BOOTSTRAP_FULL
);
require_once
DRUPAL_ROOT
.
'/'
.
settings
()
->
get
(
'session_inc'
,
'core/includes/session.inc'
);
require_once
DRUPAL_ROOT
.
'/'
.
Settings
::
get
(
'session_inc'
,
'core/includes/session.inc'
);
drupal_session_initialize
();
drupal_session_initialize
();
}
}
...
...
core/includes/install.inc
View file @
000966e0
...
@@ -317,7 +317,7 @@ function drupal_rewrite_settings($settings = array(), $settings_file = NULL) {
...
@@ -317,7 +317,7 @@ function drupal_rewrite_settings($settings = array(), $settings_file = NULL) {
// In case any $settings variables were written, import them into the
// In case any $settings variables were written, import them into the
// Settings singleton.
// Settings singleton.
if
(
!
empty
(
$settings_settings
))
{
if
(
!
empty
(
$settings_settings
))
{
$old_settings
=
settings
()
->
getAll
();
$old_settings
=
Settings
::
getAll
();
new
Settings
(
$settings_settings
+
$old_settings
);
new
Settings
(
$settings_settings
+
$old_settings
);
}
}
}
}
...
...
core/includes/mail.inc
View file @
000966e0
...
@@ -6,6 +6,7 @@
...
@@ -6,6 +6,7 @@
*/
*/
use
Drupal\Component\Utility\Html
;
use
Drupal\Component\Utility\Html
;
use
Drupal\Component\Utility\Settings
;
use
Drupal\Component\Utility\Xss
;
use
Drupal\Component\Utility\Xss
;
/**
/**
...
@@ -426,7 +427,7 @@ function drupal_html_to_text($string, $allowed_tags = NULL) {
...
@@ -426,7 +427,7 @@ function drupal_html_to_text($string, $allowed_tags = NULL) {
if
(
isset
(
$casing
))
{
if
(
isset
(
$casing
))
{
$chunk
=
$casing
(
$chunk
);
$chunk
=
$casing
(
$chunk
);
}
}
$line_endings
=
settings
()
->
get
(
'mail_line_endings'
,
PHP_EOL
);
$line_endings
=
Settings
::
get
(
'mail_line_endings'
,
PHP_EOL
);
// Format it and apply the current indentation.
// Format it and apply the current indentation.
$output
.
=
drupal_wrap_mail
(
$chunk
,
implode
(
''
,
$indent
))
.
$line_endings
;
$output
.
=
drupal_wrap_mail
(
$chunk
,
implode
(
''
,
$indent
))
.
$line_endings
;
// Remove non-quotation markers from indentation.
// Remove non-quotation markers from indentation.
...
...
core/includes/session.inc
View file @
000966e0
...
@@ -17,6 +17,7 @@
...
@@ -17,6 +17,7 @@
*/
*/
use
Drupal\Component\Utility\Crypt
;
use
Drupal\Component\Utility\Crypt
;
use
Drupal\Component\Utility\Settings
;
use
Drupal\Core\Session\UserSession
;
use
Drupal\Core\Session\UserSession
;
use
Drupal\Core\Utility\Error
;
use
Drupal\Core\Utility\Error
;
...
@@ -175,7 +176,7 @@ function _drupal_session_write($sid, $value) {
...
@@ -175,7 +176,7 @@ function _drupal_session_write($sid, $value) {
// For performance reasons, do not update the sessions table, unless
// For performance reasons, do not update the sessions table, unless
// $_SESSION has changed or more than 180 has passed since the last update.
// $_SESSION has changed or more than 180 has passed since the last update.
if
(
$is_changed
||
!
$user
->
getLastAccessedTime
()
||
REQUEST_TIME
-
$user
->
getLastAccessedTime
()
>
settings
()
->
get
(
'session_write_interval'
,
180
))
{
if
(
$is_changed
||
!
$user
->
getLastAccessedTime
()
||
REQUEST_TIME
-
$user
->
getLastAccessedTime
()
>
Settings
::
get
(
'session_write_interval'
,
180
))
{
// Either ssid or sid or both will be added from $key below.
// Either ssid or sid or both will be added from $key below.
$fields
=
array
(
$fields
=
array
(
'uid'
=>
$user
->
id
(),
'uid'
=>
$user
->
id
(),
...
@@ -196,14 +197,14 @@ function _drupal_session_write($sid, $value) {
...
@@ -196,14 +197,14 @@ function _drupal_session_write($sid, $value) {
// secure and insecure session cookies. If enabled and both cookies are
// secure and insecure session cookies. If enabled and both cookies are
// presented then use both keys. The session ID from the cookie is
// presented then use both keys. The session ID from the cookie is
// hashed before being stored in the database as a security measure.
// hashed before being stored in the database as a security measure.
if
(
settings
()
->
get
(
'mixed_mode_sessions'
,
FALSE
))
{
if
(
Settings
::
get
(
'mixed_mode_sessions'
,
FALSE
))
{
$insecure_session_name
=
substr
(
session_name
(),
1
);
$insecure_session_name
=
substr
(
session_name
(),
1
);
if
(
$cookies
->
has
(
$insecure_session_name
))
{
if
(
$cookies
->
has
(
$insecure_session_name
))
{
$key
[
'sid'
]
=
Crypt
::
hashBase64
(
$cookies
->
get
(
$insecure_session_name
));
$key
[
'sid'
]
=
Crypt
::
hashBase64
(
$cookies
->
get
(
$insecure_session_name
));
}
}
}
}
}
}
elseif
(
settings
()
->
get
(
'mixed_mode_sessions'
,
FALSE
))
{
elseif
(
Settings
::
get
(
'mixed_mode_sessions'
,
FALSE
))
{
unset
(
$key
[
'ssid'
]);
unset
(
$key
[
'ssid'
]);
}
}
...
@@ -214,7 +215,7 @@ function _drupal_session_write($sid, $value) {
...
@@ -214,7 +215,7 @@ function _drupal_session_write($sid, $value) {
}
}
// Likewise, do not update access time more than once per 180 seconds.
// Likewise, do not update access time more than once per 180 seconds.
if
(
$user
->
isAuthenticated
()
&&
REQUEST_TIME
-
$user
->
getLastAccessedTime
()
>
settings
()
->
get
(
'session_write_interval'
,
180
))
{
if
(
$user
->
isAuthenticated
()
&&
REQUEST_TIME
-
$user
->
getLastAccessedTime
()
>
Settings
::
get
(
'session_write_interval'
,
180
))
{
db_update
(
'users'
)
db_update
(
'users'
)
->
fields
(
array
(
->
fields
(
array
(
'access'
=>
REQUEST_TIME
'access'
=>
REQUEST_TIME
...
@@ -247,7 +248,7 @@ function drupal_session_initialize() {
...
@@ -247,7 +248,7 @@ function drupal_session_initialize() {
$is_https
=
\
Drupal
::
request
()
->
isSecure
();
$is_https
=
\
Drupal
::
request
()
->
isSecure
();
$cookies
=
\
Drupal
::
request
()
->
cookies
;
$cookies
=
\
Drupal
::
request
()
->
cookies
;
if
((
$cookies
->
has
(
session_name
())
&&
(
$session_name
=
$cookies
->
get
(
session_name
())))
||
(
$is_https
&&
settings
()
->
get
(
'mixed_mode_sessions'
,
FALSE
)
&&
(
$cookies
->
has
(
substr
(
session_name
(),
1
)))
&&
(
$session_name
=
$cookies
->
get
(
substr
(
session_name
(),
1
)))))
{
if
((
$cookies
->
has
(
session_name
())
&&
(
$session_name
=
$cookies
->
get
(
session_name
())))
||
(
$is_https
&&
Settings
::
get
(
'mixed_mode_sessions'
,
FALSE
)
&&
(
$cookies
->
has
(
substr
(
session_name
(),
1
)))
&&
(
$session_name
=
$cookies
->
get
(
substr
(
session_name
(),
1
)))))
{
// If a session cookie exists, initialize the session. Otherwise the
// If a session cookie exists, initialize the session. Otherwise the
// session is only started on demand in drupal_session_commit(), making
// session is only started on demand in drupal_session_commit(), making
// anonymous users not use a session cookie unless something is stored in
// anonymous users not use a session cookie unless something is stored in
...
@@ -268,7 +269,7 @@ function drupal_session_initialize() {
...
@@ -268,7 +269,7 @@ function drupal_session_initialize() {
// anonymous users than are generated in drupal_session_regenerate() when
// anonymous users than are generated in drupal_session_regenerate() when
// a user becomes authenticated.
// a user becomes authenticated.
session_id
(
Crypt
::
randomBytesBase64
());
session_id
(
Crypt
::
randomBytesBase64
());
if
(
$is_https
&&
settings
()
->
get
(
'mixed_mode_sessions'
,
FALSE
))
{
if
(
$is_https
&&
Settings
::
get
(
'mixed_mode_sessions'
,
FALSE
))
{
$insecure_session_name
=
substr
(
session_name
(),
1
);
$insecure_session_name
=
substr
(
session_name
(),
1
);
$session_id
=
Crypt
::
randomBytesBase64
();
$session_id
=
Crypt
::
randomBytesBase64
();
$cookies
->
set
(
$insecure_session_name
,
$session_id
);
$cookies
->
set
(
$insecure_session_name
,
$session_id
);
...
@@ -323,7 +324,7 @@ function drupal_session_commit() {
...
@@ -323,7 +324,7 @@ function drupal_session_commit() {
// started.
// started.
if
(
!
drupal_session_started
())
{
if
(
!
drupal_session_started
())
{
drupal_session_start
();
drupal_session_start
();
if
(
\
Drupal
::
request
()
->
isSecure
()
&&
settings
()
->
get
(
'mixed_mode_sessions'
,
FALSE
))
{
if
(
\
Drupal
::
request
()
->
isSecure
()
&&
Settings
::
get
(
'mixed_mode_sessions'
,
FALSE
))
{
$insecure_session_name
=
substr
(
session_name
(),
1
);
$insecure_session_name
=
substr
(
session_name
(),
1
);
$params
=
session_get_cookie_params
();
$params
=
session_get_cookie_params
();
$expire
=
$params
[
'lifetime'
]
?
REQUEST_TIME
+
$params
[
'lifetime'
]
:
0
;
$expire
=
$params
[
'lifetime'
]
?
REQUEST_TIME
+
$params
[
'lifetime'
]
:
0
;
...
@@ -363,7 +364,7 @@ function drupal_session_regenerate() {
...
@@ -363,7 +364,7 @@ function drupal_session_regenerate() {
$is_https
=
\
Drupal
::
request
()
->
isSecure
();
$is_https
=
\
Drupal
::
request
()
->
isSecure
();
$cookies
=
\
Drupal
::
request
()
->
cookies
;
$cookies
=
\
Drupal
::
request
()
->
cookies
;
if
(
$is_https
&&
settings
()
->
get
(
'mixed_mode_sessions'
,
FALSE
))
{
if
(
$is_https
&&
Settings
::
get
(
'mixed_mode_sessions'
,
FALSE
))
{
$insecure_session_name
=
substr
(
session_name
(),
1
);
$insecure_session_name
=
substr
(
session_name
(),
1
);
if
(
!
isset
(
$GLOBALS
[
'lazy_session'
])
&&
$cookies
->
has
(
$insecure_session_name
))
{
if
(
!
isset
(
$GLOBALS
[
'lazy_session'
])
&&
$cookies
->
has
(
$insecure_session_name
))
{
$old_insecure_session_id
=
$cookies
->
get
(
$insecure_session_name
);
$old_insecure_session_id
=
$cookies
->
get
(
$insecure_session_name
);
...
@@ -392,7 +393,7 @@ function drupal_session_regenerate() {
...
@@ -392,7 +393,7 @@ function drupal_session_regenerate() {
$fields
[
'ssid'
]
=
Crypt
::
hashBase64
(
session_id
());
$fields
[
'ssid'
]
=
Crypt
::
hashBase64
(
session_id
());
// If the "secure pages" setting is enabled, use the newly-created
// If the "secure pages" setting is enabled, use the newly-created
// insecure session identifier as the regenerated sid.
// insecure session identifier as the regenerated sid.
if
(
settings
()
->
get
(
'mixed_mode_sessions'
,
FALSE
))
{
if
(
Settings
::
get
(
'mixed_mode_sessions'
,
FALSE
))
{
$fields
[
'sid'
]
=
Crypt
::
hashBase64
(
$session_id
);
$fields
[
'sid'
]
=
Crypt
::
hashBase64
(
$session_id
);
}
}
}
}
...
@@ -453,7 +454,7 @@ function _drupal_session_destroy($sid) {
...
@@ -453,7 +454,7 @@ function _drupal_session_destroy($sid) {
if
(
$is_https
)
{
if
(
$is_https
)
{
_drupal_session_delete_cookie
(
substr
(
session_name
(),
1
),
FALSE
);
_drupal_session_delete_cookie
(
substr
(
session_name
(),
1
),
FALSE
);
}
}
elseif
(
settings
()
->
get
(
'mixed_mode_sessions'
,
FALSE
))
{
elseif
(
Settings
::
get
(
'mixed_mode_sessions'
,
FALSE
))
{
_drupal_session_delete_cookie
(
'S'
.
session_name
(),
TRUE
);
_drupal_session_delete_cookie
(
'S'
.
session_name
(),
TRUE
);
}
}
}
}
...
...
core/includes/theme.maintenance.inc
View file @
000966e0
...
@@ -6,6 +6,7 @@
...
@@ -6,6 +6,7 @@
*/
*/
use
Drupal\Component\Utility\Unicode
;
use
Drupal\Component\Utility\Unicode
;
use
Drupal\Component\Utility\Settings
;
/**
/**
* Sets up the theming system for maintenance page.
* Sets up the theming system for maintenance page.
...
@@ -24,7 +25,7 @@ function _drupal_maintenance_theme() {
...
@@ -24,7 +25,7 @@ function _drupal_maintenance_theme() {
return
;
return
;
}
}
require_once
DRUPAL_ROOT
.
'/'
.
settings
()
->
get
(
'path_inc'
,
'core/includes/path.inc'
);
require_once
DRUPAL_ROOT
.
'/'
.
Settings
::
get
(
'path_inc'
,
'core/includes/path.inc'
);
require_once
__DIR__
.
'/theme.inc'
;
require_once
__DIR__
.
'/theme.inc'
;
require_once
__DIR__
.
'/common.inc'
;
require_once
__DIR__
.
'/common.inc'
;
require_once
__DIR__
.
'/unicode.inc'
;
require_once
__DIR__
.
'/unicode.inc'
;
...
@@ -38,7 +39,7 @@ function _drupal_maintenance_theme() {
...
@@ -38,7 +39,7 @@ function _drupal_maintenance_theme() {
$custom_theme
=
$GLOBALS
[
'install_state'
][
'theme'
];
$custom_theme
=
$GLOBALS
[
'install_state'
][
'theme'
];
}
}
else
{
else
{
$custom_theme
=
settings
()
->
get
(
'maintenance_theme'
,
'seven'
);
$custom_theme
=
Settings
::
get
(
'maintenance_theme'
,
'seven'
);
}
}
}
}
else
{
else
{
...
@@ -52,7 +53,7 @@ function _drupal_maintenance_theme() {
...
@@ -52,7 +53,7 @@ function _drupal_maintenance_theme() {
// Use the maintenance theme if specified, otherwise attempt to use the
// Use the maintenance theme if specified, otherwise attempt to use the
// default site theme.
// default site theme.
try
{
try
{
$custom_theme
=
settings
()
->
get
(
'maintenance_theme'
,
''
);
$custom_theme
=
Settings
::
get
(
'maintenance_theme'
,
''
);
if
(
!
$custom_theme
)
{
if
(
!
$custom_theme
)
{
$config
=
\
Drupal
::
config
(
'system.theme'
);
$config
=
\
Drupal
::
config
(
'system.theme'
);
$custom_theme
=
$config
->
get
(
'default'
);
$custom_theme
=
$config
->
get
(
'default'
);
...
...
core/lib/Drupal/Component/Diff/DiffEngine.php
View file @
000966e0
...
@@ -1100,8 +1100,8 @@ class DrupalDiffFormatter extends DiffFormatter {
...
@@ -1100,8 +1100,8 @@ class DrupalDiffFormatter extends DiffFormatter {
);
);
function
DrupalDiffFormatter
()
{
function
DrupalDiffFormatter
()
{
$this
->
leading_context_lines
=
Settings
::
get
Singleton
()
->
get
(
'diff_context_lines_leading'
,
2
);
$this
->
leading_context_lines
=
Settings
::
get
(
'diff_context_lines_leading'
,
2
);
$this
->
trailing_context_lines
=
Settings
::
get
Singleton
()
->
get
(
'diff_context_lines_trailing'
,
2
);
$this
->
trailing_context_lines
=
Settings
::
get
(
'diff_context_lines_trailing'
,
2
);
}
}
function
_start_diff
()
{
function
_start_diff
()
{
...
...
core/lib/Drupal/Component/PhpStorage/PhpStorageFactory.php
View file @
000966e0
...
@@ -34,7 +34,7 @@ class PhpStorageFactory {
...
@@ -34,7 +34,7 @@ class PhpStorageFactory {
* An instantiated storage controller for the specified name.
* An instantiated storage controller for the specified name.
*/
*/
static
function
get
(
$name
)
{
static
function
get
(
$name
)
{
$overrides
=
Settings
::
get
Singleton
()
->
get
(
'php_storage'
);
$overrides
=
Settings
::
get
(
'php_storage'
);
if
(
isset
(
$overrides
[
$name
]))
{
if
(
isset
(
$overrides
[
$name
]))
{
$configuration
=
$overrides
[
$name
];
$configuration
=
$overrides
[
$name
];
}
}
...
...
core/lib/Drupal/Component/Utility/Settings.php
View file @
000966e0
...
@@ -34,10 +34,39 @@ final class Settings {
...
@@ -34,10 +34,39 @@ final class Settings {
*
*
* @return \Drupal\Component\Utility\Settings
* @return \Drupal\Component\Utility\Settings
*/
*/
public
static
function
get
Singleton
()
{
public
static
function
get
Instance
()
{
return
self
::
$instance
;
return
self
::
$instance
;
}
}
/**
* Returns a setting.
*
* Settings can be set in settings.php in the $settings array and requested
* by this function. Settings should be used over configuration for read-only,
* possibly low bootstrap configuration that is environment specific.
*
* @param string $name
* The name of the setting to return.
* @param mixed $default
* (optional) The default value to use if this setting is not set.
*
* @return mixed
* The value of the setting, the provided default if not set.
*/
public
static
function
get
(
$name
,
$default
=
NULL
)
{
return
self
::
$instance
->
getSetting
(
$name
,
$default
);
}
/**
* Returns all the settings. This is only used for testing purposes.
*
* @return array
* All the settings.
*/
public
static
function
getAll
()
{
return
self
::
$instance
->
getAllSettings
();
}
/**
/**
* Constructor.
* Constructor.
*
*
...
@@ -64,7 +93,7 @@ function __construct(array $settings) {
...
@@ -64,7 +93,7 @@ function __construct(array $settings) {
* @return mixed
* @return mixed
* The value of the setting, the provided default if not set.
* The value of the setting, the provided default if not set.
*/
*/
public
function
get
(
$name
,
$default
=
NULL
)
{
public
function
get
Setting
(
$name
,
$default
=
NULL
)
{
return
isset