Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
provision
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
provision
Commits
bba5bd8f
Commit
bba5bd8f
authored
Mar 5, 2014
by
Herman van Rink
Browse files
Options
Downloads
Plain Diff
Merge branch '6.x-2.x-backports' into 6.x-2.x
parents
643cc6bb
f36871af
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
platform/drupal/deploy_7.inc
+48
-0
48 additions, 0 deletions
platform/drupal/deploy_7.inc
with
48 additions
and
0 deletions
platform/drupal/deploy_7.inc
+
48
−
0
View file @
bba5bd8f
<?php
/**
* @file
*
* Update paths inside database content for sites cloned/migrated/renamed.
*/
$new_url
=
drush_get_option
(
'uri'
);
$old_url
=
drush_get_option
(
'old_uri'
);
...
...
@@ -11,6 +17,48 @@ $old_url = drush_get_option('old_uri');
*/
if
(
$new_url
!=
$old_url
)
{
$url_changed
=
TRUE
;
}
if
(
$url_changed
)
{
_provision_platform_drupal_deploy_7_replace
(
$old_url
,
$new_url
);
_provision_platform_drupal_deploy_7_replace
(
'default'
,
$new_url
);
// Is the URI in the site_name?
$site_name
=
variable_get
(
'site_name'
);
$old_url_pattern_short
=
'/'
.
preg_quote
(
$old_url
)
.
'/'
;
if
(
preg_match
(
$old_url_pattern_short
,
$site_name
))
{
variable_set
(
'site_name'
,
preg_replace
(
$old_url_pattern_short
,
$new_url
,
$site_name
));
}
}
function
_provision_platform_drupal_deploy_7_replace
(
$old_url
,
$new_url
)
{
// Update paths for sites cloned/migrated/renamed in the multisite install.
$replace_patterns
=
array
(
':old'
=>
'sites/'
.
$old_url
,
':new'
=>
'sites/'
.
$new_url
,
);
db_query
(
"UPDATE
{
block_custom
}
SET body = REPLACE(body, :old, :new)"
,
$replace_patterns
);
db_query
(
"UPDATE
{
system
}
SET filename = REPLACE(filename, :old, :new)"
,
$replace_patterns
);
$field_map
=
field_info_field_map
();
foreach
(
$field_map
as
$key
=>
$info
)
{
$tablekey
=
db_escape_table
(
$key
);
// Replace in all known text fields.
if
(
in_array
(
$info
[
'type'
],
array
(
'text_long'
,
'text_with_summary'
)))
{
drush_log
(
'Replacing in '
.
$key
,
'debug'
);
db_query
(
"UPDATE
{
field_data_${tablekey}
}
SET ${tablekey}_value = REPLACE(${tablekey}_value, :old, :new)"
,
$replace_patterns
);
db_query
(
"UPDATE
{
field_revision_${tablekey}
}
SET ${tablekey}_value = REPLACE(${tablekey}_value, :old, :new)"
,
$replace_patterns
);
}
// Replace in the optional summary.
if
(
$info
[
'type'
]
==
'text_with_summary'
)
{
drush_log
(
'Replacing summary in '
.
$key
,
'debug'
);
db_query
(
"UPDATE
{
field_data_${tablekey}
}
SET ${tablekey}_summary = REPLACE(${tablekey}_summary, :old, :new)"
,
$replace_patterns
);
db_query
(
"UPDATE
{
field_revision_${tablekey}
}
SET ${tablekey}_summary = REPLACE(${tablekey}_summary, :old, :new)"
,
$replace_patterns
);
}
}
drush_log
(
dt
(
'Changed paths from sites/@old_url to sites/@new_url'
,
array
(
'@old_url'
=>
$old_url
,
'@new_url'
=>
$new_url
)));
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment