matej_suchanek created this task.
matej_suchanek triaged this task as "High" priority.
matej_suchanek added a project: Pywikibot.
Restricted Application added subscribers: pywikibot-bugs-list, Aklapper.

TASK DESCRIPTION
  Demonstrated on `listpages.py`.
  
  name=scripts/listpages.py
    page_target.text = text
    page_target.save(summary=summary)
  
  - `Page.text.setter` updates the `Page._text` attribute with the new content
  - `Page.save` calls `Page._save` internally
  - `Page._save` calls `Page._cosmetic_changes_hook`
  - `Page._cosmetic_changes_hook` calls `Page.content_model` (new after 
rPWBC94a3f39a038a87e7516e55a253423609694d5342 
<https://phabricator.wikimedia.org/rPWBC94a3f39a038a87e7516e55a253423609694d5342>)
  - `Page.content_model` cannot use cached information because it hasn't been 
loaded yet (when `-overwrite` is used), so it calls `APISite.loadpageinfo` -> 
`APISite._update_page` -> `pywikibot.data.api.update_page`
  - `pywikibot.data.api.update_page` does `del page.text` which unconditionally 
deletes `Page._text` (the text saved in `page_target.text = text`)
  
  The last step is the problem: `APISite.loadpageinfo` deletes the useful 
content.
  
  Workarounds:
  
  - (for users) disable cosmetic changes
  - (for developers) always completely initialize the page object before 
updating its content
  
  Quick fix: revert rPWBC94a3f39a038a87e7516e55a253423609694d5342 
<https://phabricator.wikimedia.org/rPWBC94a3f39a038a87e7516e55a253423609694d5342>
 (or just remove the `content_model` check).

TASK DETAIL
  https://phabricator.wikimedia.org/T260472

EMAIL PREFERENCES
  https://phabricator.wikimedia.org/settings/panel/emailpreferences/

To: matej_suchanek
Cc: Xqt, Aklapper, matej_suchanek, pywikibot-bugs-list, JohnsonLee01, SHEKH, 
Dijkstra, Khutuck, Zkhalido, Viztor, Wenyi, Tbscho, MayS, Mdupont, JJMC89, 
Dvorapa, Altostratus, Avicennasis, mys_721tx, jayvdb, Masti, Alchimista, Rxy
_______________________________________________
pywikibot-bugs mailing list
pywikibot-bugs@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/pywikibot-bugs

Reply via email to