PHP Fatal error: Call to undefined function video_upload_initialize_provider() in sites/all/modules/contrib/video_upload/video_upload.install on line 71

although it is defined in the following places, it is not recognized during install

grep -in "video_upload_init" *
video_upload.install:71: video_upload_initialize_provider();

video_upload.module:40:function video_upload_initialize_provider() {
video_upload.module:681: video_upload_initialize_provider();
video_upload.module:697: video_upload_initialize_provider();
video_upload.module:708: video_upload_initialize_provider();
video_upload.module~:40:function video_upload_initialize_provider() {
video_upload.module~:591: video_upload_initialize_provider();
video_upload.module~:607: video_upload_initialize_provider();
video_upload.module~:618: video_upload_initialize_provider();
video_upload.theme.inc:24: video_upload_initialize_provider();
video_upload.theme.inc:124: video_upload_initialize_provider();
video_upload_widget.inc:27: video_upload_initialize_provider();

CommentFileSizeAuthor
#9 610546.patch2.92 KBbojanz
#3 video_upload_profile_fixes.patch2.84 KBaxolx

Comments

jhedstrom’s picture

Status: Active » Postponed (maintainer needs more info)

In the install hook, immediately prior to calling that function is this line:

  include_once drupal_get_path('module', 'video_upload') . '/video_upload.module';

so I'm not sure how this error is occuring.

manarth’s picture

The problem occurs if the module is installed as part of an install profile.

This is because the system table doesn't yet exist, so drupal can't lookup module directories (e.g. drupal_load() or drupal_get_path()).

axolx’s picture

StatusFileSize
new2.84 KB

I've ran into the same issue. As manarth pointed out, modules can't use drupal_get_path() in functions that are called during profile installation. That includes, but is not limited, to hook_requirements.

The attached patch is a first shot at making the module compatible for use in install profiles. Most places where it drops drupal_get_path are safe except for:

-include_once(drupal_get_path('module', 'content') .'/content.module');
+include_once realpath(dirname(__FILE__)) . '/../cck/content.module';

which assumes that both video_upload and cck and are in the same modules directory. This should be true in most cases, but still not ideal...

axolx’s picture

Status: Postponed (maintainer needs more info) » Needs review
jhedstrom’s picture

Status: Needs review » Needs work

Unfortunately, there's no way to assume that CCK is always in the same directory. Multisite installs commonly have modules in different directories. Acquia Drupal will also have CCK in a different directory.

axolx’s picture

jquery_ui is dealing with a similar issue: http://drupal.org/node/325831

jhedstrom’s picture

As far as I can tell, the __FILE__ approach should work fine. My comment in #5 is only relevant if this line stays as is:

include_once(drupal_get_path('module', 'content') .'/content.module');

I think it can safely be removed entirely, as the purpose is for checking during updates, and video_upload_install() already does this. If you reroll the patch in #3 to remove this, I'll try to get this in soon.

bojanz’s picture

Title: PHP Fatal error: Call to undefined function video_upload_initialize_provider( » Can't be installed through an install profile

Retitling.

bojanz’s picture

Status: Needs work » Needs review
StatusFileSize
new2.92 KB

Here's an updated patch, as jhedstrom requested. Please test.

jhedstrom’s picture

Status: Needs review » Reviewed & tested by the community

This patch works for me.