Skip to content

Encourage non-conflicting edits #108

@Krinkle

Description

@Krinkle

When making changes to existing content (e.g. not appending or prepending text), it is important that bots don't accidentally overwrite edits by other users.

The way bots should do this to, when fetching the existing content, pass the revision timestamp to the edit module. This way, if another edit has been made since then, the edit will be rejected. At this point the bot can either try again, or skip the item for the time being.

mwbot provides a getArticle method, but it doesn't expose any meta data besides the page content.

Please provide an easy way for developers to use mwbot to make edits in a way that doesn't cause human edits to be overwritten by default. It should perhaps be an option to ignore conflicts, but by default it probably should not ignore conflicts.

Ideas:

// getPage(string name) -> API query revisions, rvprop=content|timestamp
client.getPage(name, function (err, data) {
  // data.title
  // data.content
  // data.timestamp

  var newContent = change(data.content);

  // Method 1: edit( pageName, content, summary, params, callback )
  client.edit(data.title, newContent, '', { basetimestamp: data.timestamp, fn(err,data) });

  // Method 2: edit( string|Object pageData, content, summary, calllback )
  client.edit(data, newContent, '', function (err, data) { });
});

The second method is probably easiest and encourages developers to use it without hardcoding details of parameters.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions