Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion WikiClientLibrary/Generators/Primitive/WikiList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ protected virtual void OnEnumItemsFailed(Exception exception)
/// </exception>
public async IAsyncEnumerable<T> EnumItemsAsync([EnumeratorCancellation] CancellationToken cancellationToken = default)
{
var baseQueryParams = new Dictionary<string, object?> { { "action", "query" }, { "maxlag", 5 }, { "list", ListName } };
var baseQueryParams = new Dictionary<string, object?> { { "action", "query" }, { "list", ListName } };
foreach (var p in EnumListParameters())
baseQueryParams.Add(p.Key, p.Value);
cancellationToken.ThrowIfCancellationRequested();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ public IAsyncEnumerable<T> EnumItemsAsync(CancellationToken cancellationToken =
var queryParams = new Dictionary<string, object?>
{
{ "action", "query" },
{ "maxlag", 5 },
{ "titles", PageTitle },
{ "prop", PropertyName },
};
Expand Down
1 change: 0 additions & 1 deletion WikiClientLibrary/Generators/QueryPageGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ public async Task<QueryPageResultInfo> GetQueryPageResultInfoAsync(CancellationT
new
{
action = "query",
maxlag = 5,
list = "querypage",
qppage = QueryPageName,
qplimit = 1,
Expand Down
3 changes: 0 additions & 3 deletions WikiClientLibrary/Pages/WikiPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,6 @@ private async Task<bool> EditAsync(WikiPageEditOptions options, string? sectionI
minor = options.Minor,
bot = options.Bot,
recreate = true,
maxlag = 5,
basetimestamp = LastRevision?.TimeStamp,
watchlist = options.Watch,
summary = options.Summary,
Expand Down Expand Up @@ -541,7 +540,6 @@ public async Task MoveAsync(string newTitle, string? reason, PageMovingOptions o
from = PageStub.HasTitle ? PageStub.Title : null,
fromid = PageStub.HasTitle ? null : (int?)PageStub.Id,
to = newTitle,
maxlag = 5,
movetalk = (options & PageMovingOptions.LeaveTalk) != PageMovingOptions.LeaveTalk,
movesubpages = (options & PageMovingOptions.MoveSubpages) == PageMovingOptions.MoveSubpages,
noredirect = (options & PageMovingOptions.NoRedirect) == PageMovingOptions.NoRedirect,
Expand Down Expand Up @@ -607,7 +605,6 @@ public async Task<bool> DeleteAsync(string reason, AutoWatchBehavior watch, Canc
token = WikiSiteToken.Delete,
title = PageStub.HasTitle ? PageStub.Title : null,
pageid = PageStub.HasTitle ? null : (int?)PageStub.Id,
maxlag = 5,
watchlist = watch,
reason = reason,
}), cancellationToken);
Expand Down
7 changes: 7 additions & 0 deletions WikiClientLibrary/Sites/SiteOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ public class SiteOptions
/// <remarks>Defaults to <see cref="AccountAssertionBehavior.AssertAll"/>.</remarks>
public AccountAssertionBehavior AccountAssertion { get; set; } = AccountAssertionBehavior.AssertAll;

/// <summary>
/// Gets/sets the maximum lag allowed for the requests (in seconds).
/// </summary>
/// <remarks>Defaults to 5 seconds.</remarks>
/// <seealso href="https://www.mediawiki.org/wiki/Manual:Maxlag_parameter"/>
public int? MaxLag { get; set; } = 5;

/// <summary>
/// Initializes with empty settings.
/// </summary>
Expand Down
6 changes: 6 additions & 0 deletions WikiClientLibrary/Sites/WikiSite.cs
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,12 @@ public async Task<T> InvokeMediaWikiApiAsync<T>(WikiRequestMessage message, IWik
AccountAssertionBehavior.AssertUser && _AccountInfo.IsUser)
newFields.Add("assert", "user");
}
// Apply maxlag
if (options.MaxLag != null)
{
newFields.Add("maxlag", options.MaxLag.GetValueOrDefault());
}

localRequest = new MediaWikiFormRequestMessage(form.Id, newFields, form.AsMultipartFormData);
}
Logger.LogDebug("Sending request {Request}, SuppressAccountAssertion={SuppressAccountAssertion}",
Expand Down
Loading