I get the following error on an update from 9-25 dev of 2.x to 9-29 dev:

Fatal error: Class 'MediaBrowserPlugin' not found in /home/content/09/7651809/html/sites/all/modules/media/modules/media_internet/media_internet.module on line 34

Shifted back to 9-25 dev and the error went away.

Guessing it relates to this commit: #1289872: Use ctools plugins to provide add-ons to the media browser

CommentFileSizeAuthor
#5 1295448_4__missing_plugin_path.patch487 bytesszantog

Comments

paulgemini’s picture

Here's the code starting on line 34:

class MediaBrowserInternet extends MediaBrowserPlugin {

  function view() {
    // @todo: implement the multiselect argument here.
    $from_web_form = drupal_get_form('media_internet_add',  $this->params['types'], $this->params['multiselect']);
    return array(
      'form' => array($from_web_form),
      '#attached' => array(
        //'js' => array($path . '/js/plugins/media.fromurl.js'),
      ),
    );
  }

}
paulgemini’s picture

And here's the commit where the code changed:

diff --git a/modules/media_internet/media_internet.module b/modules/media_internet/media_internet.module
index decfffb..812296c 100644
--- a/modules/media_internet/media_internet.module
+++ b/modules/media_internet/media_internet.module
@@ -1,22 +1,49 @@
 <?php
 
 /**
+ * Implements hook_ctools_plugin_api().
+ */
+function media_internet_ctools_plugin_api($module, $api) {
+  if ($module == 'media' && $api == 'browser') {
+    return array(
+      'version' => 1,
+    );
+  }
+}
+
+/**
  * Implements hook_media_browser_plugin_info().
  */
 function media_internet_media_browser_plugin_info() {
   $plugins = array();
-  /*
-   @todo: Coming soon.
-   'search' => array(
-   ),
-  */
-  if (user_access('administer media') || user_access('add media from remote sources')) {
-    $plugins['media_internet'] = array(
-      '#title' => t('Web'),
-      '#weight' => -10,
+  $plugins['media_internet'] = array(
+    'title' => t('Web'),
+    'handler' => 'MediaBrowserInternet',
+    'access callback' => 'media_internet_access',
+  );
+  return $plugins;
+}
+
+/**
+ * Access callback for the media_internet media browser plugin.
+ */
+function media_internet_access() {
+  return user_access('administer media') || user_access('add media from remote sources');
+}
+
+class MediaBrowserInternet extends MediaBrowserPlugin {
+
+  function view() {
+    // @todo: implement the multiselect argument here.
+    $from_web_form = drupal_get_form('media_internet_add',  $this->params['types'], $this->params['multiselect']);
+    return array(
+      'form' => array($from_web_form),
+      '#attached' => array(
+        //'js' => array($path . '/js/plugins/media.fromurl.js'),
+      ),
     );
   }
-  return $plugins;
+
 }
CarbonPig’s picture

Subscribe - same issue

jonathanmd’s picture

Subscribing. Same issue as well.

szantog’s picture

Title: Fatal error on update to 9-29 dev - MediaBrowser » Missing path in media internet breaks the module
Priority: Major » Critical
Status: Active » Needs review
StatusFileSize
new487 bytes

Agree, missing path in media_internet_ctools_plugin_api. But I think, this is critical, because of media_internet module is completly unusable without this patch.

The original error message:

PHP Fatal error:  Class 'MediaBrowserPlugin' not found in /home/szantogabor/public_html/panparks/sites/all/modules/patched/media/modules/media_internet/media_internet.module on line 35
szantog’s picture

Hmm.. This is interesting.. I've reimport a database of my work, then I get this error message too. Applied the patch doesn't solved the problem soon.. When I commented the complete class MediaBrowserInternet extends MediaBrowserPlugin {} declaration, I could clear all caches. Then I removed the comment, and everythings worked well.

After this with and without this patch, I can't reproduced any error.

So I'm not sure, need this patch really..

aaron’s picture

i think it might be related to #1294498: 7.x-2.x UPGRADE PROCEDURE (Sept. 29, 2011) actually.

paulgemini’s picture

Yeah - looks like it. I'm going to keep this open though because at some point there will need to be a clean (normal) upgrade path between versions, right?

bforchhammer’s picture

dave reid’s picture

Priority: Critical » Major

I'm not able to duplicate this either with an upgrade or a fresh install.

dave reid’s picture

Status: Needs review » Needs work
afsolano’s picture

shiva7663’s picture

subscribing -- same issue

dave reid’s picture

Please try using http://drupal.org/project/registry_rebuild to rebuild your file registry. This may solve this issue.

dave reid’s picture

Title: Missing path in media internet breaks the module » PHP fatal error: Class 'MediaBrowserPlugin' not found
Status: Needs work » Postponed (maintainer needs more info)

After more discussion in IRC today, I thought this might be a problem because we have the class in the .module file and update.php is trying to do a full bootstrap before it can rebuild the registry. So I committed http://drupalcode.org/project/media.git/commit/5261856 which moved the class to includes/MediaBrowserInternet.inc to hopefully fix this issue. Please test the latest code once the 7.x-2.x-dev release rebuilds in about 12 hours and check if you can run update.php successfully.

dave reid’s picture

Status: Postponed (maintainer needs more info) » Fixed

effulgentsia confirmed that the latest commit resolves the issue. We'll roll an unstable3 release in the near future.

girishmuraly’s picture

Funny, we spent a lot of time trying to solve this problem yesterday at my workplace. We ended up inserting this line into the 'registry' table, before running update.php and it worked, as luckily media.browser.inc was an already existing file. If only we could have just waited for the patch in #15!

INSERT INTO registry(name, type, filename, module, weight) VALUES('MediaBrowserPlugin','class','profiles/dennis_distro/modules/contrib/media/includes/media.browser.inc','media',0);
mesr01’s picture

Just for the records, I got this problem while trying to upgrade from 2.0-unstable1 to unstable2. So I cleared the cache, applied the patch from @szantog in #5 and have my registry rebuilt as recommended by @Dave Reid in #14 and I got back my site up and running.

Thanks guys!

aandreux’s picture

Status: Fixed » Needs review
dave reid’s picture

Status: Needs review » Fixed
BeaPower’s picture

Follwed #18, but it didnt work. I get:

DRUPAL_ROOT is C:\xampp\htdocs\b20e1.
Bootstrapping to DRUPAL_BOOTSTRAP_SESSION
Doing registry_rebuild() in DRUPAL_BOOTSTRAP_SESSION
Bootstrapping to DRUPAL_BOOTSTRAP_FULL

Fatal error: Class 'MediaBrowserPlugin' not found in C:\xampp\htdocs\b20e1\sites\all\modules\media\modules\media_internet\media_internet.module on line 39

Status: Fixed » Closed (fixed)

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

joshmiller’s picture

Category: bug » task
Priority: Major » Normal
Status: Closed (fixed) » Needs review

I just upgraded from media-1.x to media-2.x and got this fatal error.

#17 was the most straightforward fix for me. I modified it to this:

INSERT INTO registry(name, type, filename, module, weight) VALUES('MediaBrowserPlugin','class','sites/all/modules/media/includes/media.browser.inc','media',0);

TODO: There should be a note on the module homepage that a 1.x => 2.x upgrade needs at least this patch to work.

Josh

dave reid’s picture

Status: Needs review » Closed (fixed)

We just need to roll an unstable3. We don't re-open fixed issues though.