Search code examples
phpmysqldrupal-7

Call to undefined function entityreference_get_behavior_handlers() in \sites\all\modules\community\entityreference\entityreference.install on line 46


I'm new to drupal, Here I got one project to work. In that I'm getting one error that.

Fatal error: Call to undefined function entityreference_get_behavior_handlers() in \sites\all\modules\community\entityreference\entityreference.install on line 46

And I checked that file.

foreach (entityreference_get_behavior_handlers($field) as $handler) {
      $handler->schema_alter($schema, $field);
}

these are the lines and especially error is coming from the following function call.

entityreference_get_behavior_handlers($field)

I tried to debug also. Here is the results produced when I printed the variable.

print_r($field);

Array
(
    [translatable] => 0
    [entity_types] => Array
        (
        )

    [settings] => Array
        (
            [target_type] => user
            [handler] => base
            [handler_settings] => Array
                (
                    [target_bundles] => Array
                        (
                        )

                    [sort] => Array
                        (
                            [type] => none
                        )

                    [referenceable_roles] => Array
                        (
                            [5] => 5
                            [2] => 0
                            [3] => 0
                            [4] => 0
                            [6] => 0
                            [7] => 0
                            [8] => 0
                            [9] => 0
                            [10] => 0
                        )

                    [referenceable_status] => Array
                        (
                            [active] => active
                            [blocked] => 0
                        )

                    [behaviors] => Array
                        (
                            [views-select-list] => Array
                                (
                                    [status] => 0
                                )

                        )

                )

        )

    [storage] => Array
        (
            [type] => field_sql_storage
            [settings] => Array
                (
                )

            [module] => field_sql_storage
            [active] => 1
            [details] => Array
                (
                    [sql] => Array
                        (
                            [FIELD_LOAD_CURRENT] => Array
                                (
                                    [field_data_field_web_designer] => Array
                                        (
                                            [target_id] => field_web_designer_target_id
                                        )

                                )

                            [FIELD_LOAD_REVISION] => Array
                                (
                                    [field_revision_field_web_designer] => Array
                                        (
                                            [target_id] => field_web_designer_target_id
                                        )

                                )

                        )

                )

        )

    [foreign keys] => Array
        (
            [node] => Array
                (
                    [table] => node
                    [columns] => Array
                        (
                            [target_id] => nid
                        )

                )

        )

    [indexes] => Array
        (
            [target_id] => Array
                (
                    [0] => target_id
                )

        )

    [id] => 14
    [field_permissions] => Array
        (
            [type] => 0
        )

    [field_name] => field_web_designer
    [type] => entityreference
    [module] => entityreference
    [active] => 0
    [locked] => 0
    [cardinality] => -1
    [deleted] => 0
)

I believe this will be more detail to help me.

Thanks in advance,

Vivek


Solution

  • I got the solution for this.

    add the following line.

    // Invoke the behaviors to allow them to change the schema.
    module_load_include('module', 'entityreference');
    

    above

    foreach (entityreference_get_behavior_handlers($field) as $handler) {
        $handler->schema_alter($schema, $field);
    }
    

    in file \sites\all\modules\community\entityreference\entityreference.module

    Thanks & regards,

    Vivek