I've been working with some config files from different sources over the last few days and keeping track of which site config(2).tar.gz config(3).tar.gz came from becomes an increasingly difficult task.

Following the example of backup and migrate I've attached what I hope a fix for this issue might look like.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mrf created an issue. See original summary.

hron84’s picture

Could you please also add $_SERVER['SERVER_PORT'] to the filename if it is not equals to 80 or 443? It would be important since some development systems can look like run different Drupal instances on different ports and not everyone can/would like to edit hosts file just to make different hostnames.

Otherwise, I support this patch.

alexpott’s picture

This change makes tonnes of sense.

+++ b/core/modules/config/config.module
@@ -65,8 +65,13 @@ function config_file_download($uri) {
+    $hostname = str_replace('.', '-', $_SERVER['HTTP_HOST']);

I think the host name should come the request using Request::getHost().

alexpott’s picture

Status: Active » Needs review

I think a test will break.

alexpott’s picture

Category: Feature request » Task
Issue tags: +Usability
Related issues: +#2247291: Reorder tabs in configuration UI

Also I this is a task not a feature request.

dawehner’s picture

Status: Needs review » Needs work

Haha, so does that mean we have no test coverage at all for this feature? Oh wait, actually we do have test coverage, we just get the raw content
and not care about the used filename, see core/modules/config/src/Tests/ConfigExportUITest.php:53

alexpott’s picture

So we need tests then.

mrf’s picture

Here is an update using getHttpHost() method and the request time to make this easier to test.

Next step is the actual tests but wanted to actually get this up since its been sitting lonely on my machine for two days.

mrf’s picture

Oh and hron84 to address your concern that method is supposed to return the port number if its nonstandard according to the docs.

StryKaizer’s picture

Test attached + patch including test

I made one change to the original patch in #8, I added quotes around the filename

   $disposition = 'attachment; filename="' . $filename . '"';

The last submitted patch, 10: test_only-better_file_name_for-2547865-10.patch, failed testing.

borisson_’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -Needs tests

The test added in #10 looks sufficient (test only fails, as expected).

yoroy’s picture

So, what's the proposed new file name, I can't tell from the patch :-)

borisson_’s picture

@yoroy, the new filename will be config-$hostname-$date.tar.gz where $hostname is the host name of the server the installation is running on and $date is the request-date formatted as Y-m-d-H-i.

An example is: config-d8-dev-2015-08-26-15-28.tar.gz (my hostname is d8.dev).

yoroy’s picture

Excellent, that makes a lot of sense. Thank you borisson_.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Beta evaluation: This is a really nice usability fix with no disruption.

Committed 3a0a28e and pushed to 8.0.x. Thanks!

  • alexpott committed 3a0a28e on 8.0.x
    Issue #2547865 by mrf, StryKaizer: Better file name for config.tar.gz...

Status: Fixed » Closed (fixed)

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