Repository navigation
choose configuration profile UI (WP-1022) #638
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
df19959
36084e4
512a55a
0e82d57
71d7e48
59ecdc8
559dc45
151c345
e2fd2ba
5735049
5847c8d
ab8892e
50715fc
ad3e9a7
7c91702
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -103,13 +103,11 @@ public function bulkUpload( | |
| } | ||
| $submission->setFileUri($this->fileUriHelper->generateFileUri($submission)); | ||
| } | ||
| $this->warnIfReprofilingInProgress($submission, $profile->getId()); | ||
| $submission->setJobInfo($jobInfo); | ||
| $submission->setStatus(SubmissionEntity::SUBMISSION_STATUS_NEW); | ||
| $submission->setIsCloned(0); | ||
| // Bulk-submitting is an explicit new translation request: (re)stamp with the | ||
| // profile this request's batch is being created under, for both a found | ||
| // existing submission (which bypasses getSubmissionEntity() above) and a new | ||
| // one (where this just confirms what getSubmissionEntity() already stamped). | ||
| // Bulk-submitting is an explicit new translation request: (re)stamp with the profile it was requested with. | ||
| $submission->setConfigurationProfileId($profile->getId()); | ||
| $submission = $this->submissionManager->storeEntity($submission); | ||
| $queueIds[] = $submission->getId(); | ||
|
|
@@ -153,7 +151,8 @@ public function bulkUpload( | |
| public function createSubmissions(UserTranslationRequest $request): void | ||
| { | ||
| $curBlogId = $this->wordpressProxy->get_current_blog_id(); | ||
| $profile = $this->settingsManager->getSingleSettingsProfile($curBlogId); | ||
| $profile = $this->settingsManager->resolveRequestedProfile($request->getProfileId(), $curBlogId); | ||
| $this->settingsManager->assertTargetBlogIdsBelongToProfile($profile, $request->getTargetBlogIds()); | ||
| $job = $request->getJobInformation(); | ||
| $jobInfo = new JobEntity($job->getName(), $job->getId(), $profile->getProjectId()); | ||
|
|
||
|
|
@@ -228,12 +227,11 @@ public function createSubmissions(UserTranslationRequest $request): void | |
| 'type' => $request->getContentType(), | ||
| ]; | ||
| } else { | ||
| $this->warnIfReprofilingInProgress($submission, $profile->getId()); | ||
| $submission->setStatus(SubmissionEntity::SUBMISSION_STATUS_NEW); | ||
| $submission->setIsCloned(0); | ||
| // Resubmitting an existing submission is an explicit new translation request, | ||
| // so (re)stamp it with the profile active right now, same as | ||
| // SubmissionManager::getSubmissionEntity() does - this path never goes through | ||
| // that method, so it would otherwise keep whatever profile (or none) it had. | ||
| // Resubmitting an existing submission is an explicit new translation request, so restamp it with the | ||
| // profile it was requested with. | ||
| $submission->setConfigurationProfileId($profile->getId()); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Medium] (also applies to
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added a warning (not a block, since this is a resubmission the user explicitly asked for) when an existing submission is still IN_PROGRESS under a different profile - logs the submission id and old/new profile ids before the restamp. Same in (5847c8d) |
||
| $submission = $this->storeWithJobInfo($submission, $jobInfo, $request->getDescription()); | ||
| $fileUris[] = $submission->getFileUri(); | ||
|
|
@@ -242,9 +240,7 @@ public function createSubmissions(UserTranslationRequest $request): void | |
|
|
||
| $submissionTemplateArray[SubmissionEntity::FIELD_STATUS] = SubmissionEntity::SUBMISSION_STATUS_NEW; | ||
| $submissionTemplateArray[SubmissionEntity::FIELD_SUBMISSION_DATE] = DateTimeHelper::nowAsString(); | ||
| // New submissions built from this template bypass getSubmissionEntity() too; stamp | ||
| // them with the profile this request's batch is being created under (below), so | ||
| // UploadJob never has to guess at a profile for them later. | ||
| // New submissions built from this template bypass getSubmissionEntity(), stamp them with the requested profile. | ||
| $submissionTemplateArray[SubmissionEntity::FIELD_CONFIGURATION_PROFILE_ID] = $profile->getId(); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [High] Parent submissions are stamped with the requested profile here, but related content created later still gets the default profile. With profile B chosen, children get profile A's credentials but B's job (
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed. Checked (5847c8d, tests in SubmissionManagerTest/ReferencedContentProcessorTest) |
||
|
|
||
| foreach ($sources as $source) { | ||
|
|
@@ -594,6 +590,27 @@ public function normalizeReferences(array $references): array | |
| return $result; | ||
| } | ||
|
|
||
| /** | ||
| * Re-stamping an existing submission to a different profile is an explicit, supported part of resubmitting | ||
| * under a user-chosen profile - but if it's still IN_PROGRESS under the old one, it loses its link to that | ||
| * project's file/job, and status checks/downloads will look at the new project instead. Warn so this is at | ||
| * least visible, without blocking the resubmission. | ||
| */ | ||
| private function warnIfReprofilingInProgress(SubmissionEntity $submission, int $newProfileId): void | ||
| { | ||
| $oldProfileId = $submission->getConfigurationProfileId(); | ||
| if ($oldProfileId !== null && $oldProfileId !== $newProfileId | ||
| && $submission->getStatus() === SubmissionEntity::SUBMISSION_STATUS_IN_PROGRESS | ||
| ) { | ||
| $this->getLogger()->warning(sprintf( | ||
| 'Resubmitting submissionId=%d from profileId=%d to profileId=%d while still in progress; it will lose its link to the previous profile\'s file/job.', | ||
| $submission->getId(), | ||
| $oldProfileId, | ||
| $newProfileId, | ||
| )); | ||
| } | ||
| } | ||
|
|
||
| private function storeWithJobInfo(SubmissionEntity $submission, JobEntity $jobInfo, string $description): SubmissionEntity | ||
| { | ||
| $submission->setJobInfo($jobInfo); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[High]
targetBlogIdsaren't checked against the resolved profile's enabled target locales. A blog outside profile B (stale tab, crafted request, or a locale picked in the side widget, which now merges all profiles) is accepted.getSmartlingLocaleIdBySettingsProfile()then returns'', so the upload fails later, away from the request. Can we reject it here with a 400? The same applies tocreate-job(ContentEditJobController.php:161) and instant translation (InstantTranslationController.php:58).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added
SettingsManager::assertTargetBlogIdsBelongToProfile(), called fromcreateSubmissions()(covers both the bulk and non-bulk paths),ContentEditJobController's create-job case,InstantTranslationController::handleRequestTranslation(), and the legacy widget'sajaxUploadHandler(). All four now reject with a 400 before doing any work instead of silently producing an empty Smartling locale.(5847c8d)