TypeError: call_user_func(): Argument #1 ($callback) must be a valid callback

Created on 10 March 2022, over 2 years ago
Updated 26 March 2024, 8 months ago

Problem/Motivation

Using Drupal 9.3.7, context 8.x-4.x-dev and PHP 8.1, when I try to place a block with custom machine name (custom_id field), I get this error and the block is never placed.

TypeError: call_user_func(): Argument #1 ($callback) must be a valid callback, no array or string given in call_user_func() (line 275 of /var/www/drupal/web/core/lib/Drupal/Core/Render/Element/MachineName.php)

Steps to reproduce

1) Create a context
2) Add blocks reaction
3) Try to place a block with custom machine name

πŸ› Bug report
Status

RTBC

Version

5.0

Component

Code

Created by

πŸ‡¬πŸ‡·Greece balis_m

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡ΈUnited States Kristen Pol Santa Cruz, CA, USA

    Thanks for the fix, steps to reproduce, and reviews/testing.

    Switching to new 5.x branch. This can be targeted for the next release.

  • πŸ‡¬πŸ‡§United Kingdom rossb89 Bristol

    MR-23 still applies against 5.x and solves the issue :)

  • πŸ‡¬πŸ‡§United Kingdom rossb89 Bristol

    Actually, further inspection reveals that I don't think the solution in MR-23 is quite right.

    There is no reason that I know of that the block ID has to be unique *across* contexts.

    At the moment the patch is loading up every context and making sure the block ID is unique across all of them... which is causing problems for me, as I need to re-use the same block instance across multiple contexts.

    With the 'unique' option on the context block anyway, I don't think that we need to be so heavy handed in checking the ID is unique across *all* contexts...

Production build 0.71.5 2024