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
1242612e
Commit
1242612e
authored
Nov 21, 2010
by
webchick
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#606966
by chx, sun, mr.baileys: Fixed 'load arguments' of parent path are not inherited
parent
379ef5db
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
75 additions
and
3 deletions
+75
-3
includes/menu.inc
includes/menu.inc
+8
-3
modules/simpletest/tests/menu.test
modules/simpletest/tests/menu.test
+16
-0
modules/simpletest/tests/menu_test.module
modules/simpletest/tests/menu_test.module
+51
-0
No files found.
includes/menu.inc
View file @
1242612e
...
...
@@ -521,8 +521,8 @@ function menu_execute_active_handler($path = NULL, $deliver = TRUE) {
function
_menu_load_objects
(
&
$item
,
&
$map
)
{
if
(
$load_functions
=
$item
[
'load_functions'
])
{
// If someone calls this function twice, then unserialize will fail.
if
(
$load_functions_unserialized
=
unserialize
(
$load_functions
))
{
$load_functions
=
$load_functions
_unserialized
;
if
(
!
is_array
(
$load_functions
))
{
$load_functions
=
unserialize
(
$load_functions
)
;
}
$path_map
=
$map
;
foreach
(
$load_functions
as
$index
=>
$function
)
{
...
...
@@ -3396,7 +3396,7 @@ function _menu_router_build($callbacks) {
$fit
=
(
1
<<
$number_parts
)
-
1
;
}
$masks
[
$fit
]
=
1
;
$item
[
'load_functions'
]
=
empty
(
$load_functions
)
?
''
:
serialize
(
$load_functions
)
;
$item
[
'
_
load_functions'
]
=
$load_functions
;
$item
[
'to_arg_functions'
]
=
empty
(
$to_arg_functions
)
?
''
:
serialize
(
$to_arg_functions
);
$item
+=
array
(
'title'
=>
''
,
...
...
@@ -3499,6 +3499,10 @@ function _menu_router_build($callbacks) {
$item
[
'theme arguments'
]
=
$parent
[
'theme arguments'
];
}
}
// Same for load arguments, if the parent path defines any.
if
(
!
isset
(
$item
[
'load arguments'
])
&&
!
empty
(
$parent
[
'load arguments'
]))
{
$item
[
'_load_functions'
]
=
$parent
[
'_load_functions'
];
}
}
}
if
(
!
isset
(
$item
[
'access callback'
])
&&
isset
(
$item
[
'access arguments'
]))
{
...
...
@@ -3512,6 +3516,7 @@ function _menu_router_build($callbacks) {
$item
[
'access callback'
]
=
intval
(
$item
[
'access callback'
]);
}
$item
[
'load_functions'
]
=
empty
(
$item
[
'_load_functions'
])
?
''
:
serialize
(
$item
[
'_load_functions'
]);
$item
+=
array
(
'access arguments'
=>
array
(),
'access callback'
=>
''
,
...
...
modules/simpletest/tests/menu.test
View file @
1242612e
...
...
@@ -464,6 +464,22 @@ class MenuRouterTestCase extends DrupalWebTestCase {
$asserted_title
=
$override
?
'Alternative example title - Case '
.
$case_no
:
'Example title - Case '
.
$case_no
;
$this
->
assertTitle
(
$asserted_title
.
' | Drupal'
,
t
(
'Menu title is'
)
.
': '
.
$asserted_title
,
'Menu'
);
}
/**
* Tests inheritance of 'load arguments'.
*/
function
testMenuLoadArgumentsInheritance
()
{
$arg1
=
$this
->
randomName
();
$arg2
=
$this
->
randomName
();
$expected
=
print_r
(
array
(
'%menu_test_argument'
=>
$arg1
,
'%'
=>
$arg2
),
TRUE
);
$this
->
drupalGet
(
"menu-test/arguments/
$arg1
/
$arg2
"
);
$this
->
assertRaw
(
$expected
,
t
(
'Inherited load arguments found.'
));
$this
->
drupalGet
(
"menu-test/arguments/
$arg1
/
$arg2
/default"
);
$this
->
assertRaw
(
$expected
,
t
(
'Inherited load arguments found.'
));
$this
->
drupalGet
(
"menu-test/arguments/
$arg1
/
$arg2
/task"
);
$this
->
assertRaw
(
$expected
,
t
(
'Inherited load arguments found.'
));
}
}
/**
...
...
modules/simpletest/tests/menu_test.module
View file @
1242612e
...
...
@@ -255,9 +255,60 @@ function menu_test_menu() {
'page callback'
=>
'menu_test_callback'
,
);
// Load arguments inheritance test.
$items
[
'menu-test/arguments/%menu_test_argument/%'
]
=
array
(
'title'
=>
'Load arguments inheritance test'
,
'load arguments'
=>
array
(
3
),
'page callback'
=>
'menu_test_arguments'
,
'page arguments'
=>
array
(
2
),
'access callback'
=>
TRUE
,
);
$items
[
'menu-test/arguments/%menu_test_argument/%/default'
]
=
array
(
'title'
=>
'Default local task'
,
'type'
=>
MENU_DEFAULT_LOCAL_TASK
,
);
$items
[
'menu-test/arguments/%menu_test_argument/%/task'
]
=
array
(
'title'
=>
'Local task'
,
'page callback'
=>
'menu_test_arguments'
,
'page arguments'
=>
array
(
2
),
'access callback'
=>
TRUE
,
'type'
=>
MENU_LOCAL_TASK
,
);
return
$items
;
}
/**
* Menu argument loader for the 'load arguments' inheritance test.
*
* @param $arg1
* The path argument defined as %menu_test_argument.
* @param $arg2
* The additional path argument that should be passed due to 'load arguments'.
*
* @return
* An array containing $arg1 and $arg2.
*/
function
menu_test_argument_load
(
$arg1
,
$arg2
)
{
return
array
(
'%menu_test_argument'
=>
$arg1
,
'%'
=>
$arg2
);
}
/**
* Page callback for the 'load arguments' inheritance test.
*
* @param $joined_args
* An associative array containing the values for both path arguments, as
* intercepted and processed by menu_test_argument_load():
* - %menu_test_argument: The primary path argument string.
* - %: The additional argument string.
*
* @return
* A dump of the loaded %menu_test_argument argument.
*/
function
menu_test_arguments
(
$joined_args
)
{
return
print_r
(
$joined_args
,
TRUE
);
}
/**
* Dummy callback for hook_menu() to point to.
*
...
...
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