Page MenuHomePhabricator

Check if the page content has changed before trying to save it (in Page.put)
Closed, DeclinedPublic


It seems that Page.put method always tries to send a web request to save the page, even if the newtext parameter is the same as the current text.

Although this can be done manually, I think it's still a good idea to compare page.text with the newtext parameter passed to page.put before trying to save it and avoid the unnecessary web request.

This simple comparison does not seem to cost much processing time at all, but in those cases that the user has not checked the change, it can reduce server load and improve script's speed a little bit.

Users that want to avoid this comparison will be able to use directly.

Event Timeline

Dalba raised the priority of this task from to Needs Triage.
Dalba updated the task description. (Show Details)
Dalba added projects: Pywikibot, good first task.
Dalba subscribed.
Dalba renamed this task from Check if the page content has changed (in Page.put) to Check if the page content has changed before trying to save it (in Page.put).Jan 1 2016, 6:11 AM
Dalba set Security to None.

This is a breaking change. Some users may send intentionally null edits to refresh server caches.

Oh, good point!
Even in that case, [[|forcerecursivelinkupdate]] seems a better choice to me, but maybe it's not worth it anymore. Should I mark this task as declined?

BasePage.purge() with forcerecursivelinkupdate should be preferred but some users may still be using BasePage.put() for the purpose. Although I'm not dismissing the proposed change at first glance, I don't think the framework should get in its users' way.

Change 312721 had a related patch set uploaded (by Vyeshwanth):
pywikibot.Page.put: checking the changes before saving

Some notes of my pov

  • as Ricordisamoa mentioned this would be a breaking change and unables null-edits
  • we would have a different behaviour for put() put_async() and save() but we should avoid this
  • user messages should be avoided in library parts except they are exceptions
  • put() and put_async() are more deprecated methods; save() should used instead
  • we have putting methods inside bot classes. If at all I guess this test should made inside put_current or userPut and have an additional option.

BaseBot.userPut() does it already.

@Vyeshwant123 Sorry about that!
I'd recommend you go ahead and find another bug to solve :)

Change 312721 abandoned by Xqt:
pywikibot.Page.put: checking the changes before saving

per T122715