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
300
Merge Requests
300
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
c17a5e70
Commit
c17a5e70
authored
Sep 02, 2008
by
webchick
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#285309
by pwolanin: menu_name in hook_menu is ignored on updates
parent
6511f56e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
80 additions
and
2 deletions
+80
-2
includes/menu.inc
includes/menu.inc
+5
-2
modules/simpletest/tests/hook_menu.info
modules/simpletest/tests/hook_menu.info
+8
-0
modules/simpletest/tests/hook_menu.module
modules/simpletest/tests/hook_menu.module
+20
-0
modules/simpletest/tests/menu.test
modules/simpletest/tests/menu.test
+47
-0
No files found.
includes/menu.inc
View file @
c17a5e70
...
...
@@ -1787,8 +1787,11 @@ function _menu_navigation_links_rebuild($menu) {
$existing_item
=
db_fetch_array
(
db_query
(
"SELECT mlid, menu_name, plid, customized, has_children, updated FROM
{
menu_links
}
WHERE link_path = '%s' AND module = '%s'"
,
$item
[
'link_path'
],
'system'
));
if
(
$existing_item
)
{
$item
[
'mlid'
]
=
$existing_item
[
'mlid'
];
$item
[
'menu_name'
]
=
$existing_item
[
'menu_name'
];
$item
[
'plid'
]
=
$existing_item
[
'plid'
];
// A change in hook_menu may move the link to a different menu
if
(
empty
(
$item
[
'menu_name'
])
||
(
$item
[
'menu_name'
]
==
$existing_item
[
'menu_name'
]))
{
$item
[
'menu_name'
]
=
$existing_item
[
'menu_name'
];
$item
[
'plid'
]
=
$existing_item
[
'plid'
];
}
$item
[
'has_children'
]
=
$existing_item
[
'has_children'
];
$item
[
'updated'
]
=
$existing_item
[
'updated'
];
}
...
...
modules/simpletest/tests/hook_menu.info
0 → 100644
View file @
c17a5e70
;
$
Id
$
name
=
"Hook menu tests"
description
=
"Support module for menu hook testing."
package
=
Testing
version
=
VERSION
core
=
7.
x
files
[]
=
hook_menu
.
module
hidden
=
TRUE
modules/simpletest/tests/hook_menu.module
0 → 100644
View file @
c17a5e70
<?php
// $Id$
/**
* @file
* Dummy module implementing hook menu to test changing the menu name.
*/
/**
* The name of the menu changes during the course of this test. Use a $_GET.
*/
function
hook_menu_menu
()
{
$items
[
'menu_name_test'
]
=
array
(
'title'
=>
t
(
'Test menu_name router item'
),
'page callback'
=>
'node_save'
,
'menu_name'
=>
isset
(
$_GET
[
"hook_menu_name"
])
?
$_GET
[
"hook_menu_name"
]
:
'original'
,
);
return
$items
;
}
\ No newline at end of file
modules/simpletest/tests/menu.test
0 → 100644
View file @
c17a5e70
<?php
// $Id$
/**
* @file
* Provides SimpleTests for menu.inc.
*/
class
MenuIncTestCase
extends
DrupalWebTestCase
{
/**
* Implementation of getInfo().
*/
function
getInfo
()
{
return
array
(
'name'
=>
t
(
'Hook menu tests'
),
'description'
=>
t
(
'Test menu hook functionality.'
),
'group'
=>
t
(
'Menu'
),
);
}
/**
* Implementation of setUp().
*/
function
setUp
()
{
// Enable dummy module that implements hook_menu.
parent
::
setUp
(
'hook_menu'
);
}
/**
* Tests for menu_name parameter for hook_menu().
*/
function
testMenuName
()
{
$admin_user
=
$this
->
drupalCreateUser
(
array
(
'administer site configuration'
));
$this
->
drupalLogin
(
$admin_user
);
$sql
=
"SELECT menu_name FROM
{
menu_links
}
WHERE router_path = 'menu_name_test'"
;
$name
=
db_result
(
db_query
(
$sql
));
$this
->
assertEqual
(
$name
,
'original'
,
t
(
'Menu name is "original".'
));
// Force a menu rebuild by going to the modules page.
$this
->
drupalGet
(
'admin/build/modules'
,
array
(
'query'
=>
array
(
"hook_menu_name"
=>
'changed'
)));
$sql
=
"SELECT menu_name FROM
{
menu_links
}
WHERE router_path = 'menu_name_test'"
;
$name
=
db_result
(
db_query
(
$sql
));
$this
->
assertEqual
(
$name
,
'changed'
,
t
(
'Menu name was successfully changed after rebuild.'
));
}
}
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