In order into #2987842: Improve clickpath for Downloading Drupal, we must create a menu callback that always downloads the latest tarball or zip. This allows us to reduce "Download Drupal 8.5.5" and "Download tar.gz" into a single "Download tar.gz" click.

It also allows us to simplify the steps to use the Drupal quick start commands from:

$ curl -sS https://ftp.drupal.org/files/projects/drupal-x.y.z.zip --output drupal-x.y.z.zip
$ unzip drupal-x.y.z.zip
$ cd /path/to/drupal-x.y.z
$ php core/scripts/drupal quick-start

Which requires a user to look up the latest version of Drupal and replace strings like "drupal-x.y.z.zip", to:

$ curl -L https://www.drupal.org/download-latest/tarball > drupal.tar.gz
$ mkdir drupal && tar -zxvf drupal.tar.gz -C drupal --strip-components=1
$ cd drupal
$ php core/scripts/drupal quick-start
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

grasmash created an issue. See original summary.

grasmash’s picture

Status: Active » Needs review
Issue tags: +Documentation Initiative
FileSize
2.8 KB
mlhess’s picture

I think, but am not positive that

$release_package = new DrupalorgProjectPackageRelease($release_node, $temp_path);

will create a release, as in create a tarball. Was this tested on a dev site?

mlhess’s picture

Status: Needs review » Needs work
grasmash’s picture

Status: Needs work » Needs review

I thought you'd need to actually call $release_package->createPackage() to create a release? Instantiating the object only sets the object properties in the constructor.

Yes, I tried it on a dev site and it worked. Visit http://docinitiative-drupal.dev.devdrupal.org/download-latest/tarball

grasmash’s picture

FileSize
2.49 KB

Updating patch as per @mlhess suggestions.

mlhess’s picture

This look better.

A few things

1) all anon urls are cached by fastly. So when a new version of core is released, we would want to call
drupalorg_fastly_purge_url() for these paths otherwise users might download an old version.

I am not sure where we would want to put that, we could put it in the packager, but it won't work correctly for security releases as they are not published at the time they are built, so it would clear the cache, but then load the old url. My guess is it should go in a hook_node_update and look for the release node being published. The packager will do this, and the security team does it by hand.

Lets give it a few days and see if anyone else wants to weight in?

drumm’s picture

Status: Needs review » Needs work
  • ftp.drupal.org should not be hard-coded. Use project_release_add_download_base() instead.
  • Consider using entity_metadata_wrapper() to make traversing the field collection items more-readable code.
  • I’m not sure that we can guarantee delta = 0 is always tgz and delta = 1 is zip.
  • The tarballs have a tar.gz extension. Should we use that instead of tarball?
  • The call to drupalorg_fastly_purge_url() can go near the existing call to it in drupalorg_node_update().
grasmash’s picture

Status: Needs work » Needs review
FileSize
3.46 KB

ftp.drupal.org should not be hard-coded. Use project_release_add_download_base() instead.

Done.

I’m not sure that we can guarantee delta = 0 is always tgz and delta = 1 is zip.

I've added a check.

The tarballs have a tar.gz extension. Should we use that instead of tarball?

Changed /download-latest/tarball to /download/targz.

The call to drupalorg_fastly_purge_url() can go near the existing call to it in drupalorg_node_update().

Done.

grasmash’s picture

FileSize
3.52 KB

Fixing bug regarding strpos().

hansfn’s picture

I prefer https://www.drupal.org/download/latest/targz (and https://www.drupal.org/download/latest/zip) since then people get a working URL if they strip of "latest/whatever". We might also handle https://www.drupal.org/download/latest/ by redirecting to https://www.drupal.org/project/drupal

In addition, I suggest making "download-latest/" (or "download/latest/" if I get my will) a variable so we are 100% sure that the callback and Fastly purge use the same URLs.

grasmash’s picture

This issue has been in "needs review" status for 12 days. How can this be moved forward? Are the comments in #11 requirements?

grasmash’s picture

FileSize
3.76 KB

@hansfn We can't use "download/" because of pre-existing menu item for path "download/*".

However, I've refactored the paths and added a new one:

  • latest/download/zip
  • latest/download/targz
  • latest/release

The last provides a means for linking to the latest release node. A callback already existed that serves this purpose.

hestenet’s picture

Assigned: Unassigned » drumm
Related issues: +#2961550: Project download URL for latest stable release

Providing my review and plus one for this idea.

Assigning to @drumm for final technical review and getting this ready for deployment

Some quick notes:

  • Should this be a pattern that exists for every project? If so the path will wind up being something like: /project/drupal/zip, /project/drupal/targz, /project/drupal/release (not sure we need the word latest in there, but we can add it if we want)
  • If we do make this a pattern for all projects - let's still implement some redirects for core specifically so that we can use shorter urls to find this
grasmash’s picture

In your example, /project/drupal/release would redirect to /project/drupal/releases/8.5.6. It's useful for being able to link to the latest release notes.

drumm’s picture

We currently have 8/download as a one-off redirect to the currently-recommended core release page.

  • drumm committed 416b00b on 7.x-3.x, dev authored by grasmash
    Issue #2988211 by grasmash, mlhess, drumm: Create a path that will...
drumm’s picture

I reverted to the original paths, but with the same extensions as used on the files themselves, download-latest/zip & download-latest/tar.gz, so the code to get the files could be simplified a bit.

I also left the redirect to the release page with only the original 8/download. If we want to change that, we can change it directly in drupalorg_menu() and add a redirect or alias via the UI.

Other notable changes were:

  • Using return MENU_NOT_FOUND; instead of drupal_not_found(), which doubles up the page content.
  • Moved page callback code to drupalorg/drupalorg.pages.inc
  • Only purge Fastly for core release updates.

In addition, I suggest making "download-latest/" (or "download/latest/" if I get my will) a variable so we are 100% sure that the callback and Fastly purge use the same URLs.

This is site-specific custom code, it should be clean, but hard-coding things happens. grepping the codebase for a string is only marginally worse than grepping for a variable.

drumm’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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