Skip to content
This repository was archived by the owner on Jul 28, 2024. It is now read-only.
This repository was archived by the owner on Jul 28, 2024. It is now read-only.

Different tracking of admin/public actions #1442

@pavelevap

Description

@pavelevap

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    improvementImprovement of an existing functionality. See "feature" for new features.scope: coreCore VersionPress functionality like tracking actions, creating Git commits, etc.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions