This patch adds three things which are necessary for #864542: Replace old-style tokens with new token integration.

- Drops the custom sql query builder, load and load hook in favor of using a controller class
- Provides an URI callback that can build the path to a message
- Provides body, url and thread_id tokens

This doesn't have an direct visual changes, this is more a backend thing ;) However, testing is very important here. Tests passed for me locally, let's see what the bot has to say.

One way to actually test the URL stuff is to either use the new tokens or to build a rule that grants userpoints when a private message is sent and privatemsg_message is used as the referenced entity. Without this patch, the reason column is not linked to the message, with this patch, it is :)

Comments

BenK’s picture

Subscribing to help with testing...

Status: Needs review » Needs work

The last submitted patch, loading_tokens_uri.patch, failed testing.

berdir’s picture

Status: Needs work » Needs review
StatusFileSize
new17.84 KB

Updated patch, improved tokens.

Status: Needs review » Needs work

The last submitted patch, loading_tokens_uri2.patch, failed testing.

berdir’s picture

Status: Needs work » Needs review

#3: loading_tokens_uri2.patch queued for re-testing.

Status: Needs review » Needs work

The last submitted patch, loading_tokens_uri2.patch, failed testing.

berdir’s picture

Status: Needs work » Needs review
StatusFileSize
new17.84 KB

Trying to figure out what the actual exception is, see also #947874: Simpletest uses %message instead of !message for uncaught exceptions

berdir’s picture

StatusFileSize
new19.36 KB

Grml, new try.

Status: Needs review » Needs work

The last submitted patch, loading_tokens_uri4.patch, failed testing.

berdir’s picture

Status: Needs work » Needs review
StatusFileSize
new10.81 KB

New patch without the test changes, these were commited in another issue.

Status: Needs review » Needs work

The last submitted patch, loading_tokens_uri5.patch, failed testing.

berdir’s picture

Status: Needs work » Needs review
StatusFileSize
new10.95 KB

Grml. Debugged this literally for hours. Turns out, I just forgot to pass the constructed $conditions array to privatemsg_user_load_multiple(). This will be green!

Status: Needs review » Needs work

The last submitted patch, loading_tokens_uri6.patch, failed testing.

berdir’s picture

Status: Needs work » Needs review
StatusFileSize
new11.18 KB

Uh, left in a debug call.

BenK’s picture

Status: Needs review » Needs work

I tested using the following tokens in a private message: body, url and thread_id. Here's what I noticed:

a) All three tokens displayed as invalid to the sender, but they seemed to be replaced fine for the recipient.
b) For the body token, all carriage returns and line spacing seems to be missing from the message text. Basically, the body token appears to put the body text in one big paragraph that is smushed together.

I'll now test using the rules method you mentioned above.

--Ben

BenK’s picture

I did the following rules test just as you suggested:

build a rule that grants userpoints when a private message is sent and privatemsg_message is used as the referenced entity. Without this patch, the reason column is not linked to the message, with this patch, it is

It worked exactly as you described, with the reason link activated once I used the patch.

--Ben

berdir’s picture

Status: Needs work » Needs review
StatusFileSize
new13.92 KB

a) Only body shows up as invalid for me. I guess you used the body token inside the message body? That was a problem (it doesn't make sense anyway :)) with our token validation, I replaced it with the function provided by token.module now. That means that invalid token detection only works when token module is installed.

b) This is a tricky problem and we will have to change this somehow when mail tokens come into play. I formatted the body now according to the defined text format.

- I also noticed that entity.module does expose the defined properties as tokens. Some of them were actually showing up twice because of that. I fixed that by renaming our tokens so that they have the same name as the property (sent => timestamp, thread_id => thread-id). This would break existing messages that used the sent token, but I doubt that there are any :)

Status: Needs review » Needs work

The last submitted patch, loading_tokens_uri8.patch, failed testing.

berdir’s picture

Status: Needs work » Needs review
StatusFileSize
new14.73 KB

Ok, the test needs token.module now to work correctly.

This might work...

berdir’s picture

StatusFileSize
new15.24 KB

Ok, discussed this with boombatower, optional test dependencies are not supported yet, this is being worked on in #102102: Parse project .info files: present module list and dependency information. We need to add a test dependency to the .info and it should start working when the linked issue is resolved. Until then, the token test case will be silently ignored.

BenK’s picture

Status: Needs review » Reviewed & tested by the community

All reported issues on this thread are fixed for me. I'm marking this RTBC, but you can change the status if modifications will still need to be made to work in conjunction with the e-mail notify thread.

--Ben

berdir’s picture

Status: Reviewed & tested by the community » Fixed

Ok, committed. We can always fix bugs in the notify, I just wanted to split this (which is working fine for the most part) from the tricky notification stuff.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.