Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
project
drupal
Commits
642f91d1
Commit
642f91d1
authored
Mar 30, 2012
by
Dries
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '8.x' of git.drupal.org:project/drupal into 8.x
parents
4c0124b7
72cf5a75
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
126 additions
and
6 deletions
+126
-6
core/includes/common.inc
core/includes/common.inc
+2
-2
core/includes/update.inc
core/includes/update.inc
+66
-0
core/modules/book/book.module
core/modules/book/book.module
+2
-2
core/modules/book/book.pages.inc
core/modules/book/book.pages.inc
+1
-1
core/modules/config/config.test
core/modules/config/config.test
+37
-0
core/modules/file/file.field.inc
core/modules/file/file.field.inc
+1
-1
core/modules/simpletest/tests/config_upgrade/config/config.test.xml
...es/simpletest/tests/config_upgrade/config/config.test.xml
+5
-0
core/modules/simpletest/tests/config_upgrade/config_upgrade.info
...dules/simpletest/tests/config_upgrade/config_upgrade.info
+6
-0
core/modules/simpletest/tests/config_upgrade/config_upgrade.module
...les/simpletest/tests/config_upgrade/config_upgrade.module
+6
-0
No files found.
core/includes/common.inc
View file @
642f91d1
...
...
@@ -531,8 +531,8 @@ function drupal_get_destination() {
* Parses a system URL string into an associative array suitable for url().
*
* This function should only be used for URLs that have been generated by the
* system,
resp.
url(). It should not be used for URLs that come from
external
* sources, or URLs that link to external resources.
* system,
such as via
url(). It should not be used for URLs that come from
*
external
sources, or URLs that link to external resources.
*
* The returned array contains a 'path' that may be passed separately to url().
* For example:
...
...
core/includes/update.inc
View file @
642f91d1
...
...
@@ -849,6 +849,72 @@ function update_retrieve_dependencies() {
return
$return
;
}
/**
* Updates config with values set on Drupal 7.x
*
* Provide a generalised method to migrate variables from Drupal 7 to Drupal 8's
* configuration management system.
*
* @param $config_name
* The name of the configuration object to retrieve. The name corresponds to
* an XML configuration file. For @code config(book.admin) @endcode, the
* config object returned will contain the contents of book.admin.xml.
* @param $variable_map
* An array to map new to old configuration naming conventions. Example:
* @code
* array('new_config' => 'old_config')
* @endcode
* This would update the value for new_config to the value old_config has in
* the variable table.
*/
function
update_variables_to_config
(
$config_name
,
$variable_map
=
array
())
{
$config
=
config
(
$config_name
);
$config_data
=
array_keys
(
$config
->
get
());
if
(
!
empty
(
$config_data
))
{
// Build a list of variables to select from the database and build a mapping
// of variable names to config keys.
foreach
(
$config_data
as
$config_key
)
{
if
(
isset
(
$variable_map
[
$config_key
]))
{
$variables
[]
=
$variable_map
[
$config_key
];
$config_keys
[
$variable_map
[
$config_key
]]
=
$config_key
;
}
else
{
$variables
[]
=
$config_key
;
$config_keys
[
$config_key
]
=
$config_key
;
}
}
// Get any variables currently defined that match the new setting names in
// the config file.
$query
=
db_select
(
'variable'
,
'v'
)
->
fields
(
'v'
)
->
condition
(
'name'
,
$variables
,
'IN'
);
$var_values
=
$query
->
execute
()
->
fetchAllKeyed
(
0
);
if
(
!
empty
(
$var_values
))
{
// Update the config system settings to use the values previously stored in
// the variable table.
try
{
foreach
(
$var_values
as
$name
=>
$val
)
{
$config
->
set
(
$config_keys
[
$name
],
unserialize
(
$val
));
}
$config
->
save
();
// Delete the old variables. The config system will throw an exception if a
// value cannot be saved, so this code will not run if there is a problem
// running the update.
$del
=
db_delete
(
'variable'
)
->
condition
(
'name'
,
$variables
,
'IN'
);
$del
->
execute
();
}
// @TODO We may want to do different error handling for different
// exception types, but for now we'll just log the exception.
catch
(
Exception
$e
)
{
watchdog_exception
(
'update'
,
$e
);
}
}
}
}
/**
* @defgroup update-api-7.x-to-8.x Update versions of API functions
* @{
...
...
core/modules/book/book.module
View file @
642f91d1
...
...
@@ -414,7 +414,7 @@ function book_get_books() {
}
/**
* Implements hook_form_BASE_FORM_ID_alter().
* Implements hook_form_BASE_FORM_ID_alter()
for node_form()
.
*
* Adds the book fieldset to the node form.
*
...
...
@@ -1036,7 +1036,7 @@ function _book_parent_depth_limit($book_link) {
}
/**
* Implements hook_form_FORM_ID_alter().
* Implements hook_form_FORM_ID_alter()
for node_delete_confirm()
.
*
* Alters the confirm form for a single node deletion.
*
...
...
core/modules/book/book.pages.inc
View file @
642f91d1
...
...
@@ -56,7 +56,7 @@ function book_export($type, $nid) {
}
/**
*
This function is called by book_export() to generate HTML for export
.
*
Generates HTML for export when invoked by book_export()
.
*
* The given node is embedded to its absolute depth in a top level section. For
* example, a child node with depth 2 in the hierarchy is contained in
...
...
core/modules/config/config.test
View file @
642f91d1
...
...
@@ -296,3 +296,40 @@ class ConfOverrideTestCase extends DrupalWebTestCase {
$this
->
assertEqual
(
$config
->
get
(
'cache'
),
$conf
[
'system.performance'
][
'cache'
]);
}
}
/**
* Tests function providing configuration upgrade from Drupal 7 to 8.
*/
class
ConfUpdate7to8TestCase
extends
DrupalWebTestCase
{
protected
$testContent
=
'Olá, Sao Paulo!'
;
public
static
function
getInfo
()
{
return
array
(
'name'
=>
'Configuration update from Drupal 7 to 8'
,
'description'
=>
'Tests the ability to update Drupal 7 variables to the
configuration management system.'
,
'group'
=>
'Configuration'
,
);
}
function
setUp
()
{
parent
::
setUp
(
'config_upgrade'
);
require_once
DRUPAL_ROOT
.
'/core/includes/update.inc'
;
}
/**
* Test configuration update function.
*/
function
testConfigurationUpdate
()
{
// Ensure that the variable table has the object. The variable table will
// remain in place for Drupal 8 to provide an upgrade path for overridden
// variables.
db_merge
(
'variable'
)
->
key
(
array
(
'name'
=>
'config_test_foo'
))
->
fields
(
array
(
'value'
=>
serialize
(
$this
->
testContent
)))
->
execute
();
db_merge
(
'variable'
)
->
key
(
array
(
'name'
=>
'config_bar'
))
->
fields
(
array
(
'value'
=>
serialize
(
$this
->
testContent
)))
->
execute
();
update_variables_to_config
(
'config.test'
,
array
(
'config_test_bar'
=>
'config_bar'
));
$config
=
config
(
'config.test'
);
$this
->
assertEqual
(
$config
->
get
(
'config_test_foo'
),
$this
->
testContent
);
$this
->
assertEqual
(
$config
->
get
(
'config_test_bar'
),
$this
->
testContent
);
}
}
core/modules/file/file.field.inc
View file @
642f91d1
...
...
@@ -120,7 +120,7 @@ function file_field_instance_settings_form($field, $instance) {
}
/**
* Render API callback: Validates the maximum uplo
d
ad size field.
* Render API callback: Validates the maximum upload size field.
*
* Ensures that a size has been entered and that it can be parsed by
* parse_size().
...
...
core/modules/simpletest/tests/config_upgrade/config/config.test.xml
0 → 100644
View file @
642f91d1
<?xml version="1.0"?>
<config>
<config_test_foo>
bar
</config_test_foo>
<config_test_bar>
foo
</config_test_bar>
</config>
core/modules/simpletest/tests/config_upgrade/config_upgrade.info
0 → 100644
View file @
642f91d1
name
=
Config
upgrade
tests
description
=
A
support
module
for
update_variables_to_config
testing
.
core
=
8.
x
package
=
Testing
version
=
VERSION
hidden
=
TRUE
core/modules/simpletest/tests/config_upgrade/config_upgrade.module
0 → 100644
View file @
642f91d1
<?php
/**
* @file
* A support module for update_variables_to_config() testing.
*/
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment