Skip to:
Content

BuddyPress.org

Opened 7 months ago

Closed 5 months ago

#8080 closed defect (bug) (fixed)

Data_export exports wrong data

Reported by: gingerbooch Owned by: imath
Milestone: 4.4.0 Priority: high
Severity: major Version: 4.1.0
Component: Messages Keywords: has-patch has-unit-tests commit
Cc:

Description

I am working on GDPR and Terms for a website.
I found a bug with the private messages’ data generated by the export data tool.
I have user1 and user2.
user1 sends a private message to user2.
user2 sends an answer to user1.
user1 answers again to user2.
Then I export data for both users.
In the private messages section, every messages retrieved are the same for both users. It only shows the text user1 wrote. Neither the text user2 wrote.

This tool should permit a user to see the data HE wrote to any others. And the delete data tool should allow that user to remove all the messages HE wrote to others too.
This is the case with user1. But user2 can only export the data user1 wrote to him. I did not try to delete user2´s data as this may remove user1’s data.

Attachments (2)

8080.unittest.patch (2.0 KB) - added by imath 5 months ago.
8080.patch (556 bytes) - added by imath 5 months ago.

Download all attachments as: .zip

Change History (13)

#1 @Venutius
7 months ago

From my own testing, I set up two users and each sent and email to the other. I then had each user reply to the others message. In the data export I could see that each user had two messages. Each message had the correct recipient id however the message content for one of these messages was actually the reply from the other.

So to summarise, the export data for messages initiated by the users actually contained the reply message content, even though the recipient id would indicate it was the initial message.

This leads me t suggest that it's not actually the export data function that is at fault but that the data being served by BP_Messages_Thread::get_current_threads_for_user() seems to be incorrect.

#2 @gingerbooch
7 months ago

With the tests I did, it seemed the tool only exports the original sender’s data. The one who created the thread.

#3 @Venutius
7 months ago

I've just done another test and the original problem I had has now corrected itself, Each user is seeing the correct results from exporting the data.

That indicates that this maybe more of a conflict issue. Let's take our conversation back to the forum and see if we can resolve your issue by other means.

#4 @gingerbooch
5 months ago

Hi @Venutius,

I finally found some time to make more tests on this issue.

What I did :

Install a fresh WordPress 5.1.1 on a test server.
Install Buddypress 4.3.0.
Create a user called “blue”.
Create a user called “red”.
Connect with “blue” and send a private message to “red” saying “Hello I am blue and I say blue”.
Connect with “red” and send a private message to “blue” saying “Hello I am red and I say red”.
Export Data for both “blue” and “red” users.

Result :
Export Data for user “blue” shows one message sent to recipient “red” with content : “Hello I am blue and I say blue”.
Export Data for user “red” shows one message sent to recipient “blue” with content : “Hello I am blue and I say blue”.

The result is the same on this fresh install. For both users in a thread, the Export Data only returns the private message data content wrote by the creator of the thread.

For your information, I am running WordPress with French language. However I don’t think this can be linked to my issue.

Can you try to reproduce this please ?
I still think it is a bug.

Thank you 🙂

#5 @imath
5 months ago

  • Keywords has-patch has-unit-tests reporter-feedback added
  • Milestone changed from Awaiting Review to 4.4.0

Hi @gingerbooch

Thanks for making some more tests about this. I confirm there's a bug as only messages sent by a user should be exported for this user.

It appears it's not the case as shows the unit test I'm attaching to this ticket (8080.unittest.patch).

I think 8080.patch is fixing the issue. I'll run some more tests later but if you can confirm it's fixing the issue for you, it would be great :)

@imath
5 months ago

#6 @gingerbooch
5 months ago

Hi @imath,

Thanks a lot for your support on this ticket.
How can I use your file please ? 😆

Thank you 🙏

#7 @imath
5 months ago

In this comment about another ticket I’m giving some explanations about how to apply a patch :
https://buddypress.trac.wordpress.org/ticket/8079

But if you can probably simply edit the file /bp-messages/bp-messages-functions.php at line 687 replacing:

if ( $recipient->user_id !== $message->sender_id ) {

by:

if ( $user->ID !== $message->sender_id ) {

Try to avoid doing it on a production site : it’s always safer to use a staging/testing site.

#8 @gingerbooch
5 months ago

Hi @imath,

Thanks for the code. I did it manually on my testing site. It is working the good way now, as far as I can see.

Thank you very much,

I will wait for the official update for my production sites.

Have a nice day 😊

#9 @imath
5 months ago

  • Keywords commit added; reporter-feedback removed

Thanks a lot for your confirmation @gingerbooch I'm going to run some complementary tests on my hand and will commit the patch in a few minutes.

PS: wise decision to wait for the official release 👌

#10 @imath
5 months ago

In 12402:

Make sure Messages exports only include the ones sent by the user

Using the $user->ID instead of the $recipients->ID to check for the sender ID is more reliable to make sure the generated zip Archive only contains messages sent by the requesting user.

Props gingerbooch, Venutius

See #8080 (branch 4.0)

#11 @imath
5 months ago

  • Owner set to imath
  • Resolution set to fixed
  • Status changed from new to closed

In 12403:

Make sure Messages exports only include the ones sent by the user

Using the $user->ID instead of the $recipients->ID to check for the sender ID is more reliable to make sure the generated zip Archive only contains messages sent by the requesting user.

Props gingerbooch, Venutius

Fixes #8080 (trunk)

Note: See TracTickets for help on using tickets.