When a providing site is in a subdirectory, Entity Share fails to copy physical files over to the requesting site. The associated file entities are created, but the files themselves are missing.

To reproduce:

- Have two Drupal sites (multisite) installed in subdirectories.
- Create a standard article on one site and sync it to the other.
- The image field physical file is not copied to the destination site.

This appears to be caused by the authentication request in \Drupal\entity_share_client\Service\RemoteManager::prepareClient():

    $http_client->post('/user/login', [
      'form_params' => [
        'name' => $remote->get('basic_auth_username'),
        'pass' => $remote->get('basic_auth_password'),
        'form_id' => 'user_login_form',
      ],
    ]);

If the providing exists at http://example.com/my-subdirectory, the leading slash in /user/login causes the login request to post to http://example.com/user/login, eliminating the subdirectory name. Apparently this is the way Guzzle intentionally handle absolute directory paths combined with base_uri's with subdirectories, as described at https://stackoverflow.com/questions/25268872/guzzlehttp-client-ignores-b....

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

quicksketch created an issue. See original summary.

quicksketch’s picture

Status: Active » Needs review
FileSize
627 bytes

Here's a patch that fixes this login issue, which seems to be trivial.

Grimreaper’s picture

Assigned: Unassigned » Grimreaper

Thanks @quicksketch for catching that and for the patch.

I am currently trying to reproduce manually, Doing #3094091: Use dedicated block content type for tests before.

And I am also searching why I did not catch that with #3072238: Tests: file field (entity reference) (tests are failing on this issue only for deprecations), because on d.o tests are in subdirectory so the case should be tested.

  • quicksketch authored 814594c on 8.x-2.x
    Issue #3091899 by quicksketch, Grimreaper: Files are not synced when...
Grimreaper’s picture

Assigned: Grimreaper » Unassigned
Status: Needs review » Fixed

Patch merged!

But I am worried that the tests from #3072238: Tests: file field (entity reference) did not catch such a bug.

Status: Fixed » Closed (fixed)

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