Modx User Messages Manager UI potentially broken Modx 2.7.3

Summary

In the Manager interface i tried to send a message to another user and pressed the send button, i know the database updated (i checked it manually and also have a REST API to read all user messages) The issue is that it does not show in the manager interface. I can’t see the messages and therefore cannot delete them.

Step to reproduce

Go into manager, go to view and send messages, send a message,

Observed behavior

Not showing in manager


Does show on my endpoint and is in database.

No Core files have been changed since installation all other interfaces are working as normal

Expected behavior

It should show in the manager

Environment

Modx 2.7.3
MySQL 5.6.49

Could you report that here if you haven’t already?

The MessageManager extra might help in the meantime (unless it has the same problem).

I was going to but i want to confirm if anyone else is able to produce it before i file it as an actual bug, I am due to update my modx install so i might give that a go first but in the mean time if anyone else has 2.7.3 it would be good to see if it happens for them also.

In the dropdown “Filter by type…” you have to select “Outbox” to see the messages you sent.

Hi Again

Unfortunately I’m getting the same result :frowning:

I logged in as another user and tried to send more messages and still not showing but my endpoint looks ok so the data is stored and the table in the database is updated also. Also no error in the error log from what i can see.

I tested it with MODX version 2.7.3 and I can’t reproduce your problems. Everything works fine on my installation.

When you open the “Network” tab in the developer tools of your browser and select “Outbox” in the dropdown, a new AJAX-request should be generated with the action “security/message/getlist”.
What is the response of this request?

The request executes this processor. So maybe you can try to debug it. For example by temporarily adding log-statements to the code.

public function prepareQueryBeforeCount(xPDOQuery $c)
{
	...
	
	//output the SQL-query for debugging purposes
	$c->prepare();
	$this->modx->log(modX::LOG_LEVEL_ERROR,'security/message/getlist: ' . $c->toSQL());
	
	return $c;
}

Had a litte bit of a play, and still can’t seem to nail down what is causing it.

added the error logging and it returned me the following SQL on load with the id “1” being my user id

[2021-01-09 02:59:35] (ERROR @ /var/www/html/core/model/modx/processors/security/message/getlist.class.php : 72) security/message/getlist: SELECT modUserMessage.id AS modUserMessage_id, modUserMessage.type AS modUserMessage_type, modUserMessage.subject AS modUserMessage_subject, modUserMessage.message AS modUserMessage_message, modUserMessage.sender AS modUserMessage_sender, modUserMessage.recipient AS modUserMessage_recipient, modUserMessage.private AS modUserMessage_private, modUserMessage.date_sent AS modUserMessage_date_sent, modUserMessage.read AS modUserMessage_read FROM modx_user_messages AS modUserMessage JOIN modx_users Sender ON modUserMessage.sender = Sender.id JOIN modx_users Recipient ON modUserMessage.recipient = Recipient.id JOIN modx_user_attributes SenderProfile ON SenderProfile.id = modUserMessage.sender JOIN modx_user_attributes RecipientProfile ON RecipientProfile.id = modUserMessage.recipient WHERE modUserMessage.recipient = 1

Also did a bit of checking on the network tab and seems to be returning a 200 and a result JSON that is empty for both outbox and inbox.

I’m tempted to just create a migxdb cmp and hook it up to the same package modx + classkey = modUserMessage and see if it pulls them through into that, because i seem to be able to see everything / be able to query everything from my REST endpoint for the same table

I just tested it on MODX 2.8.1 running PHP 7.4.3 and MySQL 8.0.22 and it’s working properly.

@nadakbar What happens when you run that SQL query that was returned in your error log? If you run that, it should tell you exactly what’s going wrong.

Hi again,

So attempted to use the SQL in phpmyadmin and it returned nothing, so went for a different route and quickly created a migxDB CMP to grab the data and it appears to be working as normal.

