Fatal error: Call to undefined function field_info_field() in /var/aegir/platforms/drupal-7.0/sites/all/modules/media_gallery/media_gallery.install on line 125

Comments

Version:7.x-1.0-beta3» 7.x-1.x-dev
Status:Active» Needs review
StatusFileSize
new3.45 KB

The function field_info_field() can be used in hook_requirements() only during the runtime phase (http://api.drupal.org/api/drupal/developer--hooks--install.php/function/...).

I found an other issue with drush site-install:

WD php: PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds[error]
to your MySQL server version for the right syntax to use near '))
ORDER BY fit DESC
LIMIT 1 OFFSET 0' at line 1: SELECT menu_router.path AS path
FROM
{menu_router} menu_router
WHERE  (path IN  ())
ORDER BY fit DESC
LIMIT 1 OFFSET 0; Array
(
)
in _menu_find_router_path() (line 3199 of /Users/Thomas/Sites/drupal-7.0/includes/menu.inc). [30.97 sec, 49.6 MB]
PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '))
ORDER BY fit DESC
LIMIT 1 OFFSET 0' at line 1: SELECT menu_router.path AS path
FROM
{menu_router} menu_router
WHERE  (path IN  ())
ORDER BY fit DESC
LIMIT 1 OFFSET 0; Array
(
)
in _menu_find_router_path() (line 3199 of /Users/Thomas/Sites/drupal-7.0/includes/menu.inc).
Drush command terminated abnormally due to an unrecoverable error. [30.97 sec, 49.59 MB]                                                             [error]

This error occurs because the install file creates a menu link but menu module isn't in dependencies.

Status:Needs review» Needs work

I can confirm that this patch avoids the error on drush site-install explained in the original post, but later on when my install profile tries to create the tags field (I suspect) this error occurs:

WD php: PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'tags' for key 'machine_name': INSERT INTO {taxonomy_vocabulary}
(name, machine_name, description, module) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3); Array
(
    [:db_insert_placeholder_0] => Tags
    [:db_insert_placeholder_1] => tags
    [:db_insert_placeholder_2] => Use tags to group articles on similar topics into categories.
    [:db_insert_placeholder_3] => taxonomy
)
in drupal_write_record() (line 6776 of /home/testuser/Public/Sites/testsite/includes/common.inc).
WD php: Warning: Cannot modify header information - headers already sent by (output started at /home/testuser/Public/Sites/Scripts/drush/includes/drush.inc:868) in drupal_send_headers() (line 1040 of /home/testuser/Public/Sites/testsite/includes/bootstrap.inc).
PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'tags' for key 'machine_name': INSERT INTO {taxonomy_vocabulary} (name, machine_name, description, module) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3); Array
(
    [:db_insert_placeholder_0] => Tags
    [:db_insert_placeholder_1] => tags
    [:db_insert_placeholder_2] => Use tags to group articles on similar topics into categories.
    [:db_insert_placeholder_3] => taxonomy
)
in drupal_write_record() (line 6776 of /home/testuser/Public/Sites/testsite/includes/common.inc).
Drush command terminated abnormally due to an unrecoverable error.

Status:Needs work» Postponed (maintainer needs more info)

I am unable to reproduce any of these errors myself. Can someone post (or link to) an example of an install profile which causes these errors to occur?

The patch itself looks a bit suspicious to me because if anything I would think we wanted the opposite (having it not run on $phase 'runtime')? It needs to run during $phase 'install' to prevent the module from being installed at all in the case where there are fields that conflict with the ones it needs.

Also, regarding this:

This error occurs because the install file creates a menu link but menu module isn't in dependencies.

Which part of the install file do you think requires the Menu module? The only menu-related part I see is that it calls menu_link_save(); however, that function is part of the menu system (i.e., lives in includes/menu.inc), not the Menu module, and the menu system does not require that the Menu module be installed in order to work correctly.

Thanks for looking into this!

StatusFileSize
new1.6 MB

I was able to test that this fails with the following install profile. I was able to install using the patch, but I also feel that this is not correct because now it will not block installs that have field conflicts.

Once you get past the requirements it fails with the menu error if the dependency is not included. When the dependency is included the install works properly.

I don't really know what all this means, but I hope this install profile can help people cause I need to have this module install in my install profile.

Thanks.

About the message @V1 is getting in #2, I too got it in another situation, and it turned out it was because I was calling standard_install() from myprofile_install(), this was my scenario:

  • One of the features (namely debut_event) created the 'tags' vocabulary
  • standard_install() called from myprofile_install() tried to create the 'tags' vocabulary again and it failed with that message.

A possible workaround is to call minimal_install() intead in the profile, or maybe standard_install() could be fixed to check for the existence of the vocabulary before creating it.

I thought that myprofile_install() was called earlier in the installation process, while it looks like it is called after the profile dependancy have been installed already.

Regards,
Antonio

Title:Install fails using drush site-install Drupal can't be installed when Media Gallery is enabled via an install profile
Status:Postponed (maintainer needs more info)» Needs review
StatusFileSize
new1.3 KB

Thanks for the example code and the analysis!

The attached patch should fix the "undefined function field_info_field" error (from the original post), as well as the "Syntax error or access violation" error from comment #1. The latter is sort of related to a core bug; see #1187906: Shortcut module cannot be installed via an install profile if the menu module wasn't installed first.

With this patch, I still get the error in #2 when using the above install profile, but that's a bug with the profile itself (it shouldn't try to create a vocabulary that it knows already exists). Once I removed that code from the profile, I was able to install Drupal using that profile either with Drush or via the UI.

I think this patch also might fix #1207274: No item created in menu.

I'll probably commit this soon since we want to get a new beta release out and I'm pretty confident it's right, but if anyone else wants to test and report back here, please do :)

Status:Fixed» Closed (fixed)

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