Skip to content

Commit 39c3a25

Browse files
Merge pull request #541 from Smartling/WP-907-batches-error
fix batch creation error (WP-907)
2 parents 1ec4543 + 566acc8 commit 39c3a25

File tree

5 files changed

+71
-4
lines changed

5 files changed

+71
-4
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "smartling/wordpress-connector",
33
"license": "GPL-2.0-or-later",
4-
"version": "3.9.8",
4+
"version": "3.9.9",
55
"description": "",
66
"type": "wordpress-plugin",
77
"repositories": [

inc/Smartling/Services/ContentRelationsDiscoveryService.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ public function createSubmissions(UserTranslationRequest $request): void
302302
$this->uploadQueueManager->enqueue($queueIds, $this->apiWrapper->createBatch(
303303
$profile,
304304
$jobInfo->getJobUid(),
305-
array_unique($fileUris),
305+
array_values(array_unique($fileUris)),
306306
$job->isAuthorize(),
307307
));
308308
}

readme.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Tags: translation, localization, localisation, translate, multilingual, smartlin
44
Requires at least: 5.5
55
Tested up to: 6.4.1
66
Requires PHP: 8.0
7-
Stable tag: 3.9.8
7+
Stable tag: 3.9.9
88
License: GPLv2 or later
99

1010
Translate content in WordPress quickly and seamlessly with Smartling, the industry-leading Translation Management System.
@@ -62,6 +62,9 @@ Additional information on the Smartling Connector for WordPress can be found [he
6262
3. Track translation status within WordPress from the Submissions Board. View overall progress of submitted translation requests as well as resend updated content.
6363

6464
== Changelog ==
65+
= 3.9.9 =
66+
* Fixed submissions not being uploaded when related assets list has multiple entries that point to the same content
67+
6568
= 3.9.8 =
6669
* Fixed extra slashes being added in Gutenberg block attributes that had quotes after translation
6770

smartling-connector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* Plugin Name: Smartling Connector
1212
* Plugin URI: https://www.smartling.com/products/automate/integrations/wordpress/
1313
* Description: Integrate your WordPress site with Smartling to upload your content and download translations.
14-
* Version: 3.9.8
14+
* Version: 3.9.9
1515
* Author: Smartling
1616
* Author URI: https://www.smartling.com
1717
* License: GPL-2.0+

tests/Services/ContentRelationDiscoveryServiceTest.php

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,70 @@ public function testCreateSubmissionsHandler()
151151
]));
152152
}
153153

154+
public function testCreateSubmissionsRelations()
155+
{
156+
$sourceBlogId = 1;
157+
$sourceId = 48;
158+
$contentType = 'post';
159+
$targetBlogId = 2;
160+
$jobName = 'Job Name';
161+
$jobUid = 'abcdef123456';
162+
163+
$apiWrapper = $this->createMock(ApiWrapper::class);
164+
$apiWrapper->expects($this->once())->method('createBatch')->willReturnCallback(
165+
function (ConfigurationProfileEntity $profile, string $jobUid, array $fileUris): string {
166+
$arrayPointer = 0; // TODO replace with array_is_list() once php 8.1 is used
167+
foreach ($fileUris as $key => $value) {
168+
if ($key !== $arrayPointer++) {
169+
throw new \RuntimeException('FileUris expected to be list');
170+
}
171+
}
172+
173+
return '';
174+
});
175+
176+
$submission1 = $this->createMock(SubmissionEntity::class);
177+
$submission1->method('getId')->willReturn(17);
178+
$submission1->method('getFileUri')->willReturn('17');
179+
180+
$submission2 = $this->createMock(SubmissionEntity::class);
181+
$submission2->method('getId')->willReturn(23);
182+
$submission2->method('getFileUri')->willReturn('23');
183+
184+
$submissionFactory = $this->createMock(SubmissionFactory::class);
185+
$submissionFactory->method('fromArray')->willReturn($submission1, $submission2);
186+
187+
$submissionManager = $this->getMockBuilder(SubmissionManager::class)->disableOriginalConstructor()
188+
->getMock();
189+
$submissionManager->method('findOne')->willReturn($submission1, $submission1, $submission2);
190+
$submissionManager->method('storeEntity')->willReturnArgument(0);
191+
192+
$wpProxy = $this->createMock(WordpressFunctionProxyHelper::class);
193+
$wpProxy->method('get_current_blog_id')->willReturn($sourceBlogId);
194+
195+
$this->getContentRelationDiscoveryService(
196+
$apiWrapper,
197+
submissionManager: $submissionManager,
198+
submissionFactory: $submissionFactory,
199+
wpProxy: $wpProxy
200+
)->createSubmissions(UserTranslationRequest::fromArray([
201+
'source' => ['contentType' => $contentType, 'id' => [$sourceId]],
202+
'job' =>
203+
[
204+
'id' => $jobUid,
205+
'name' => $jobName,
206+
'description' => '',
207+
'dueDate' => '',
208+
'timeZone' => 'Europe/Kiev',
209+
'authorize' => 'true',
210+
],
211+
'targetBlogIds' => $targetBlogId,
212+
'relations' => [
213+
1 => [$targetBlogId => ['post' => [17]]],
214+
2 => [$targetBlogId => ['attachment' => [23]]],
215+
],
216+
]));
217+
}
154218
public function testBulkSubmitHandler()
155219
{
156220
$sourceBlogId = 1;

0 commit comments

Comments
 (0)