(Go: >> BACK << -|- >> HOME <<)

Page MenuHomePhabricator

Maintenance script for purging old translation drafts that can be run manually by deployers
Closed, ResolvedPublic

Description

As part of the efforts to remove very old drafts from the CX database (T183890), it would be useful to have a maintenance script that can be run manually by deployers.

Some considerations for the script:

  • Has a --really option to disable dry-run (default)
  • Has --age-in-days X option to select drafts older than X
  • Updates database by purging cx_drafts and metadata as if the user had deleted them.
  • Sends a notification (one per user) about deleted drafts using the class from T184268

Event Timeline

Change 422477 had a related patch set uploaded (by Nikerabbit; owner: Nikerabbit):
[mediawiki/extensions/ContentTranslation@master] Add a script to purge old unpublished drafts

https://gerrit.wikimedia.org/r/422477

Change 422477 merged by jenkins-bot:
[mediawiki/extensions/ContentTranslation@master] Add a script to purge old unpublished drafts

https://gerrit.wikimedia.org/r/422477

Nikerabbit updated the task description. (Show Details)
Nikerabbit moved this task from In Review to QA on the Language-2018-Jan-Mar board.

Please move back to Maintenance Backlog (or Blocked) once verified for the last part.

I'll test script in Labs and Beta for QA.

@Nikerabbit I tried the script (not with the --really option). It does not seem to accept (or throw an error) on age-in-days value.

@deployment-tin:/srv/mediawiki/php-master/extensions/ContentTranslation/scripts$ php purge-unpublished-drafts.php --age-in-days=abc
No MWMultiVersion instance initialized! MWScript.php wrapper not used?
@deployment-tin:/srv/mediawiki/php-master/extensions/ContentTranslation/scripts$ php purge-unpublished-drafts.php --age-in-days=730
No MWMultiVersion instance initialized! MWScript.php wrapper not used?

No MWMultiVersion instance initialized! MWScript.php wrapper not used?

This script need mwscript to run. eg.

mwscript extensions/ContentTranslation/scripts$ php purge-unpublished-drafts.php --wiki=enwiki --age-in-days=365

I tested script locally and in Beta and it worked as expected.

kartik@deployment-tin:/srv/mediawiki/php-master$ mwscript extensions/ContentTranslation/scripts/purge-unpublished-drafts.php --wiki=eswiki --age-in-days=1200
Selecting drafts with last modified timestamp older than 2014-12-19T00:00:00+00:00
Found 18 purgeable drafts
DRY-RUN mode: drafts are not purged unless you add --really
      14 2014-12-06T04:58:00+00:00 es→ca       Rolli de Génova
      15 2014-12-07T03:11:38+00:00 es→pt       Hebe de Bonafini
      22 2014-12-08T14:17:35+00:00 pt→es       16 Dias de Ativismo contra a Violência de Gênero
      30 2014-12-08T18:42:15+00:00 es→ca       Iglesia parroquial de Nuestra Señora de la Asunción de Montesa
      33 2014-12-08T22:16:04+00:00 es→ca       Norman Loftus Bor
      67 2014-12-10T09:52:26+00:00 es→pt       Santiago Castroviejo
     130 2014-12-11T23:19:05+00:00 en→he       Australia
     185 2014-12-13T17:53:38+00:00 es→ca       Coplas por la muerte de su padre
     326 2014-12-13T20:57:24+00:00 es→ca       Museo Nacional de Diseño Cooper-Hewitt
      89 2014-12-13T22:55:21+00:00 pt→hy       Cup
     362 2014-12-14T07:38:45+00:00 es→ca       Superenalotto
     377 2014-12-14T17:40:38+00:00 ca→es       Eduard Toda i Güell
     400 2014-12-15T10:59:54+00:00 es→ca       Corina Crețu
     426 2014-12-15T22:12:39+00:00 es→ca       Casa Malaparte
     462 2014-12-17T05:57:40+00:00 es→pt       Tentamen Pteridographiae
     474 2014-12-17T06:36:07+00:00 es→pt       Alpinia conchigera
     611 2014-12-18T08:39:06+00:00 es→pt       Ma
     692 2014-12-18T13:06:59+00:00 es→ca       Rrröööaaarrr
Done!
kartik@deployment-tin:/srv/mediawiki/php-master$ mwscript extensions/ContentTranslation/scripts/purge-unpublished-drafts.php --wiki=eswiki --age-in-days=1200 --really
Selecting drafts with last modified timestamp older than 2014-12-19T00:00:00+00:00
Found 18 purgeable drafts
      14 2014-12-06T04:58:00+00:00 es→ca       Rolli de Génova — PURGED
      15 2014-12-07T03:11:38+00:00 es→pt       Hebe de Bonafini — PURGED
      22 2014-12-08T14:17:35+00:00 pt→es       16 Dias de Ativismo contra a Violência de Gênero — PURGED
      30 2014-12-08T18:42:15+00:00 es→ca       Iglesia parroquial de Nuestra Señora de la Asunción de Montesa — PURGED
      33 2014-12-08T22:16:04+00:00 es→ca       Norman Loftus Bor — PURGED
      67 2014-12-10T09:52:26+00:00 es→pt       Santiago Castroviejo — PURGED
     130 2014-12-11T23:19:05+00:00 en→he       Australia — PURGED
     185 2014-12-13T17:53:38+00:00 es→ca       Coplas por la muerte de su padre — PURGED
     326 2014-12-13T20:57:24+00:00 es→ca       Museo Nacional de Diseño Cooper-Hewitt — PURGED
      89 2014-12-13T22:55:21+00:00 pt→hy       Cup — PURGED
     362 2014-12-14T07:38:45+00:00 es→ca       Superenalotto — PURGED
     377 2014-12-14T17:40:38+00:00 ca→es       Eduard Toda i Güell — PURGED
     400 2014-12-15T10:59:54+00:00 es→ca       Corina Crețu — PURGED
     426 2014-12-15T22:12:39+00:00 es→ca       Casa Malaparte — PURGED
     462 2014-12-17T05:57:40+00:00 es→pt       Tentamen Pteridographiae — PURGED
     474 2014-12-17T06:36:07+00:00 es→pt       Alpinia conchigera — PURGED
     611 2014-12-18T08:39:06+00:00 es→pt       Ma — PURGED
     692 2014-12-18T13:06:59+00:00 es→ca       Rrröööaaarrr — PURGED
Done!

Thanks, @KartikMistry - I forgot about mwscript part. I checked the purged translations - after the script was run, the articles became available for translations again. The translation status is changed to translation_status: deleted. Closing the ticket.

Please move back to Maintenance Backlog (or Blocked) once verified for the last part.

Having a way to give that right to admins on a given wiki may be useful; a user asked me about getting the right to translate an article, already claimed by a banned user.

There is only a maintenance script. There is no user interface for deleting drafts.