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
315
Merge Requests
315
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
7d7aa979
Commit
7d7aa979
authored
Aug 26, 2012
by
webchick
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Temporary rollback of
#1688144
as it seems to be failing.
parent
d5702e7b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
58 deletions
+4
-58
core/modules/translation/lib/Drupal/translation/Tests/TranslationTest.php
...nslation/lib/Drupal/translation/Tests/TranslationTest.php
+2
-54
core/modules/translation/translation.module
core/modules/translation/translation.module
+2
-4
No files found.
core/modules/translation/lib/Drupal/translation/Tests/TranslationTest.php
View file @
7d7aa979
...
...
@@ -249,55 +249,6 @@ function testLanguageSwitcherBlockIntegration() {
$this
->
assertLanguageSwitchLinks
(
$node
,
$node_it
,
TRUE
,
$type
);
}
/**
* Delete a basic page with a translation.
*/
function
testMultilanguageContentDelete
()
{
// Add Italian to have three items in the translation set.
$this
->
drupalLogin
(
$this
->
admin_user
);
$this
->
addLanguage
(
'it'
);
$this
->
resetCaches
();
$this
->
drupalLogin
(
$this
->
translator
);
// Create Basic page in English.
$node_title
=
$this
->
randomName
();
$node_body
=
$this
->
randomName
();
$nodes
=
array
(
'en'
=>
$this
->
createPage
(
$node_title
,
$node_body
,
'en'
));
// Add Spanish translation.
$nodes
[
'es'
]
=
$this
->
createTranslation
(
$nodes
[
'en'
],
$this
->
randomName
(),
$this
->
randomName
(),
'es'
);
// Reload the English node to get the updated tnid.
$nodes
[
'en'
]
=
node_load
(
$nodes
[
'en'
]
->
nid
,
NULL
,
TRUE
);
// Add Italian translation.
// Use Spanish translation as source, rather than the original English one
// to check correct tnid handling in createTranslation().
$nodes
[
'it'
]
=
$this
->
createTranslation
(
$nodes
[
'es'
],
$this
->
randomName
(),
$this
->
randomName
(),
'it'
);
// Delete the original translation source.
node_delete
(
$nodes
[
'en'
]
->
nid
);
// Reload the remaining nodes.
$nodes
[
'es'
]
=
node_load
(
$nodes
[
'es'
]
->
nid
,
NULL
,
TRUE
);
$nodes
[
'it'
]
=
node_load
(
$nodes
[
'it'
]
->
nid
,
NULL
,
TRUE
);
// The new tnid is selected by the state of {node}.translate.
// As the original source node has been deleted, the new tnid could be
// generated from either remaining node.
$this
->
assertNotEqual
(
$nodes
[
'es'
]
->
tnid
,
0
,
'ES still in translation set.'
);
$this
->
assertNotEqual
(
$nodes
[
'it'
]
->
tnid
,
0
,
'IT still in translation set.'
);
$this
->
assertEqual
(
$nodes
[
'es'
]
->
tnid
,
$nodes
[
'it'
]
->
tnid
,
'ES and IT still in same translation set.'
);
// Delete the spanish node.
node_delete
(
$nodes
[
'es'
]
->
nid
);
// Reload the italian node. This is the last one.
$nodes
[
'it'
]
=
node_load
(
$nodes
[
'it'
]
->
nid
,
NULL
,
TRUE
);
// The tnid must be zero.
$this
->
assertEqual
(
$nodes
[
'it'
]
->
tnid
,
0
,
'Translation set is terminated.'
);
}
/**
* Resets static caches to make the test code match the client-side behavior.
*/
...
...
@@ -347,7 +298,7 @@ function addLanguage($language_code) {
}
else
{
// It's installed. No need to do anything.
$this
->
assertTrue
(
TRUE
,
'Language ['
.
$language_code
.
'] already installed.'
);
$this
->
assertTrue
(
true
,
'Language ['
.
$language_code
.
'] already installed.'
);
}
}
...
...
@@ -413,11 +364,8 @@ function createTranslation(Node $node, $title, $body, $langcode) {
// Check to make sure that translation was successful.
$translation
=
$this
->
drupalGetNodeByTitle
(
$title
);
// Maybe the source node was not in translation set,
// or it is not the base node of the translation set.
$tnid
=
(
empty
(
$node
->
tnid
)
?
$node
->
nid
:
$node
->
tnid
);
$this
->
assertTrue
(
$translation
,
t
(
'Node found in database.'
));
$this
->
assertTrue
(
$translation
->
tnid
==
$
tnid
,
'Translation set id correctly stored.'
);
$this
->
assertTrue
(
$translation
->
tnid
==
$
node
->
nid
,
t
(
'Translation set id correctly stored.'
)
);
return
$translation
;
}
...
...
core/modules/translation/translation.module
View file @
7d7aa979
...
...
@@ -413,10 +413,8 @@ function translation_remove_from_set($node) {
'tnid'
=>
0
,
'translate'
=>
0
,
));
if
(
db_query
(
'SELECT COUNT(nid) FROM {node} WHERE nid <> :nid AND tnid = :tnid'
,
array
(
':nid'
=>
$node
->
nid
,
':tnid'
=>
$node
->
tnid
))
->
fetchField
()
==
1
)
{
// Apart from the node being deleted, only one node remains in the set:
// remove the set altogether
if
(
db_query
(
'SELECT COUNT(*) FROM {node} WHERE tnid = :tnid'
,
array
(
':tnid'
=>
$node
->
tnid
))
->
fetchField
()
==
1
)
{
// There is only one node left in the set: remove the set altogether.
$query
->
condition
(
'tnid'
,
$node
->
tnid
)
->
execute
();
...
...
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