Skip to content
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

Different tracking of admin/public actions #1442

Open
pavelevap opened this issue May 10, 2019 · 1 comment · May be fixed by #1449
Open

Different tracking of admin/public actions #1442

pavelevap opened this issue May 10, 2019 · 1 comment · May be fixed by #1449
Labels
improvement Improvement of an existing functionality. See "feature" for new features. scope: core Core VersionPress functionality like tracking actions, creating Git commits, etc.

Comments

@pavelevap
Copy link
Collaborator

pavelevap commented May 10, 2019

VersionPress currently differentiates requests made from WordPress administration and public frontend.

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 admin for 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.

@pavelevap pavelevap added improvement Improvement of an existing functionality. See "feature" for new features. scope: core Core VersionPress functionality like tracking actions, creating Git commits, etc. labels May 10, 2019
@borekb
Copy link
Member

borekb commented May 10, 2019

I'm in favor of solution no. 1.

@pavelevap pavelevap linked a pull request May 14, 2019 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvement Improvement of an existing functionality. See "feature" for new features. scope: core Core VersionPress functionality like tracking actions, creating Git commits, etc.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants