Legoktm has uploaded a new change for review.

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


Change subject: Add a script to remove expired drafts from the database
......................................................................

Add a script to remove expired drafts from the database

Bug: 19767
Change-Id: Iaa689e160e8b38d665356dfa23b051563e37fc4b
---
M Drafts.classes.php
A maintenance/removeExpired.php
2 files changed, 19 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Drafts 
refs/changes/69/89769/1

diff --git a/Drafts.classes.php b/Drafts.classes.php
index 8421ebc..171768d 100644
--- a/Drafts.classes.php
+++ b/Drafts.classes.php
@@ -66,12 +66,14 @@
        /**
         * Removes drafts which have not been modified for a period of time 
defined
         * by $egDraftsCleanRatio
+        *
+        * @param bool $rand whether to do it randomly
         */
-       public static function clean() {
+       public static function clean( $rand = true ) {
                global $egDraftsCleanRatio;
 
                // Only perform this action a fraction of the time
-               if ( rand( 0, $egDraftsCleanRatio ) == 0 ) {
+               if ( rand( 0, $egDraftsCleanRatio ) == 0 || !$rand ) {
                        // Get database connection
                        $dbw = wfGetDB( DB_MASTER );
                        // Removes expired drafts from database
diff --git a/maintenance/removeExpired.php b/maintenance/removeExpired.php
new file mode 100644
index 0000000..7738ab4
--- /dev/null
+++ b/maintenance/removeExpired.php
@@ -0,0 +1,15 @@
+<?php
+/**
+ * Really simple script to remove expired drafts from the database
+ */
+
+require_once( dirname( __FILE__ ) . "/Maintenance.php" );
+
+class RemoveExpired extends Maintenance {
+       public function execute() {
+               Drafts::clean( false ); // @todo make this query batched
+       }
+}
+
+$maintClass = 'RemoveExpired';
+require_once( RUN_MAINTENANCE_IF_MAIN );

-- 
To view, visit https://gerrit.wikimedia.org/r/89769
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iaa689e160e8b38d665356dfa23b051563e37fc4b
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Drafts
Gerrit-Branch: master
Gerrit-Owner: Legoktm <[email protected]>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to