Skip to content

page does not exist removed from username #3620

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

Closed
wants to merge 4 commits into from

Conversation

318anushka
Copy link
Contributor

Description (required)
In Explore, some pictures have (page does not exist) string appended to the username.

Fixes #3341 "Page does not exist" near some usernames in Explore
What changes did you make and why?
formatted the string in Media getArtist() when author name is fetched through metadata.

Tests performed (required)

Tested ProdDebug on OnePlus 5 with API level 28.

Copy link

@tests-checker tests-checker bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please add tests to make sure this change works as expected?

@macgills
Copy link
Contributor

macgills commented Apr 6, 2020

This seems a bit hacky, if we could address the root problem I would be happier. Is this somehow related to custom author names?

@318anushka
Copy link
Contributor Author

@macgills
Copy link
Contributor

macgills commented Apr 6, 2020

              "Artist": {
                "value": "<a href=\"//commons.wikimedia.org/w/index.php?title=User:%D7%98%D7%9C_%D7%A9%D7%9E%D7%A2&amp;action=edit&amp;redlink=1\" class=\"new\" title=\"User:טל שמע (page does not exist)\">טל שמע</a>",
                "source": "commons-desc-page"
              },

I am sorry, you might have to spell this out for me a bit more.

The API is returning this bad text, do we know why this text was created? Have you tried an upload with a bad custom author name?

The solution may be client side formatting but I would massively prefer if it wasn't

@318anushka
Copy link
Contributor Author

No idea about it and it's not always created.
Sorry but I’m not very clear what do mean by bad custom author name?

@macgills
Copy link
Contributor

macgills commented Apr 6, 2020

In the settings screen we can put in a custom author name. #3415 #3205 #3536 there are some issues around it. I don't have enough in depth knowledge about it to confirm what is happening but if you could investigate if your uploads are tainted with a custom author name set then that may give us more insight into this problem

@macgills
Copy link
Contributor

macgills commented Apr 6, 2020

Is the custom name in anyway related is what I wanted to get at.

              "Artist": {
                "value": "<a href=\"https://commons.wikimedia.beta.wmflabs.org/w/index.php?title=User:Qwert._qwerty&amp;action=edit&amp;redlink=1\" class=\"new\" title=\"User:Qwert. qwerty (page does not exist)\">qwert.  qwerty</a>",
                "source": "commons-desc-page"
              },

Is (page does not exist) added to every artist in explore? Only ones with custom names? Without custom names? Do custom names matter at all to this bug? What does this look like on any other client?

I want a complete diagnosis of the problem

@318anushka
Copy link
Contributor Author

318anushka commented Apr 6, 2020

I found the cause it happens only for users who don't have a user page on commons or user not registered. So for each custom author name that user chooses he has to create a separate page i otherwise link is red.
this is related issue #3160

@318anushka
Copy link
Contributor Author

do we intend to direct user to new user page with custom author name?
If no then why are user and author both set to same value. This is what creating problem i guess.

@sivaraam
Copy link
Member

sivaraam commented Apr 7, 2020

do we intend to direct user to new user page with custom author name?

For this issue, just forget about the Custom author name. It's not specific to that. AFAIK, you'll get that "(page does not exist)" text only when there is no user page associated with the author field. See

https://commons.wikimedia.beta.wmflabs.org/w/api.php?action=query&format=json&prop=imageinfo&titles=File%3ADalgona_coffee.jpg&formatversion=2&iiprop=url%7Cextmetadata&iiextmetadatafilter=DateTime%7CCategories%7CGPSLatitude%7CGPSLongitude%7CImageDescription%7CDateTimeOriginal%7CArtist%7CLicenseShortName%7CLicenseUrl

If we just need the name of the user who uploaded the image (as opposed to the author of the image) I believe adding the user via iiprop would give us that information. Check if that works as a possible solution. Example:

