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
292
Merge Requests
292
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
5a4ab9f0
Commit
5a4ab9f0
authored
Mar 08, 2013
by
webchick
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue
#1933190
by larowlan: Fixed Fatal error when reordering book pages in book admin.
parent
a4a64ac0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
4 deletions
+41
-4
core/modules/book/book.admin.inc
core/modules/book/book.admin.inc
+13
-3
core/modules/book/lib/Drupal/book/Tests/BookTest.php
core/modules/book/lib/Drupal/book/Tests/BookTest.php
+28
-1
No files found.
core/modules/book/book.admin.inc
View file @
5a4ab9f0
...
...
@@ -150,6 +150,8 @@ function book_admin_edit_submit($form, &$form_state) {
$order
=
array_flip
(
array_keys
(
$form_state
[
'input'
][
'table'
]));
$form
[
'table'
]
=
array_merge
(
$order
,
$form
[
'table'
]);
// Track updates.
$updated
=
FALSE
;
foreach
(
element_children
(
$form
[
'table'
])
as
$key
)
{
if
(
$form
[
'table'
][
$key
][
'#item'
])
{
$row
=
$form
[
'table'
][
$key
];
...
...
@@ -157,9 +159,11 @@ function book_admin_edit_submit($form, &$form_state) {
// Update menu item if moved.
if
(
$row
[
'plid'
][
'#default_value'
]
!=
$values
[
'plid'
]
||
$row
[
'weight'
][
'#default_value'
]
!=
$values
[
'weight'
])
{
$row
[
'#item'
][
'plid'
]
=
$values
[
'plid'
];
$row
[
'#item'
][
'weight'
]
=
$values
[
'weight'
];
menu_link_save
(
$row
[
'#item'
]);
$menu_link
=
entity_load
(
'menu_link'
,
$values
[
'mlid'
]);
$menu_link
->
weight
=
$values
[
'weight'
];
$menu_link
->
plid
=
$values
[
'plid'
];
$menu_link
->
save
();
$updated
=
TRUE
;
}
// Update the title if changed.
...
...
@@ -176,6 +180,12 @@ function book_admin_edit_submit($form, &$form_state) {
}
}
}
if
(
$updated
)
{
// Flush static and cache.
drupal_static_reset
(
'book_menu_subtree_data'
);
$cid
=
'links:'
.
$form
[
'#node'
]
->
book
[
'menu_name'
]
.
':subtree-cid:'
.
$form
[
'#node'
]
->
book
[
'mlid'
];
cache
(
'menu'
)
->
delete
(
$cid
);
}
drupal_set_message
(
t
(
'Updated book %title.'
,
array
(
'%title'
=>
$form
[
'#node'
]
->
label
())));
}
...
...
core/modules/book/lib/Drupal/book/Tests/BookTest.php
View file @
5a4ab9f0
...
...
@@ -406,5 +406,32 @@ function testBookNodeTypeChange() {
$this
->
assertTrue
(
book_type_is_allowed
(
'bar'
),
'Config book.settings:allowed_types contains the updated node type machine name "bar".'
);
$this
->
assertFalse
(
book_type_is_allowed
(
'book'
),
'Config book.settings:allowed_types does not contain the old node type machine name "book".'
);
}
}
/**
* Tests re-ordering of books.
*/
public
function
testBookOrdering
()
{
// Create new book.
$nodes
=
$this
->
createBook
();
$book
=
$this
->
book
;
$this
->
drupalLogin
(
$this
->
admin_user
);
$node1
=
$this
->
createBookNode
(
$book
->
nid
);
$node2
=
$this
->
createBookNode
(
$book
->
nid
);
$plid
=
$node1
->
book
[
'mlid'
];
// Head to admin screen and attempt to re-order.
$this
->
drupalGet
(
'admin/content/book/'
.
$book
->
nid
);
$edit
=
array
(
"table[book-admin-
{
$node1
->
nid
}
][weight]"
=>
1
,
"table[book-admin-
{
$node2
->
nid
}
][weight]"
=>
2
,
// Put node 2 under node 1.
"table[book-admin-
{
$node2
->
nid
}
][plid]"
=>
$plid
,
);
$this
->
drupalPost
(
NULL
,
$edit
,
t
(
'Save book pages'
));
// Verify weight was updated.
$this
->
assertFieldByName
(
"table[book-admin-
{
$node1
->
nid
}
][weight]"
,
1
);
$this
->
assertFieldByName
(
"table[book-admin-
{
$node2
->
nid
}
][weight]"
,
2
);
$this
->
assertFieldByName
(
"table[book-admin-
{
$node2
->
nid
}
][plid]"
,
$plid
);
}
}
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