-
Notifications
You must be signed in to change notification settings - Fork 239
Different tracking of admin/public actions #1442
Description
VersionPress currently differentiates requests made from WordPress administration and public frontend.
versionpress/plugins/versionpress/src/Git/Committer.php
Lines 89 to 103 in e220983
| if (is_user_logged_in() && is_admin()) { | |
| $currentUser = wp_get_current_user(); | |
| /** @noinspection PhpUndefinedFieldInspection */ | |
| $authorName = $currentUser->display_name; | |
| /** @noinspection PhpUndefinedFieldInspection */ | |
| $authorEmail = $currentUser->user_email; | |
| } else { | |
| if (defined('WP_CLI') && WP_CLI) { | |
| $authorName = GitConfig::$wpcliUserName; | |
| $authorEmail = GitConfig::$wpcliUserEmail; | |
| } else { | |
| $authorName = "Non-admin action"; | |
| $authorEmail = "nonadmin@example.com"; | |
| } | |
| } |
But there are several related problems:
- For example comments made by registered users (even by administrators) SOMETIMES create authored commits (when working in WordPress administration) and sometimes not (when working on frontend). But commit message is always same with particular user: "Created comment
by user adminfor post Hello world". - Ajax requests are ALWAYS commited with authenticated users (even if on frontend), because are made through WordPress administration.
- REST requests are NEVER commited with authenticated users (see our related problem with Gutenberg in issue Support WordPress 5.0 (especially Gutenberg) #1387), but only as "Non-admin action". And there is no automatic way how to differentiate admin/public actions, except custom solution for every plugin (see for example solution for VersionPress: Wrong username in commit #817).
Solution?
-
I would suggest to remove current admin/public differences and simplify it to "action done by registered user = authored commit". I do not see any reason to preserve current solution. On the other hand, I would love to see for example "request type" information (Ajax, REST, Gutenberg) stored inside commits in the future (see Using source and type of requests #691).
-
Or we can simply allow Gutenberg requests to be commited with authenticated users and let it be for now with all disadvanatges mentioned earlier.