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
220
Merge Requests
220
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
f63bd1c6
Unverified
Commit
f63bd1c6
authored
Jun 24, 2020
by
larowlan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue
#3028621
by jungle, John Cook: BatchBuilder included files fails
(cherry picked from commit
ad50981a
)
parent
11ddd4c0
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
3 deletions
+18
-3
core/lib/Drupal/Core/Batch/BatchBuilder.php
core/lib/Drupal/Core/Batch/BatchBuilder.php
+6
-0
core/tests/Drupal/Tests/Core/Batch/BatchBuilderTest.php
core/tests/Drupal/Tests/Core/Batch/BatchBuilderTest.php
+12
-3
No files found.
core/lib/Drupal/Core/Batch/BatchBuilder.php
View file @
f63bd1c6
...
...
@@ -205,12 +205,18 @@ public function setErrorMessage($message) {
* The path should be relative to base_path(), and thus should be built using
* drupal_get_path(). Defaults to {module_name}.module.
*
* The file needs to be set before using ::addOperation(),
* ::setFinishCallback(), or any other function that uses callbacks from the
* file. This is so that PHP knows about the included functions.
*
* @param string $filename
* The path to the file.
*
* @return $this
*/
public
function
setFile
(
$filename
)
{
include_once
$filename
;
$this
->
file
=
$filename
;
return
$this
;
}
...
...
core/tests/Drupal/Tests/Core/Batch/BatchBuilderTest.php
View file @
f63bd1c6
...
...
@@ -113,11 +113,20 @@ public function testSetErrorMessage() {
* @covers ::setFile
*/
public
function
testSetFile
()
{
$filename
=
dirname
(
__DIR__
,
6
)
.
'/core/modules/system/tests/modules/batch_test/batch_test.callbacks.inc'
;
$this
->
assertIsNotCallable
(
'_batch_test_callback_1'
);
$this
->
assertIsNotCallable
(
'_batch_test_finished_1'
);
$batch
=
(
new
BatchBuilder
())
->
setFile
(
'filename.php'
)
->
setFile
(
$filename
)
->
setFinishCallback
(
'_batch_test_finished_1'
)
->
addOperation
(
'_batch_test_callback_1'
,
[])
->
toArray
();
$this
->
assertEquals
(
'filename.php'
,
$batch
[
'file'
]);
$this
->
assertEquals
(
$filename
,
$batch
[
'file'
]);
$this
->
assertEquals
([[
'_batch_test_callback_1'
,
[]]],
$batch
[
'operations'
]);
$this
->
assertEquals
(
'_batch_test_finished_1'
,
$batch
[
'finished'
]);
$this
->
assertIsCallable
(
'_batch_test_callback_1'
);
$this
->
assertIsCallable
(
'_batch_test_finished_1'
);
}
/**
...
...
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