Exception: Invalid class 'VersioncontrolRepository' specified by VersioncontrolBackend backend for requested type 'repo' when attempting to build a Versioncontrol entity; class does not implement VersioncontrolEntityInterface. in VersioncontrolBackend->buildEntity() (line 149 of /var/www/drupal/sites/all/modules/versioncontrol/includes/VersioncontrolBackend.php).

versioncontrol_git 6.x-2.x-dev
versioncontrol 6.x-2.x-dev
Drupal 6.20

Comments

sdboyer’s picture

We've seen this before. A similar problem on d.o, in fact.

However, I need a HELL of a lot more information. That error is "wrong" in that VersioncontrolRepository *does* implement VersioncontrolEntityInterface. So I need to know when this error occurs, if it always occurs or if its intermittent...as much context as you can give me. If it's intermittent, it could be related to the problem we're having on d.o itself.

sdboyer’s picture

Ohhh wait. Sorry, it says 'on cron' in the title.

Well, still - please provide me some background on your vcapi install - do you have any repositories set up? How many? Are they all valid? etc. etc.

fizk’s picture

I traced the problem to buildEntity() in versioncontrol/includes/VersioncontrolBackend.php

....  
    // Ensure the class to create descends from VersioncontrolEntity.
    // FIXME temporary hack to accommodate the introduction of the VersioncontrolEntityInterface interface; have to use reflection to check interfaces on a classname string, and
    // it's too annoying to refactor all this to accommodate that right now.
    else if (!is_subclass_of($class, 'VersioncontrolEntity') && !is_subclass_of($class, 'VersioncontrolRepository')) {
      throw new Exception("Invalid class '$class' specified by " . __CLASS__ . " backend for requested type '$type' when attempting to build a Versioncontrol entity; class does not implement VersioncontrolEntityInterface.", E_ERROR);
    }

The errors stop when I made this change (i.e. change VersioncontrolRepository to VersioncontrolGitRepository, etc):

    // FIXME currently all these classes are abstract, so this won't work. Decide
    // if this should be removed, or if they should be made concrete classes
    $this->classesEntities += array(
      'repo'      => 'VersioncontrolGitRepository',
      'account'   => 'VersioncontrolGitAccount',
      'operation' => 'VersioncontrolGitOperation',
      'item'      => 'VersioncontrolGitItem',
      'branch'    => 'VersioncontrolGitBranch',
      'tag'       => 'VersioncontrolGitTag',
    );

I find it funny that in both places, theres a big FIXME comment :)
Basically, the code should be supplying buildEntity() with the Git version of all those 6 functions.

fizk’s picture

It seems the problem is in versioncontrol_git/includes/VersioncontrolGitBackend.php

I think this is the right fix:


class VersioncontrolGitBackend extends VersioncontrolBackend {

  public $classesEntities = array(
      'repo' => 'VersioncontrolGitRepository',
      'account' => 'VersioncontrolGitAccount',
      'operation' => 'VersioncontrolGitOperation',
      'item' => 'VersioncontrolGitItem',
    );
 ....
}
fizk’s picture

sdboyer’s picture

Status: Active » Closed (duplicate)

Yeah, as I said in the other issue, you need to be using 6.x-2.x, not master; all these issues you're reporting are out of date because master is defunct. I'll kill it now.

sdboyer’s picture

But, yeah. They're FIXMEs because I'm pretty stringent about the architecture being up to snuff, and those are somewhat hacky/pain points. They work though (once you get on the right branch), so they could probably be reduced to TODOs.

fizk’s picture

You're right, I was using master............... Sorry Sam :)

I don't have any errors now.

sdboyer’s picture

No worries at all. I'm SUPER excited that you're doing this level of consistent checking and bug reporting...I'm just sorry we didn't clear that up better so that all your effort thus far had to go to waste. Here's hoping you'll continue the diligence on 6.x-2.x, and keep coming up with good points and ideas :)