https://commons.wikimedia.beta.wmflabs.org/w/api.php?action=query&format=json&prop=imageinfo&titles=File%3ADalgona_coffee.jpg&formatversion=2&iiprop=url%7Cextmetadata%7Cuser&iiextmetadatafilter=DateTime%7CCategories%7CGPSLatitude%7CGPSLongitude%7CImageDescription%7CDateTimeOriginal%7CArtist%7CLicenseShortName%7CLicenseUrl

(See the 'user' parameter within pages > 0 > imageinfo > 0)

@318anushka
Copy link
Contributor Author

If we just need the name of the user who uploaded the image (as opposed to the author of the image) I believe adding the user via iiprop would give us that information. Check if that works as a possible solution.

But in that case wouldn't be author of image on web browser be same as username?
We don't want that right else what is the use of adding custom author.

@sivaraam
Copy link
Member

sivaraam commented Apr 7, 2020

But in that case wouldn't be author of image on web browser be same as username?

I couldn't understand what you mean by this. Can you clarify?

@sivaraam
Copy link
Member

sivaraam commented Apr 7, 2020

FYI: I was suggesting that the user field might provide the desired value as the thing we're trying to fix here is just about the uploader and not about the author.

image

I say this based on the above screenshot which says "Uploaded by" and haven't yet looked at the code. If we use actually show the name of the author as "Uploaded by" that would mean the phrase "Uploaded by" is actually misleading as the uploader and author could be totally different for an image.

Apologies, for the vagueness of my comments. I'm just sharing what I know in case they're helpful in some way. I'll try to look at the code and comment better.

@318anushka
Copy link
Contributor Author

Uploader is the username, right?

@318anushka
Copy link
Contributor Author

318anushka commented Apr 7, 2020

I couldn't understand what you mean by this. Can you clarify?

See this image for example:
image

Author here is the custom name that i chose and that's what we want in Uploaded by i guess
Currently, author name is set as creator of contribution so that value is displayed everywhere. if we wish to change that then
.append("|author=[[User:").append(creator).append("|").append(creator).append("]]\n");
here instead of setting both as creator (which by default is username else author name) first field should be user.

@318anushka
Copy link
Contributor Author

Okay i think i get it now. Few more things to clear before writing the code.

  • We want to display username or author in Uploaded by

  • Instead of new user page for every author we want to link it to the registered user

  • This issue still exists if user hasn't created a page

@sivaraam
Copy link
Member

sivaraam commented Apr 7, 2020

We want to display username or author in Uploaded by

If I were to just go by the phrase "Uploaded by" I would say it's best to show the uploader (the username of the person who uploaded it). To back up my conclusion let me quote a recent comment by @nicolas-raoul about the use case for the "Uploaded via Mobile" tab.

Context: "Uploaded via mobile" is meant to emulate good behavior by showing good pictures uploaded by others. It also allows experienced users to spot bad pictures and delete them, on the go.

The experienced users would expect the name of the uploader to be shown there as it would be helpful for them for their work. So, I think showing the uploader would be the appropriate thing to do.

Instead of new user page for every author we want to link it to the registered user

I don't get this. What do you mean by this and how does this relate to the issue?

This issue still exists if user hasn't created a page

I couldn't get this too.

I took a look at the code and it looks like we really are just showing the author name as "Uploaded by". This is misleading, IMO.

As an aside, it looks like the code that parses the author name would just return an empty string for some valid cases. For example: File:Troy Hunt.jpg. These are also the images for which you see no "Uploaded By:" line in the Explore, Uploaded via Mobile screens!
Also, it just seems to show creepy text in other cases. Example: File:Jean-François de Troy - A Hunting Meal - WGA23084.jpg
But that's not our concern now. We can look into those separately.

To conclude, I think we can fix this issue by properly showing uploader name[1] for "Uploaded by: ". This shouldn't be a big deal as we'll be showing the author name in the media detail view. Anyways, you can ask in the corresponding issue to see what the consensus is.

[1]: obtained from user parameter in imageinfo result

@318anushka
Copy link
Contributor Author

318anushka commented Apr 7, 2020

I don't get this. What do you mean by this and how does this relate to the issue?

