Page MenuHomePhabricator

Invite for translation when creating a new article not showing for new users
Closed, ResolvedPublic

Description

After thorough investigation on T232372, me and @Petar.petkovic couldn't find a way to get this working for a new user, checking in the code that all the requirements were met.

This task is to investigate why is not showing and find a fix for it.
For more information on the requirements needed please check T232372.
You can see detailed debugging data in T232372#5595821.

UPDATE:
From the previous investigation, what is missing from the original task is the invitation not showing for newly created users

It was reported by @Jpita that new users on Javanese Wikipedia (on which CX is out of beta) are not seeing invite. I instructed him to edit articles on some non-Javanese Wikipedia and try again. The invite was not showing after that, so we did some investigation. Without a clear cause, I went on to investigate on my own.

After creating a new user on Javanese Wikipedia, I went to Serbian Wikipedia, found some article to fix typo and made an edit. Then, I opened https://jv.wikipedia.org/w/index.php?title=Paneer&action=edit&debug=1 to check if invite will show. First time, Visual Editor dialog was shown. I kept reloading as I was eliminating possible causes for invite not being shown. The script ext.cx.entrypoints.newbytranslation.js was not loaded, so I spent time checking conditions on server side.
I checked following with respective outputs:

Condition	Output
mw.user.options.get( 'cx-enable-entrypoints' )	true
mw.config.get( 'wgVisualEditorConfig' ).showBetaWelcome	true
mw.user.options.get( 'visualeditor-hidebetawelcome' )	"1"
These options and configs were used to check if early return is needed. If early return does not happen, we get to the following line:
if ( $wgContentTranslationAsBetaFeature === false && self::isPotentialTranslator( $user ) )

Content Translation is no longer beta feature on Javanese. Check self::isPotentialTranslator( $user ) looks if user ever started any translation using CX. If not, we check CentralAuth for edit counts on Wikipedia sites. We can see that new user account I created has edits on Serbian Wikipedia - https://jv.wikipedia.org/w/index.php?title=Astamiwa:Otoritas_pusat&target=Testuser212

@santhosh What could be the reason for script ext.cx.entrypoints.newbytranslation.js not being loaded to show the invite?

Event Timeline

I did some debugging by creating a test user as mentioned in the bug report and doing different workflows. For the new user, the suggestions never showed up, untill I created a draft translation. This concludes that
the logic in isPotentialTranslator is not returning true for new user.

private static function isPotentialTranslator( User $user ) {
		if ( Translator::isTranslator( $user ) ) {
			// Already a translator
			return true;
		}

		if ( ExtensionRegistry::getInstance()->isLoaded( 'CentralAuth' ) ) {
			$centralUser = CentralAuthUser::newFromId( $user->getId() );
			if ( !$centralUser ) {
				// No user exists with that id
				return false;
			}

			// Check if the user has edited in more than one wiki.
			$editedWikiCount = 0;
			$attachedAccounts = $centralUser->queryAttached();
			foreach ( $attachedAccounts as $account ) {
				if (
					// Ignore non-wikipedia wikis such as commons, mediawiki, meta etc
					// url property example "https://commons.wikimedia.org",
					strpos( $account['url'] ?? '', 'wikipedia' ) !== false &&
					intval( $account['editCount'] ?? 0 ) > 0
				) {
					$editedWikiCount++;
					break;
				}
			}
			if ( $editedWikiCount === 0 ) {
				return false;
			}
		}

		return true;
	}

This means, if Translator::isTranslator( $user ) is returning true, everything works fine. If not, the rest of the logic in the code is not able to return true for new user. The good news is we know what part of the code is faulty for new users. Bad news is debugging with centralauth is not easy in our local development machines.

Change 556522 had a related patch set uploaded (by Santhosh; owner: Santhosh):
[mediawiki/extensions/ContentTranslation@master] isPotentialTranslator: Fix the editCount and wiki validation

https://gerrit.wikimedia.org/r/556522

Change 556522 merged by jenkins-bot:
[mediawiki/extensions/ContentTranslation@master] isPotentialTranslator: Fix the editCount and wiki validation

