I've tried converting video with zencoder and latest video module and also latest dev of video. The video files are correctly posted back and save in my file system but the notification from zencoder receives the message and fails:

Exception: PO files URL should not be public. in TranslationsStreamWrapper->getExternalUrl() (line 25 of <path_to_httpdocs>/sites/all/modules/l10n_update/includes/locale/TranslationsStreamWrapper.php).

After updating l10n_update to latest version the problem persists. Disabling l10n_update "fixed" the problem.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

vasi1186’s picture

The issue comes from the video_utility:getStreamBaseMapping(), which 'Maintains a mapping from scheme to external URL prefix'. In that function a call to getExternalUrl() is made for every stream wrapper.

If the l10n_update module is installed, then the wrapper it defines, TranslationsStreamWrapper, just throws an exception the getExternalUrl() method is called for it. So, a quick fix (which still needs to be checked if does not introduce any other side effects) is to return the empty string instead of the exception, so basically the method would be just like this:

function getExternalUrl() {
  return '';
}

But, this is actually a 'hacky' fix, if there is a reason why the getExternalUrl() should really throw an exception. In my opinion, the correct fix would be that the TranslationsStreamWrapper::getExternalUrl() should throw an meaningful exception, not just

throw new Exception('PO files URL should not be public.');

because this is almost useless for the code which should catch it. In the same time, it should be an exception which is also documented in the drupal core itself, so it should not be one defined by the l10n_update module, because the TranslationsStreamWrapper class implements the DrupalStreamWrapperInterface interface by extending the DrupalLocalStreamWrapper class.

So, supposing that throwing an exception in getExternalUrl() would make sense, then this exception should be defined and documented by the Drupal core in the first place (in DrupalStreamWrapperInterface), then it would be thrown by the TranslationsStreamWrapper::getExternalUrl() method, and should be catched by any client code that makes calls to this method.
I guess that there is a big chance that this fix does not get implemented, so one quick fix for the moment is to not return an exception in TranslationsStreamWrapper::getExternalUrl(), or catch the Exception in video_utility:getStreamBaseMapping().

heshanlk’s picture

Status: Active » Closed (cannot reproduce)
garphy’s picture

Status: Closed (cannot reproduce) » Needs review
FileSize
1.24 KB

I've got the exact same problem here.
Indeed, the behavior of l10n_update's TranslationsStreamWrapper is a bit harsh. Nothing is documented nor declared wrt throwing exceptions here.
I think this only way around is to catch Exception when calling getExternalUrl() and ignore any failure.
Attached patch for anyone still having a maintenance burden with Drupal 7 & Video.

garphy’s picture

Well... for some reason I mixed up Error & Exception.
Here's a functional patch.

garphy’s picture

...patch which I obviously forgot to upload.