For new users who haven't created a user page. Like i uploaded via app without creating a page for a while and in Uploaded via mobile it displayed "page does not exist" next to my username.
Anyway, this is just to explain what I meant. your proposed solution shouldn't cause that problem. I'll check and let you know :-)

@macgills
Copy link
Contributor

macgills commented Apr 8, 2020

@318anushka this is my own ignorance showing here: We have to create a user page? Is a user page not created when you create an account? Surely you can't upload without an account?

@318anushka
Copy link
Contributor Author

318anushka commented Apr 8, 2020

@318anushka this is my own ignorance showing here: We have to create a user page? Is a user page not created when you create an account? Surely you can't upload without an account?

yes, you have to create user page. Even if a user registers, page is not created on it own.

@318anushka
Copy link
Contributor Author

318anushka commented Apr 8, 2020

@sivaraam No changes in media detail view? It'd still show the author name.
This is fixed
image
This still exists
image

I suggest creating a separate issue for this as it is related to custom author name.

@neslihanturan
Copy link
Collaborator

@318anushka this is my own ignorance showing here: We have to create a user page? Is a user page not created when you create an account? Surely you can't upload without an account?

Actually no, you don't need to have a userpage to be able to upload. If you are a registered user and you didn't created your userpage as https://commons.wikimedia.org/wiki/User:USERNAMEHERE this user is still exist, just the page describe themselves is not there. (I have read the long conversation very fast, please ignore me if I am saying something you already knew)

@sivaraam
Copy link
Member

sivaraam commented Apr 8, 2020

This is fixed

Done.

This still exists

I think we should fix that too. The following modified version of the Media#getArtist should do the trick:

    private static String getArtist(ExtMetadata metadata) {
        try {
            final String anchorStartTagTerminalChars = "\">";
            final String anchorCloseTag = "</a>";

            String artistHtml = metadata.artist();
            return artistHtml
                    .substring(
                        artistHtml.indexOf(anchorStartTagTerminalChars),
                        artistHtml.indexOf(anchorCloseTag)
                    )
                    .substring(anchorStartTagTerminalChars.length());
        } catch (Exception ex) {
            return "";
        }
    }

I hope this doesn't break anything, though.

I suggest creating a separate issue for this as it is related to custom author name.

As I've said before this isn't related to custom author name at all. The custom author name is just one of the ways that you could easily use to make the issue surface. It happens in general whenever a author of an image is a commons user who hasn't created a user page. Example: File:Sticker Domitilla Tete Pierre.jpg - Wikimedia Commons. This image was not uploaded using the app at all. But if you view this image using the app (by searching in Explore) or check the corresponding API call you should see the (page does not exist) part appended to the Author.

@codecov-io
Copy link

codecov-io commented Apr 8, 2020

Codecov Report

Merging #3620 into master will increase coverage by 0.02%.
The diff coverage is 6.66%.

Impacted file tree graph

@@             Coverage Diff             @@
##             master   #3620      +/-   ##
===========================================
+ Coverage      6.95%   6.97%   +0.02%     
- Complexity      291     292       +1     
===========================================
  Files           256     256              
  Lines         11730   11749      +19     
  Branches        959     960       +1     
===========================================
+ Hits            816     820       +4     
- Misses        10843   10858      +15     
  Partials         71      71              
