diff --git a/core/modules/views/src/Controller/ViewAjaxController.php b/core/modules/views/src/Controller/ViewAjaxController.php index 5e4c4ca..0e5109b 100644 --- a/core/modules/views/src/Controller/ViewAjaxController.php +++ b/core/modules/views/src/Controller/ViewAjaxController.php @@ -81,8 +81,8 @@ public function ajaxView(Request $request) { $args = isset($args) && $args !== '' ? explode('/', $args) : array(); // Replace empty argument strings with NULL. - array_map(function ($arg) { - $arg === '' ? NULL : $arg; + $args = array_map(function ($arg) { + return ($arg == '' ? NULL : $arg); }, $args); $path = $request->request->get('view_path'); diff --git a/core/modules/views/tests/src/Unit/Controller/ViewAjaxControllerTest.php b/core/modules/views/tests/src/Unit/Controller/ViewAjaxControllerTest.php index 8d0a313..996ac1a 100644 --- a/core/modules/views/tests/src/Unit/Controller/ViewAjaxControllerTest.php +++ b/core/modules/views/tests/src/Unit/Controller/ViewAjaxControllerTest.php @@ -167,6 +167,27 @@ public function testAjaxViewWithArguments() { } /** + * Tests a valid view with arguments. + */ + public function testAjaxViewWithEmptyArguments() { + $request = new Request(); + $request->request->set('view_name', 'test_view'); + $request->request->set('view_display_id', 'page_1'); + // Simulate a request that has a second, empty argument. + $request->request->set('view_args', 'arg1/'); + + list($view, $executable) = $this->setupValidMocks(); + $executable->expects($this->once()) + ->method('preview') + ->with('page_1', $this->identicalTo(array('arg1', NULL))); + + $response = $this->viewAjaxController->ajaxView($request); + $this->assertTrue($response instanceof ViewAjaxResponse); + + $this->assertViewResultCommand($response); + } + + /** * Tests a valid view with a pager. */ public function testAjaxViewWithPager() {