https://gerrit.wikimedia.org/r/556522

@santhosh currently, if I

  1. create a new user on jv.wikipedia.org
  2. change it's language from javanese to english
  3. go to jv.wikipedia.org/w/index.php?title=Paneer&action=edit and close the visual editor popup
  4. go to jv.wikipedia.org/w/index.php?title=Paneer&action=edit

I get the specific invite with the Paneer article in English.
This behaviour is expected and was not working before.

BUT...

If I

  1. create a new user on jv.wikipedia.org
  2. change it's language from javanese to english
  3. go to jv.wikipedia.org/w/index.php?title=randomArticle&action=edit and close the visual editor popup
  4. go to jv.wikipedia.org/w/index.php?title=randomArticle&action=edit

I should get the generic invite, but nothing appears.

I should get the generic invite, but nothing appears.

That 4 steps in this comment looks same in both cases to my eyes. So, confused.

I forgot to change the text of the 2nd case links, updated the comment now.
On the 2nd case the article does not exist in another language

Generic invite is supposed to show only once and only for the user having no translations yet. Can you help me getting the following code executed for the second case in browser console?

>> mw.config.get( 'wgContentTranslationExistingTranslator' )
true
>> mw.config.get( 'wgContentTranslationNewByTranslationShown' )
"true"

If both value are true, no invites are shown. But if the user is new, both these values are supposed to be false.
In any case, if this issue is present, it is not part of this ticket, probably the parent ticket.

I just tried with a brand new user, not changing the language and going to https://jv.wikipedia.org/w/index.php?title=Paneer&action=edit and the special invite is showing.
I believe this is not supposed to be happening.
the results of your query are:

mw.config.get( 'wgContentTranslationExistingTranslator' )
false
mw.config.get( 'wgContentTranslationNewByTranslationShown' )
"true"

image.png (1×1 px, 609 KB)

In summary:
There are 2 issues:

  1. The generic invite is not showing
  2. The specific invite is always showing, even for non-multilingual users

Are these issues going to be fixed here or should I create other tickets?

Change 564392 had a related patch set uploaded (by Santhosh; owner: Santhosh):
[mediawiki/extensions/ContentTranslation@master] Fix the default result of isPotentialTranslator

https://gerrit.wikimedia.org/r/564392

Change 564392 merged by jenkins-bot:
[mediawiki/extensions/ContentTranslation@master] Fix the default result of isPotentialTranslator

https://gerrit.wikimedia.org/r/564392

@KartikMistry how can I know when this is going to be deployed?
the tag on the tag (wmf11) doesn't have the latest code

@KartikMistry how can I know when this is going to be deployed?
the tag on the tag (wmf11) doesn't have the latest code

This will be available with wmf.15 (ie on Friday for all Wikis): https://www.mediawiki.org/wiki/MediaWiki_1.35/wmf.15#ContentTranslation

New user created on jv.wiki:

Steps:

user info:
https://gist.github.com/jpita/ebebab16648441b5c909903a5e0f1767

mw.config.get( 'wgContentTranslationExistingTranslator' )
null
mw.config.get( 'wgContentTranslationNewByTranslationShown' )
null

Change 569935 had a related patch set uploaded (by Santhosh; owner: Santhosh):
[mediawiki/extensions/ContentTranslation@master] Hooks: Fix CentralAuth user instance calculation

https://gerrit.wikimedia.org/r/569935

Change 569935 merged by jenkins-bot:
[mediawiki/extensions/ContentTranslation@master] Hooks: Fix CentralAuth user instance calculation

https://gerrit.wikimedia.org/r/569935

Change 573064 had a related patch set uploaded (by Santhosh; owner: Santhosh):
[mediawiki/extensions/ContentTranslation@master] Fix impossible condition in Hooks:isPotentialTranslator

https://gerrit.wikimedia.org/r/573064

Change 573064 merged by jenkins-bot:
[mediawiki/extensions/ContentTranslation@master] Fix impossible condition in Hooks:isPotentialTranslator

https://gerrit.wikimedia.org/r/573064