Impacted Files Coverage Δ Complexity Δ
.../fr/free/nrw/commons/category/GridViewAdapter.java 0.00% <0.00%> (ø) 0.00 <0.00> (ø)
...r/free/nrw/commons/contributions/Contribution.java 0.77% <0.00%> (ø) 1.00 <0.00> (ø)
.../commons/contributions/ContributionsPresenter.java 21.25% <0.00%> (ø) 5.00 <0.00> (ø)
...w/commons/explore/images/SearchImagesRenderer.java 0.00% <0.00%> (ø) 0.00 <0.00> (ø)
...fr/free/nrw/commons/mwapi/OkHttpJsonApiClient.java 0.00% <0.00%> (ø) 0.00 <0.00> (ø)
...n/java/fr/free/nrw/commons/upload/UploadModel.java 0.00% <0.00%> (ø) 0.00 <0.00> (ø)
app/src/main/java/fr/free/nrw/commons/Media.java 16.66% <15.38%> (-0.30%) 5.00 <0.00> (ø)
...main/java/fr/free/nrw/commons/WelcomeActivity.java 0.00% <0.00%> (ø) 0.00% <0.00%> (ø%)
...n/java/fr/free/nrw/commons/CommonsApplication.java 1.09% <0.00%> (ø) 1.00% <0.00%> (ø%)
...fr/free/nrw/commons/media/MediaDetailFragment.java 0.00% <0.00%> (ø) 0.00% <0.00%> (ø%)
... and 1 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update eb88e58...6046c45. Read the comment docs.

