95 UserIdentity $userIdentity,
98 RevisionRecord $revisionRecord,
99 EditResult $editResult
101 global $wgEnablePageTranslation;
103 $content = $wikiPage->getContent();
105 if ( !$content instanceof TextContent ) {
110 $text = $content->getText();
111 $title = $wikiPage->getTitle();
114 if ( !$handle->isValid() ) {
120 $isDummyRevision = !$editResult->isNew()
121 && ( $editResult->getOriginalRevisionId() === $revisionRecord->getParentId() );
123 if ( $isDummyRevision ) {
138 $isNullEdit = $editResult->getOriginalRevisionId() === $revisionRecord->getId();
141 $revId = $revisionRecord->getId();
142 $mwServices = MediaWikiServices::getInstance();
144 $fuzzy = $handle->needsFuzzy( $text );
145 $parentId = $revisionRecord->getParentId();
146 $revTagStore = Services::getInstance()->getRevTagStore();
147 if ( $isNullEdit || $parentId == 0 ) {
149 $wasFuzzy = $handle->isFuzzy();
154 $wasFuzzy = $revTagStore->isRevIdFuzzy( $title->getArticleID(), $parentId );
156 if ( !$fuzzy && $wasFuzzy ) {
157 $title = $mwServices->getTitleFactory()->newFromPageIdentity( $wikiPage );
158 $user = $mwServices->getUserFactory()->newFromUserIdentity( $userIdentity );
160 if ( !$mwServices->getPermissionManager()->userCan(
'unfuzzy', $user, $title ) ) {
163 } elseif ( $isNullEdit ) {
164 $entry =
new ManualLogEntry(
'translationreview',
'unfuzzy' );
169 $nullRevision = $mwServices->getPageUpdaterFactory()
170 ->newPageUpdater( $wikiPage, $userIdentity )
172 CommentStoreComment::newUnsavedComment(
173 $summary !==
'' ? $summary : wfMessage(
"translate-unfuzzy-comment" )
180 $revId = $nullRevision->getId();
181 $entry->setAssociatedRevId( $revId );
182 $entry->setPerformer( $userIdentity );
183 $entry->setTarget( $title );
184 $logId = $entry->insert();
185 $entry->publish( $logId );
193 if ( !$fuzzy && $editResult->isExactRevert() ) {
194 $method = $editResult->getRevertMethod();
195 if ( $method !== EditResult::REVERT_MANUAL ) {
196 $revertedTo = $editResult->getOriginalRevisionId();
199 if ( $revertedTo !==
null ) {
200 $fuzzy = $revTagStore->isRevIdFuzzy( $title->getArticleID(), $revertedTo );
205 self::updateFuzzyTag( $title, $revId, $fuzzy );
207 $group = $handle->getGroup();
209 if ( $handle->getCode() !== $group->getSourceLanguage() ) {
214 MessageGroupStats::clear( $handle );
220 DeferredUpdates::addCallableUpdate(
221 static function () use ( $handle ) {
225 $user = $mwServices->getUserFactory()
226 ->newFromId( $userIdentity->getId() );
229 Services::getInstance()->getHookRunner()
230 ->onTranslate_newTranslation( $handle, $revId, $text, $user );
231 } elseif ( $revertedTo !==
null ) {
234 $oldTransver = $revTagStore->getTransver( $title, $revertedTo );
235 if ( $oldTransver !==
null ) {
236 $revTagStore->setTransver( $title, $revId, $oldTransver );
240 TtmServer::onChange( $handle );
242 if ( $wgEnablePageTranslation && $handle->isPageTranslation() ) {
244 $minor = (bool)( $flags & EDIT_MINOR );
246 $summary, $minor, $flags, $handle );
294 if ( $user->isAllowed(
'bot' ) ) {
298 $group = $handle->getGroup();
300 $title = $handle->getTitle();
301 $name = $handle->getKey() .
'/' . $group->getSourceLanguage();
302 $definitionTitle = Title::makeTitleSafe( $title->getNamespace(), $name );
303 if ( !$definitionTitle || !$definitionTitle->exists() ) {
307 $definitionRevision = $definitionTitle->getLatestRevID();
308 $revTagStore = Services::getInstance()->getRevTagStore();
309 $revTagStore->setTransver( $title, $revision, $definitionRevision );