Page MenuHomePhabricator

Pywikibot makes extra network request even if diff is empty
Open, Needs TriagePublicBUG REPORT

Description

Steps to replicate the issue (include links if applicable):

  • item = pywikibot.ItemPage(site, "Q1")
  • item.editEntity()

What happens?: A network request is made.

What should have happened instead?: The method should have done nothing.

Software version (skip for WMF-hosted wikis like Wikipedia): pywikibot 8.6.0

Other information (browser name/version, screenshots, etc.):

Event Timeline

@RPI2026F1 Cannot follow this task, could you please explain a bit more. What is meant with diff is empty? What would be the reason not to make a request call if we have a site? I guess you mean the editEntity() call without any parameters?

@RPI2026F1 Cannot follow this task, could you please explain a bit more. What is meant with diff is empty? What would be the reason not to make a request call if we have a site? I guess you mean the editEntity() call without any parameters?

editEntity() has a function where if you call it without any parameters, it will make a "diff" of the item from the server and what's stored internally, and then send this diff to Wikidata. However, if the item wasn't changed at all, the diff will be an empty dictionary.

What is the motivation behind the procedure?

item = pywikibot.ItemPage(site, "Q1")
item.editEntity()

Obviously this is not something I would do intentionally, but in a large script is it very possible for one section of code to add a property and another section of code to remove that property, and then the diff becomes empty.

An alternative that would work is if I can query the diff publicly. Taking a look at the internal code, it uses private variables, so there's no easy way to get the diff in a "safe" way.