-
Notifications
You must be signed in to change notification settings - Fork 18
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
Conflict with the Postie Plugin #370
Comments
Could you revert the following change and try again: ebc4ddf#diff-1e55d4d09272c1fe017db9ee8b1481cec1d995320b790781fedb4878484792aeR569 I think this will cause the issue. Because you are only identified as admin if there is an rest request. If this will not solve the issue it would be nice if you could older version of the plugin because you mentioned you used the both plugins for years and the worked. So the problem could be also related to changes made by Postie. |
Is there any specific procedure to go back to that previous version? I think it's a bit dangerous to make this change in production (I see there are many changes over there). I could checkout a specific tag for example but I think it's not a good idea to do this change in prod. The Postie author suggested me to try with UAM disabled. Could you please check this out and reply? |
@fbertini I already read the thread at the Postie plugin forum. So since I only edited minor things, the postie author too and you used both plugins for years without an issue, I think this could be the reason. And please do this at a test system. I think the problem is that you try to assign a restricted category, but since you are not logged in you don't have the permission to see the category and UAM filters the categories which are restricted. If the downgrade doesn't work I think I can not do much about it. The post should be created via Postie by the user which would do this at the backend, so this is nothing I can do about because that must happen within the Postie plugin. |
Thank you @GM-Alex Thanks! |
Hello, I tested the same functionality on my local test environment and I'm really surprised: it works without any downgrade/change to the code. Honestly I have no idea why this is happening in production. My only guess is that some data is different in production (I mean some configuration/relationship in the database). I could see this in the log file: INSERT INTO `wp_term_relationships` (`object_id`, `term_taxonomy_id`) VALUES (7193, 10)
INSERT INTO `wp_term_relationships` (`object_id`, `term_taxonomy_id`) VALUES (7193, 11) I still can't explain why if I disable UAM in production, this is working fine. |
Hi, I did some more analysis with regards this issue and found out that the following query is built when the wordpress SELECT DISTINCT t.term_id
FROM wp_terms AS t INNER JOIN wp_term_taxonomy AS tt ON t.term_id = tt.term_id INNER JOIN wp_term_relationships AS tr ON tr.term_taxonomy_id = tt.term_taxonomy_id
WHERE tt.taxonomy IN ('category') AND t.term_id NOT IN (10,29,30,31) AND tr.object_id IN (7196) Such "NOT IN" clause is added because of exclusions declared at line 484 and we go inside the first if block: if ( ! empty( $exclusions ) ) {
$exclusions = 't.term_id NOT IN (' . implode( ',', array_map( 'intval', $exclusions ) ) . ')';
} else {
$exclusions = '';
} So the question now is: is there any chance that User Access Manager has something to do with categories hiding so that the above NOT IN clause is built? I bet there is a difference on the database between the working one and production. |
Hi, |
I would say the problem is the hide post, term or what ever completely option. If Postie is not running as admin then all restricted objects are completely "hidden", which means they are not available because all queries are modified that the are not accessible. This would also explain why it works in manual mode and not in automatic mode:
https://wordpress.org/support/topic/no-category-and-wrong-author-after-posting/#post-16409566 Try to disable the "hide" option and if it works this is the reason. But if this it the reason I can do nothing about it. The Postie then must provide a way to simulate a logged in user during the automatic mode. |
What do mean for the "hide post" option? I couldn't find it on Postie or UAM. [info] Query: SELECT ID FROM wp_uam_accessgroups
[info] Query: SELECT *
FROM wp_uam_accessgroups
WHERE ID = 4
LIMIT 1
[info] Query: SELECT *
FROM wp_uam_accessgroups
WHERE ID = 5
LIMIT 1
[info] Query: SELECT *
FROM wp_uam_accessgroups
WHERE ID = 6
LIMIT 1
[info] Query: SELECT *
FROM wp_uam_accessgroups
WHERE ID = 7
LIMIT 1
[info] Query: SELECT group_id AS id, group_type AS type
FROM wp_uam_accessgroup_to_object
WHERE group_type IN ('role', 'user')
GROUP BY group_type, group_id
[info] Query: SELECT object_id AS id, object_type AS objectType, from_date AS fromDate, to_date AS toDate
FROM wp_uam_accessgroup_to_object
WHERE group_id = '4'
AND group_type = 'UserGroup'
AND object_id != ''
AND (genera
[info] Query: SELECT term_id AS id, parent AS parentId, taxonomy AS type
FROM wp_term_taxonomy
WHERE parent != 0
[info] Query: SELECT object_id AS id, object_type AS objectType, from_date AS fromDate, to_date AS toDate
FROM wp_uam_accessgroup_to_object
WHERE group_id = '5'
AND group_type = 'UserGroup'
AND object_id != ''
AND (genera
[info] Query: SELECT object_id AS id, object_type AS objectType, from_date AS fromDate, to_date AS toDate
FROM wp_uam_accessgroup_to_object
WHERE group_id = '6'
AND group_type = 'UserGroup'
AND object_id != ''
AND (genera
[info] Query: SELECT object_id AS id, object_type AS objectType, from_date AS fromDate, to_date AS toDate
FROM wp_uam_accessgroup_to_object
WHERE group_id = '7'
AND group_type = 'UserGroup'
AND object_id != ''
AND (genera
[info] Query: SELECT object_id AS id, object_type AS objectType, from_date AS fromDate, to_date AS toDate
FROM wp_uam_accessgroup_to_object
WHERE group_id = '0'
AND group_type = 'user'
AND object_id != ''
AND (general_obj
[info] Query: SELECT object_id AS id, object_type AS objectType, from_date AS fromDate, to_date AS toDate
FROM wp_uam_accessgroup_to_object
WHERE group_id = '4'
AND group_type = 'UserGroup'
AND object_id != ''
AND (genera
[info] Query: SELECT object_id AS id, object_type AS objectType, from_date AS fromDate, to_date AS toDate
FROM wp_uam_accessgroup_to_object
WHERE group_id = '5'
AND group_type = 'UserGroup'
AND object_id != ''
AND (genera
[info] Query: SELECT object_id AS id, object_type AS objectType, from_date AS fromDate, to_date AS toDate
FROM wp_uam_accessgroup_to_object
WHERE group_id = '6'
AND group_type = 'UserGroup'
AND object_id != ''
AND (genera
[info] Query: SELECT object_id AS id, object_type AS objectType, from_date AS fromDate, to_date AS toDate
FROM wp_uam_accessgroup_to_object
WHERE group_id = '7'
AND group_type = 'UserGroup'
AND object_id != ''
AND (genera
[info] Query: SELECT object_id AS id, object_type AS objectType, from_date AS fromDate, to_date AS toDate
FROM wp_uam_accessgroup_to_object
WHERE group_id = '0'
AND group_type = 'user'
AND object_id != ''
AND (general_obj
[info] Query: SELECT object_id AS id, object_type AS objectType, from_date AS fromDate, to_date AS toDate
FROM wp_uam_accessgroup_to_object
WHERE group_id = '0'
AND group_type = 'user'
AND object_id != ''
AND (general_obj
[info] Query: SELECT object_id AS id, object_type AS objectType, from_date AS fromDate, to_date AS toDate
FROM wp_uam_accessgroup_to_object
WHERE group_id = '_none-role_'
AND group_type = 'role'
AND object_id != ''
AND (g Actually, the query that is executed just after the query above, doesn't have the "NOT IN" clause which is the cause of the problem I suppose: NOT OK: [info] Query:
SELECT DISTINCT t.term_id
FROM wp_terms AS t INNER JOIN wp_term_taxonomy AS tt ON t.term_id = tt.term_id INNER JOIN wp_term_relationships AS tr ON tr.term_taxonomy_id = tt.term_taxonomy_id
WHERE tt.taxonomy IN ('category') AND t.term_id NOT IN (10,29,30,31) AND tr.object_id IN (739 OK: [info] Query:
SELECT DISTINCT t.term_id
FROM wp_terms AS t INNER JOIN wp_term_taxonomy AS tt ON t.term_id = tt.term_id INNER JOIN wp_term_relationships AS tr ON tr.term_taxonomy_id = tt.term_taxonomy_id
WHERE tt.taxonomy IN ('category') AND tr.object_id IN (7405) Do you have an idea why and when the wp_uam_accessgroups is being accessed? I can't believe this table is accessed depending on the environment the website is running in! It sounds kind of weird to me 🤣 |
No way. It was already set to no. |
Also for categories and other types? |
Could you try setting "Hide empty" to "No"? |
Okay anyway the reason is the AccessHandler::getExcludedTerms function, this returns categories which should be excluded and so the query is adjusted. Changing that could lead to unwanted access so I will not change it. So the only way to make it work is run the job with the right user and this can only be done by the Postie plugin. |
Thank you very much for your suggestion. Just one last question before closing this issue: what do you mean by "right user"? Consider that I have a list containing the authorized e-mails to post contents; they are just two: one is linked to the admin user and one to another user with an administrator role. |
Hello @GM-Alex I started by querying the SELECT *
FROM wp_uam_accessgroup_to_object
WHERE object_id = 10 OR object_id = 11 Here's the output of the query: | object_id | general_object_type | object_type | group_id | group_type | from_date | to_date |
| --------- | ------------------- | ----------- | -------- | ---------- | --------- | ------- |
| 10 | _user_ | user | 5 | UserGroup | NULL | NULL |
| 10 | _term_ | _term_ | 5 | UserGroup | NULL | NULL |
| 10 | _term_ | _term_ | 6 | UserGroup | NULL | NULL |
| 11 | _user_ | user | 5 | UserGroup | NULL | NULL | As you can see, there are two "strange" entries having object_id = 10 that I removed to obtain the following data only if you repeat the select query above: | object_id | general_object_type | object_type | group_id | group_type | from_date | to_date |
| --------- | ------------------- | ----------- | -------- | ---------- | --------- | ------- |
| 10 | _user_ | user | 5 | UserGroup | NULL | NULL |
| 11 | _user_ | user | 5 | UserGroup | NULL | NULL | Now I was able to use Postie again and I think there was something wrong with the UAM database (probably it is due to the migration I have done from Wordpress 4.2 to 6.1.1 last year after running the UAM database fix tool). What do you think about this? Is there any other investigation I can do? |
I'm using Postie to add Posts on my Wordpress site since a long time ago.
I've been using Postie and UAM since at least 5 years without any issue but now I'm facing an annoying one.
On every new post created from an e-mail, a new article is created but the following parameter is not correct:
Let's describe with a practical example:
I have category having ID = 10 and tag with ID = 11.
For what I could see, every time a new post is created via Postie message,
the batch runs and it creates just one new row into the
wp_term_relationships
table.This means that I have only one new row with ID 11 only within this table for such new post. If I make a comparison to the posts having the category and tag being associated, I see this for the correct posts:
While I only see this one for the new post without the category:
I tried to manually insert a new entry into the
wp_term_relationships
table and could see the post correctly in the Admin panel (meaning that I can see both category and tag set as well as the author). This is equivalent to setting up the category in the admin panel.Basically the root cause is that the following INSERT is being skipped:
Could you please chack this out?
Thanks!
WordPress version: 6.1.1
Postie version: 1.9.64
User Access Manager: 2.2.19
The text was updated successfully, but these errors were encountered: