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
912dcde7
Commit
912dcde7
authored
Dec 02, 2009
by
Dries
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- Patch
#398110
by matt2000: bugfix: node_submit() resets ->uid.
parent
2845fa95
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
4 deletions
+10
-4
modules/node/node.module
modules/node/node.module
+5
-3
modules/node/node.test
modules/node/node.test
+5
-1
No files found.
modules/node/node.module
View file @
912dcde7
...
...
@@ -924,13 +924,15 @@ function node_validate($node, $form = array()) {
}
/**
* Prepare node for sav
e and allow modules to make changes
.
* Prepare node for sav
ing by populating author and creation date
.
*/
function
node_submit
(
$node
)
{
global
$user
;
if
(
user_access
(
'administer nodes'
))
{
// Populate the "authored by" field.
// A user with 'administer nodes' permission might assign the node author by
// entering a user name in the node form, which we then need to translate to a
// user ID, unless we've already been provided a user ID by other means.
if
(
user_access
(
'administer nodes'
)
&&
!
isset
(
$node
->
uid
))
{
if
(
$account
=
user_load_by_name
(
$node
->
name
))
{
$node
->
uid
=
$account
->
uid
;
}
...
...
modules/node/node.test
View file @
912dcde7
...
...
@@ -840,7 +840,11 @@ class NodeSaveTestCase extends DrupalWebTestCase {
'nid'
=>
$test_nid
,
'is_new'
=>
TRUE
,
);
$node
=
(
object
)
$node
;
$node
=
node_submit
((
object
)
$node
);
// Verify that node_submit did not overwrite the user ID.
$this
->
assertEqual
(
$node
->
uid
,
$this
->
web_user
->
uid
,
t
(
'Function node_submit() preserves user ID'
));
node_save
(
$node
);
// Test the import.
$node_by_nid
=
node_load
(
$test_nid
);
...
...
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