Currently i am not able to wrap my batch operations in a class(which is very often the use case) because of this in batch.inc:
if (function_exists($batch_set['finished'])) {
If we change this to
if (is_callable($batch_set['finished'])) {
We can do this:
$batch['finished'] = array($this, 'method')
This already works with the actual batch operation callback, just not with the finished callback.
Now, i will submit patches for both 7.x and 8.x and foresee already war emerging on this, but i really hope it will be accepted, otherwise i'll have to resort to some really dirty solutions(move the function out from the class or something) and the client wont exactly buy me a champaign.
Comments
Comment #1
bfr commentedHere's the first one.
edit: The upload form is broken, will try again later.
Comment #2
bfr commentedNew try. Uploading seems to work with Firefox but not Chrome? Or is my Chrome broken?
Comment #3
bfr commentedComment #4
bfr commentedBackport here.
Comment #5
twistor commentedThis problem also exists with the new FormInterface.
I'm currently seeing this in _batch_next_set() while trying to spawn a batch process from EntityNGConfirmFormBase::submit().
Comment #6
xano#5: drupal-replace_function_exists_with_is_callable-1924429-5.patch queued for re-testing.
Comment #7
chx commentedComment #8
xanoCould we name it
$callbackfor the sake of clarity? callable sounds like a type hint.Is this an accidental left-over from another patch?
Comment #9
chx commentedComment #11
xanoThis only works in PHP 5.4 and higher: http://3v4l.org/ERMcQ, so we can't commit this until our testing infra supports 5.4 all the way. The rest of the patch looks good. RTBC if the bot agrees.
Comment #12
chx commentedGood then that Drupal 8 requires PHP 5.4 (even if this is not yet committed).
Comment #13
xanoRTBC, on condition that the tests pass.
Comment #14
chx commentedBlocks migrate, bumping up.
Comment #15
catchI'm confused by #11 - is that passing because we're not testing this?
Comment #16
chx commentedWell, sorta, it's completely legal as long as you don't actually use an array as your callable which core currently doesn't for any of these callbacks. Redirect callbacks are used extremely rarely, for example 0 times in core.
Comment #17
catchOK I think we can live with that level of obscure incompatibility until the bots are actually upgraded.
Committed/pushed to 8.x, thanks!
Comment #18
twistor commented