Is there a way in MigxDB for me to filter the grid so that it only shows items where recipient = logged in user id. I know i can set up filters manually, but can i set it so it only shows items in the grid for the logged in user when the CMP loads.

So the only thing i can think about the original messages CMP that its not getting the user id of the logged in user to grab all the messages for the grid

P.S i also updated modx to 2.8.1 in hopes it would replace any missing files etc but, no errors or bugs just a none populating messages section.

EDIT :
i figured out how to filter, inside the MIGXDB > settings section it has a “where” field i set it to 1 in this instance but i wonder if this field accepts modx parameters such as $modx->getUser();

image

I’m somewhat baffled that the SQL query in phpmyadmin doesn’t return results. That probably means that your users don’t have an entry in the database table modx_user_attributes (class modUserProfile).
So how exactly to you create your users?

I think you should be able to use a snippet call in the “Where” field, but I’m not quite sure.

{"sender":[[mySnippet]]}

Just had a look and the user attributes table, seems ok from what i can see, because isn’t that table required anyway for modx to store the sessionid etc and auth me into the manager?

here is a snippet

im pretty baffled myself considering that i have sort of replicated the functionality in migxdb (the where field does support snippets and I’m now showing a filtered view of only messages logged in user has sent).

EDITED / Updated

I may have accidentally (from trying to debug) created something a bit more suited for what i want to be honest.

Now that i have it Migx’d up i might stick with my current solution as i can now do a few extra things such as set the message field to richtext and control over the input types and prepopulate certain fields. I have split it out so i have an outbox and an inbox tab now (as i couldn’t get the combobox filter to work quickly that comes with migx without writing a bunch of snippets)

If i do ever figure out what is going on with my normal messages i will post my findings

You could do some testing in phpmyadmin:
You said that this query doesn’t return anything

SELECT * 
FROM modx_user_messages AS modUserMessage 
JOIN modx_users Sender ON modUserMessage.sender = Sender.id 
JOIN modx_users Recipient ON modUserMessage.recipient = Recipient.id 
JOIN modx_user_attributes SenderProfile ON SenderProfile.id = modUserMessage.sender 
JOIN modx_user_attributes RecipientProfile ON RecipientProfile.id = modUserMessage.recipient 
WHERE modUserMessage.recipient = 1

but this query probably will return something (because it is basically what your Migx CMP does)

SELECT * 
FROM modx_user_messages AS modUserMessage 
WHERE modUserMessage.recipient = 1

When you add the JOIN statements back to the query one after to other, which one breaks it?

Removing the following lines from your query returned a result in phpmyadmin

JOIN modx_user_attributes SenderProfile ON SenderProfile.id = modUserMessage.sender 
JOIN modx_user_attributes RecipientProfile ON RecipientProfile.id = modUserMessage.recipient 

Any insight why that might be?

Does it work with these Joins?

JOIN modx_user_attributes SenderProfile ON SenderProfile.internalKey = modUserMessage.sender 
JOIN modx_user_attributes RecipientProfile ON RecipientProfile.internalKey = modUserMessage.recipient

It think there might be a bug in the “security/message/getlist”-processor, that manifests itself if the columns id and internalKey of the table modx_user_attributes are not equal.

Hi Again

result! those joins seemed to do the trick, i have a result

Granted the data im trying to get is currently for my user with the id and an internal key of 1 but the rest of my users do not have matching columns

image

is there anything i can now mod in the getlist processor to make it work in the UI ?

UPDATED :

All done and working now for the original messages CMP

made the following modification to the getlist processor, path is in the screenshot

changed
SenderProfile.id to SenderProfile.internalKey
RecipientProfile.id to RecipientProfile.internalKey

phew! that was alot of digging for two lines of code, always seems to be the case haha

1 Like

This topic was automatically closed 2 days after discussion ended and a solution was marked. New replies are no longer allowed. You can open a new topic by clicking the link icon below the original post or solution and selecting “+ New Topic”.