Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Services/ProjectComposerJsonUpdater.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ public function update(string $file, string $latestVersion): void
$composerJson['require'][$shopwarePackage] = $version;
}

if (isset($composerJson['require']['shopware/commercial'])) {
// If commercial is installed, also update it directly as part of the core update to keep them in sync

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need to ensure, that the given $version is of format (v)11.22.33.44.
I am not sure, if "versions" like dev-trunk are also possible at this point 🤔

// Remove leading "(v)6." from Shopware version to match commercial release versions
$composerJson['require']['shopware/commercial'] = substr($version, strpos($version, '.') + 1);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The entire bootstrapping of extension loading is forgotten at this place.

How does Composer will get the next version? The plugin can be in:

  • vendor (required store version)
  • custom/static-plugins (someone put it there)
  • custom/plugins (downloaded through plugin manager)

To fulfill this, you will need packages.shopware.com. This is right now on 0% of Shops configured who uses the WebInstaller, if they already now our packages, they might not use this tool at all anymore.

There are still no API to gather the packages token, so you will have to fallback to regular API Download which we have in core. But the application might me such in a unstable state, that an bin/console store:download SwagCommercial may also fail. Also that command is not forward-compatible, when you run it on the old version, you get the old version. On the new version, you may already too late and it's broken because "you didnt updated them at same time". So the only real viable solution is to make those SBP API Calls also in the WebInstaller and grab the store token manually from Shopware DB.

When we wanna open this Topic really, I would push further that we authenticate every Shopware instance against packages.shopware.com, and only use that mechanism. I would not port the existing uggly zip downloading to there. The store packages, would solve this problem also for PayPal plugin whatever else requires this in future

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the mentioned issue, we should do first shopware/shopware#13631

}

$composerJson = $this->configureRepositories($composerJson);

file_put_contents($file, json_encode($composerJson, \JSON_THROW_ON_ERROR | \JSON_PRETTY_PRINT | \JSON_UNESCAPED_SLASHES));
Expand Down
27 changes: 27 additions & 0 deletions Tests/Services/ProjectComposerJsonUpdaterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,33 @@ public function testUpdateWithFixVersionAndBranchSame(): void
);
}

public function testUpdateWithCommercialRequirement(): void
{
file_put_contents($this->json, json_encode([
'require' => [
'shopware/core' => '1.2.3',
'shopware/commercial' => '1.2.3',
],
], \JSON_THROW_ON_ERROR));

(new ProjectComposerJsonUpdater(new MockHttpClient([$this->getEmptyVersionsResponse()])))->update(
$this->json,
'6.7.6.0'
);

$composerJson = json_decode((string) file_get_contents($this->json), true, 512, \JSON_THROW_ON_ERROR);

static::assertSame(
[
'require' => [
'shopware/core' => '6.7.6.0',
'shopware/commercial' => '7.6.0',
],
],
$composerJson
);
}

public function testUpdateWithSymfonyRuntimeRequirement(): void
{
file_put_contents($this->json, json_encode([
Expand Down