@@ -117,7 +120,7 @@ public static Media from(MwQueryPage page) {
ExtMetadata metadata = imageInfo.getMetadata();
if (metadata == null) {
Media media = new Media(null, imageInfo.getOriginalUrl(),
page.title(), "", 0, null, null, null);
page.title(), "", 0, null, null, null, null);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ImageInfo doesn't have a user if metaData is null?

@@ -98,9 +98,9 @@ public View getView(int position, View convertView, ViewGroup parent) {
* @param author
*/
private void setAuthorView(Media item, TextView author) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this still even an author? Uploader is probably more accurate?

@@ -107,7 +107,7 @@ public void fetchContributions() {
.filter(mwQueryLogEvent -> !mwQueryLogEvent.isDeleted()).doOnNext(mwQueryLogEvent -> Timber.d("Image %s passed filters", mwQueryLogEvent.title()))
.map(image -> {
Contribution contribution = new Contribution(null, null, image.title(),
"", -1, image.date(), image.date(), user,
"", -1, image.date(), image.date(), user, user,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems wrong in light of the other constructor where you set creator/user to different values
null, null, sessionManager.getAuthorName(), sessionManager.getUserName(),

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is for fetching current user's contributions and user value is username only

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay so when we are fetching current users contributions

creator == sessionManager.getUserName()
user == sessionManager.getUserName()

but when we are creating them to upload

creator == sessionManager.getAuthorName()
user == sessionManager.getUserName()

That is correct behaviour?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, didn't notice that. we are not displaying author in media detail. don't know why it is set to username.
@sivaraam shouldn't creator be getAuthorName() in first one too.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sivaraam any insight?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure if creator is a field we ever need right now at this point.

To add to what @318anushka said, creator is also useful as some images might literally have no relation between the Author and the person who uploaded it. Here's an example: File: Troy Hunt. The Author is Troy Hunt while the user who uploaded it is IagoQnsi.

This most likely comes into picture only in Explore, though. It should actually be a concern in Contributions too but let's give ourselves some break and not get into that for now ;)

When we create a Contribution for upload we set the creator to sessionManager.getAuthorName() aka just the user name

The author name information should come from the media rather than from the session manager but I believe we can't do it right now as we are using the logevents API. #2904 would change this, I believe.

We then upload the creator twice??

Just to clear the confusion, that's just the code for constructing the following wiki text:

[[User:USER_NAME | USER_NAME]]

The redundant USER_NAME is just to hide the User: prefix from the rendered wiki text.

It probably should be, I am now quite interested in what this artist metadata returns when we actually put the right data into this pageContents ...

I really couldn't get this. I think this PR is in a right shape now. If there's something that's still not clear let me know. I'll see if I could help with clarifying that.

Also while uploading
.append("|author=[[User:").append(contribution.getCreator()).append("|") .append(contribution.getCreator()).append("]]\n");
shouldn't first one of these field be username and then creator. I don't know about this just inferring from here

I have zero knowledge of the rationale behind custom author name. But I'm suspecting it's to enable users to have a custom name in author field (as opposed to allowing them to attribute images created by others) in which case you're right. The first one should be username. Anyways, that should probably be fixed separately.

This author/creator/artist/user stew is thoroughly annoying

Yeah. This is the mess you get when the data model of the app and that returned by the server don't align well. 🤷‍♂️

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not particularly happy with this PR. Why did we bother extracting the contents of the anchor tag, removing the page does not exist suffix only to add and use a new different field?
Why is DeleteHelper still trying to remove page does not exist?

This new field gets assigned like sessionManager.getAuthorName(), sessionManager.getUserName(), and having these 2 identical damned methods beside each other adds more to confusion making them seem like separate things.

I think adding user is a mistake and perhaps the only changes in this PR should be getArtist and get rid of the suffix removal in DeleteHelper.

Viewed in browser the author field is, I believe, whatever we sent in author=[[User:myUserName|userName again?]]
image
And we should not differ from the website

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Though I guess uploadedBy is information that isn't explicitly mentioned anywhere on the website? I'll seek confirmation on the ticket

Copy link
Member

@sivaraam sivaraam Apr 16, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not particularly happy with this PR. Why did we bother extracting the contents of the anchor tag, removing the page does not exist suffix only to add and use a new different field?

Because if we don't then the (page does not exist) would still show up in the detail view of the images you view via 'Explore'. The new field is to just show the username near the "Uploaded by:". We still show the "Author" in the media detail view.

Why is DeleteHelper still trying to remove page does not exist?

Thanks for bringing that up! We can remove that code now. cc @318anushka.
It really should've been caught during the PR that added that code. Looks like it slipped through.

Also, that's another place where the user would be the appropriate thing to use instead of the author/creator. Something to be done in a separate PR :)

This new field gets assigned like sessionManager.getAuthorName(), sessionManager.getUserName(), and having these 2 identical damned methods beside each other adds more to confusion making them seem like separate things.

Yeah. I think we can just go with user, user for that part instead of sessionManager.getAuthorName(), user. There's not much difference as of now like you point out.

I think adding user is a mistake and perhaps the only changes in this PR should be getArtist and get rid of the suffix removal in DeleteHelper.

I would say it's a "boon" for the reasons I mention above. You'll likely get more info about this in the issue thread where you've asked Nicolas for clarification. Let me know if you're still find some mistakes with introducing user. I'll see if I could clarify :)

Viewed in browser the author field is, I believe, whatever we sent in author=[[User:myUserName|userName again?]]
image
And we should not differ from the website

Do you mean we shouldn't be doing any kind of extraction from anchor tag for the Author? If yes, then I agree. It's best if show it similar to how the website shows the Author. But it would be a more involved change and is out of scope of this PR.

The HTML fiddling has it's limitations such as the "Author" field not being shown in the detail view for some images. I believe this fiddling with the HTML came into picture as we needed a username that we could use as a simple string for use in other places.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one reason it's getting quite confusing is because we are having different names for same field. How about we keep only 2 user and author for now, replacing creator with author. All of this including changes you mentioned above could be done in separate pr after this.

Also i was just waiting for nicolas's input, thought to make changes after clarifying.

@318anushka
Copy link
Contributor Author

318anushka commented Apr 9, 2020 via email

@neslihanturan
Copy link
Collaborator

This discussion is too long here, but I am sure @sivaraam and @macgills are pointing the correct issues. Despite so much effort of everyone we can't let this PR go to sleep:D @318anushka can you fix conflicts, are there anything else needs to be done?

@318anushka
Copy link
Contributor Author

Yeah, actually there is an ongoing discussion on what field to reflect in uploadedBy.
And looks like everyone agrees to @sivaraam points starting here

@sivaraam @macgills should i proceed with solving conflicts? I guess there are some more changes that needs to be done. could you please tell me what to do further.

@macgills
Copy link
Contributor

It might be easier to start over than resolve the conflicts, there has been quite a large change with the merging of structured data

@318anushka
Copy link
Contributor Author

Sounds better!! okay so current changes are fine, i'll fix the rest.
Closing this PR now.

@318anushka 318anushka closed this Apr 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"Page does not exist" near some usernames in Explore
5 participants