Skip to content

Commit

Permalink
Merge pull request #418 from AcclaroInc/release/v2.2.4
Browse files Browse the repository at this point in the history
Release/2.2.4
  • Loading branch information
bhupeshappfoster authored Feb 6, 2023
2 parents 261e204 + 625cea8 commit f3d79f8
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .craftplugin
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"pluginName": "Translations for Craft",
"pluginDescription": "Drive global growth with simplified translation workflows.",
"pluginVersion": "2.2.3",
"pluginVersion": "2.2.4",
"pluginAuthorName": "Acclaro",
"pluginVendorName": "Acclaro",
"pluginAuthorUrl": "http://www.acclaro.com/",
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/discord-notify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ name: Discord Notification
# events but only for the main branch
on:
push:
branches: [ master ]
branches: [ craft3 ]

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
Expand All @@ -15,8 +15,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- uses: fateyan/[email protected]
with:
message-title: New Deploy for Craft Translations
message-title: New Deploy for Craft(3) Translations
webhook: ${{ secrets.DISCORD_WEBHOOK }}
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/).

## 2.2.4 - 2023-02-06

### Fixed
- An issue where order unable to create draft due to tag id mismatch. ([AcclaroInc#410](https://github.com/AcclaroInc/craft-translations/issues/410))

### Chore
- Code refactor (draft creation & publish)

## 2.2.3 - 2022-08-01

### Fixed
Expand Down
4 changes: 2 additions & 2 deletions src/controllers/OrderController.php
Original file line number Diff line number Diff line change
Expand Up @@ -1020,12 +1020,12 @@ public function actionSaveDraftAndPublish()
} catch (Exception $e) {
$actionName = $action == "publish" ? "publish" : "merge";
$order->logActivity(Translations::$plugin->translator->translate('app', "Could not $actionName draft Error: " . $e->getMessage()));
Translations::$plugin->logHelper->log( '['. __METHOD__ .'] Couldn’t save the draft. Error: '.$e->getMessage(), Constants::LOG_LEVEL_ERROR );
$order->status = 'failed';
Translations::$plugin->logHelper->log( '['. __METHOD__ .'] Couldn’t save the draft. Error: '.$e, Constants::LOG_LEVEL_ERROR );
Craft::$app->getElements()->saveElement($order);
Craft::$app->getSession()->setNotice(
Translations::$plugin->translator->translate('app', "Could not $actionName draft Error: " . $e->getMessage())
);
return;
}

if ($job) {
Expand Down
7 changes: 2 additions & 5 deletions src/services/fieldtranslator/TagFieldTranslator.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,12 @@ class TagFieldTranslator extends TaxonomyFieldTranslator
{
public function translateRelated(ElementTranslator $elementTranslator, Element $element, Tag $existingTag, $sourceSite, $targetSite, $fieldData)
{
$translatedTag = Translations::$plugin->tagRepository->find(array(
'id' => $existingTag->id,
'groupId' => $existingTag->groupId,
'siteId' => $existingTag->siteId
));
$translatedTag = Translations::$plugin->tagRepository->getTagById($existingTag->id, $targetSite);

if ($translatedTag) {
$tag = $translatedTag;
} else {
// Doesn't feels this part runs as tags are propagated to all target locales if localised
$tag = Translations::$plugin->elementCloner->cloneElement($existingTag);
}

Expand Down
6 changes: 4 additions & 2 deletions src/services/repository/DraftRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ public function createOrderDrafts($orderId, $wordCounts, $publish, $fileIds, $qu
$currentElement = 0;

$createDrafts = new CreateDrafts();
$transaction = Craft::$app->db->beginTransaction();

foreach ($order->getFiles() as $file) {
if (! in_array($file->id, $fileIds)) {
Expand Down Expand Up @@ -213,11 +214,12 @@ public function createOrderDrafts($orderId, $wordCounts, $publish, $fileIds, $qu
if ($publish) {
$this->applyDrafts($order->id, [$element->id], [$file->id], $queue);
}

} catch(Exception $e) {
$order->logActivity(Translations::$plugin->translator->translate('app', 'Could not update draft Error: ' .$e->getMessage()));
$transaction->rollback();
throw new \Exception($e->getMessage());
}
}
$transaction->commit();

if ($isNewDraft)
$order->logActivity(Translations::$plugin->translator->translate('app', 'Drafts created'));
Expand Down
13 changes: 13 additions & 0 deletions src/services/repository/TagRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,19 @@ public function find($attributes = null)
->one();
}

/**
* Returns a tag by its ID.
*
* @param int $tagId
* @param int|null $siteId
* @return Tag|null
*/
public function getTagById(int $tagId, int $siteId = null)
{
/** @noinspection PhpIncompatibleReturnTypeInspection */
return Craft::$app->getElements()->getElementById($tagId, Tag::class, $siteId);
}

public function saveTag(Tag $tag)
{
$success = Craft::$app->elements->saveElement($tag, true, false);
Expand Down

0 comments on commit f3d79f8

Please sign in to comment.