Download & Extend

Can't be installed through an install profile

Project:Video Upload
Version:6.x-1.x-dev
Component:Code
Category:bug report
Priority:critical
Assigned:Unassigned
Status:reviewed & tested by the community

Issue Summary

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();

Comments

#1

Status:active» postponed (maintainer needs more info)

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

<?php
 
include_once drupal_get_path('module', 'video_upload') . '/video_upload.module';
?>

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

#2

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()).

#3

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...

AttachmentSize
video_upload_profile_fixes.patch 2.84 KB

#4

Status:postponed (maintainer needs more info)» needs review

#5

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.

#6

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

#7

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:

<?php
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.

#8

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

Retitling.

#9

Status:needs work» needs review

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

AttachmentSize
610546.patch 2.92 KB

#10

Status:needs review» reviewed & tested by the community

This patch works for me.

nobody click here