masugadesign / link-vault-craft-cms

The Link Vault download link protection plugin for Craft CMS v3.
Other
5 stars 2 forks source link

Download links not working in multi-site setup #3

Closed thisisjamessmith closed 6 years ago

thisisjamessmith commented 6 years ago

Describe the bug

I'm testing this plugin in a multi-site setup, where the protected links are on site-2. Clicking a link-vault download link results in an error in Craft's log (storage/logs/web.log) stating Attempting to save an element in an unsupported site, generated by line 264 of GeneralService.php ($saveStatus = Craft::$app->elements->saveElement($element);)

To Reproduce

Steps to reproduce the behavior:

  1. Setup two sites in Craft
  2. Create Link-Vault protected links on the site that's not the primary site
  3. Click that link

Potential fix

Adding the following code at the end of the elements/LinkVaultDownload.php class appears to fix the problem, but I'm not 100% sure what the knock-on effects of this might be:

public static function isLocalized(): bool
{
    return true;
}
benjaminkohl commented 6 years ago

I just released Link Vault 3.0.5.2 which contains this fix.