I ran Etsy's Phan (static analyzer) on Drupal 8 and am investigating the output. It pointed out that Form API's callback_batch_operation is using $this when not in an object context.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

tvlooy created an issue. See original summary.

tvlooy’s picture

tvlooy’s picture

ps: if this is confirmed as a bug. Then this code is probably not under tests. I must admit that I'm not sure what callback_batch_operation exactly does, but if nobody is using it (nobody reported any problems before) maybe we should just delete the code instead of fixing it.

tvlooy’s picture

Status: Active » Needs review
JeroenT’s picture

Component: forms system » documentation
tvlooy’s picture

Thanks Jeroen. So it's example code, that explains a lot :-)

Nevertheless the example is wrong. I just found out that Drupal::entityManager() is deprecated so I adjusted the patch.

borisson_’s picture

Status: Needs review » Reviewed & tested by the community

@tvlooy: *.api.php files are examples on how to use the api. Those files are not executed or tested.

The example was wrong and your patch fixes it.

jhodgdon’s picture

+1 Thanks! @borisson, thanks for the review too.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed d8b27e3 and pushed to 8.0.x and 8.1.x. Thanks!

  • alexpott committed d213335 on 8.1.x
    Issue #2637254 by tvlooy: Form API using $this when not in object...

  • alexpott committed d8b27e3 on
    Issue #2637254 by tvlooy: Form API using $this when not in object...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.