Skip to content
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

Media details categories editor: Category not actually added #4278

Closed
Prince-kushwaha opened this issue Feb 24, 2021 · 14 comments · Fixed by #4328
Closed

Media details categories editor: Category not actually added #4278

Prince-kushwaha opened this issue Feb 24, 2021 · 14 comments · Fixed by #4328

Comments

@Prince-kushwaha
Copy link
Contributor

Summary:

when Add category to any (image,video) it show in add in categories(MedailDetail)
But when re again open current image medailDetail it not show in categories its mean it is not upload to database

Steps to reproduce:
See in Screenshot

Device and Android version:
Android Device:Redmi 4
API :28
Commons app version:
Latest master (3.0.0)
Screen-shots:

Screenrecorder-2021-02-24-23-17-22-854.mp4

Would you like to work on the issue?
YES
Please let us know whether you want to fix the issue by yourself. If not, anyone can get the issue assigned to them.
YES

@Prince-kushwaha Prince-kushwaha changed the title when Add category to any(image ,video) Notification always show: Category Update :Could not add categories or not Upload when Add category to any(image ,video) Notification always show: Category Update :Could not add categories Feb 25, 2021
@Prince-kushwaha
Copy link
Contributor Author

@nicolas-raoul can i work on this issue

@Prince-kushwaha
Copy link
Contributor Author

@nicolas-raoul @misaochan can i work on this issue

@misaochan
Copy link
Member

Have you checked to see if the categories were actually added to Commons, by looking at the upload in your browser? That would help figure out if the categories were genuinely not added, or if they were added but there is a bug in media details that does not fetch/display them.

@nicolas-raoul
Copy link
Member

I tried a few times, and can see that the category is actually not added.
For instance, I added category "Bakeries" to https://commons.wikimedia.org/wiki/File:Last_day_of_Mitsukoshi_at_Ebisu_Garden_Place_8.jpg but I can see nothing recent in history: https://commons.wikimedia.org/w/index.php?title=File:Last_day_of_Mitsukoshi_at_Ebisu_Garden_Place_8.jpg&action=history

@nicolas-raoul nicolas-raoul changed the title when Add category to any(image ,video) Notification always show: Category Update :Could not add categories Media details categories editor: Category not actually added Mar 3, 2021
@Prince-kushwaha
Copy link
Contributor Author

@nicolas-raoul
@FormUrlEncoded @Headers("Cache-Control: no-cache") @POST(Service.MW_API_PREFIX + "action=edit") fun postAppendEdit( @Field("title") title: String, @Field("summary") summary: String, @Field("appendtext") appendText: String, @Field("token") token: String ): Observable<Edit>
how i test this Post request locally on my browser
can we explain how this http POST request work and what this POST request return

@Prince-kushwaha
Copy link
Contributor Author

@misaochan @neslihanturan
@FormUrlEncoded @Headers("Cache-Control: no-cache") @POST(Service.MW_API_PREFIX + "action=edit") fun postAppendEdit( @Field("title") title: String, @Field("summary") summary: String, @Field("appendtext") appendText: String, @Field("token") token: String ): Observable<Edit>
how i test this Post request locally on my browser
can we explain how this http POST request work and what this POST request return

@nicolas-raoul
Copy link
Member

Adding a category means editing the image's page (example) to append something like [[Category:Bakeries]] at the end of it.

Here is the documentation to edit a page: https://www.mediawiki.org/wiki/API:Edit

@Prince-kushwaha
Copy link
Contributor Author

@nicolas-raoul @misaochan @neslihanturan what is csrfTokenClient.tokenBlocking
or what is csrfToken or token

@nicolas-raoul
Copy link
Member

@Prince-kushwaha Please first tell us everything you understand about it, so that we can start from there or correct your understanding if needed :-)

@Prince-kushwaha
Copy link
Contributor Author

@nicolas-raoul @misaochan
fun appendEdit(pageTitle: String, appendText: String, summary: String): Observable<Boolean> { return try { pageEditInterface.postAppendEdit(pageTitle, summary, appendText, csrfTokenClient.tokenBlocking) .map { editResponse -> editResponse.edit()!!.editSucceeded() } } catch (throwable: Throwable) { Observable.just(false) } }

At runtime when compiler try to access value of csfrTokenClient.tokenBlocking in above code then it thrown the exception
due which upload category process stop and category does not upload and catch block return Observable.just(false)
so can you tell me what is csrfTokenClient.tokenBlocking
or what is csrfToken or token

@Prince-kushwaha
Copy link
Contributor Author

@nicolas-raoul below code is in file :PageEditClient.kt in actions folder

  fun appendEdit(pageTitle: String, appendText: String, summary: String): Observable<Boolean> {
        return try {
            pageEditInterface.postAppendEdit(pageTitle, summary, appendText, csrfTokenClient.tokenBlocking)
                .map { editResponse -> editResponse.edit()!!.editSucceeded() }
        } catch (throwable: Throwable) {
            Observable.just(false)
        }
    }

@nicolas-raoul
Copy link
Member

Have you read about CSRF? See https://stackoverflow.com/questions/5207160/what-is-a-csrf-token-what-is-its-importance-and-how-does-it-work
Please add log debug lines, just before the postAppendEdit, and before the equivalent post call used when uploading (which works and probably uses CSRF too).

@4D17Y4
Copy link
Collaborator

4D17Y4 commented Apr 4, 2021

I can reproduce this on master,
While uploading the categories are added without any issue but adding categories to the images does not work as intended.
Additionally, on add categories dialog, the back button is not configured properly and triggers the back of media detail.

I would like to work on this one if no one is working on it.

@nicolas-raoul
Copy link
Member

@Prince-kushwaha Since you are working on another issue, I take the liberty to reassign this one, thank you for your understanding :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants