In the drush commands, the generated XML will output file urls with the file fields stream wrapper scheme instead of the full url. In other words it will generate public://path/to/file.xml instead of http://example.c om/sites/default/files/path/to/file.xml.

Comments

jojonaloha’s picture

Attached patch should resolve this issue.

Note: Since this is run from drush, either $base_url should be set or it should be provided with the --uri option.

jojonaloha’s picture

Status: Active » Needs review
hass’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new1.56 KB

The patch required a re-role, but this is RTBC.

URI param is important as noted or all urls are http://default...

drush release-create-history --uri=http://updates.mysite.org

I wonder how d.o can run without this patch.

drumm’s picture

Drupal.org alters it with a project_release_download_base_* variable, see project_release_project_behavior_settings(). We'll have to make sure this handles those URLs properly.

hass’s picture

It works with custom http:// and https://, but not for ftp:// urls.

The root cause is file_create_url(). FTP urls require that the site has FTP stream wrapper registered.

Should we do this inside the project module or in an external module? Maybe d.o can just install storage api and we are done.

It's not the patch here that is wrong.

hass’s picture

This snippet allows using FTP links. But I fear that is not clean enough for sites that may use storage API and also define ftp stream wrapper. However it proves that this file_create_url() works with the patch and ftp:// links.

/**
 * Implements hook_stream_wrappers().
 */
function project_release_stream_wrappers() {
  return array(
    'ftp' => array(
      'name' => t('FTP distribution files'),
      'class' => 'ProjectFtpStreamWrapper',
      'description' => t('Provides read-only paths to ftp distribution files.'),
      'type' => STREAM_WRAPPERS_READ,
    ),
  );
}

/**
 * Default FTP files (ftp://) stream wrapper class.
 */
class ProjectFtpStreamWrapper extends DrupalPublicStreamWrapper {
  function getExternalUrl() {
    return $this->uri;
  }
}

We should add a form validation to the node type form to check if the entered scheme is supported by Drupal.

hass’s picture

This patch validates the entered base URL to have a valid stream wrapper registered. So nothing can go wrong any longer if systems are not properly configured or missing the core requirements.

hass’s picture

StatusFileSize
new3.46 KB

Now fully tested with ftp/http/https and without URL.

drumm’s picture

Status: Reviewed & tested by the community » Fixed

Tested well, committed.

  • drumm committed 5178648 on 7.x-2.x authored by jojonaloha
    Issue #2473603 by hass, jojonaloha: Project Release history XML should...

Status: Fixed » Closed (fixed)

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