[Rt-commit] rt branch 5.0/vulnerable-passwords-page-users created. rt-5.0.3-293-g197b9a92bf

BPS Git Server git at git.bestpractical.com
Tue Mar 14 19:28:02 UTC 2023


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "rt".

The branch, 5.0/vulnerable-passwords-page-users has been created
        at  197b9a92bfd725b2c22c49ad3f9aef739215a876 (commit)

- Log -----------------------------------------------------------------
commit 197b9a92bfd725b2c22c49ad3f9aef739215a876
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Wed Mar 15 03:25:44 2023 +0800

    Page users to save memory in case there are too many records
    
    The FetchNext sub is stolen from etc/upgrade/shrink-cgm-table.

diff --git a/etc/upgrade/vulnerable-passwords.in b/etc/upgrade/vulnerable-passwords.in
index 4b9e9ff21f..1b9aeeedab 100644
--- a/etc/upgrade/vulnerable-passwords.in
+++ b/etc/upgrade/vulnerable-passwords.in
@@ -99,7 +99,8 @@ if ($count == 0) {
 
 if ($fix) {
     print "Upgrading $count users...\n";
-    while (my $u = $users->Next) {
+    FetchNext( $users, 'init' );
+    while ( my $u = FetchNext($users) ) {
         my $stored = $u->__Value("Password");
         my $raw;
         if (length $stored == 32) {
@@ -139,3 +140,19 @@ if ($fix) {
     print "\n", "Run again with --fix to upgrade.\n";
     exit 1;
 }
+
+use constant PAGE_SIZE => 10000;
+sub FetchNext {
+    my ( $objs, $init ) = @_;
+    if ($init) {
+        $objs->RowsPerPage(PAGE_SIZE);
+        $objs->FirstPage;
+        return;
+    }
+
+    my $obj = $objs->Next;
+    return $obj if $obj;
+    $objs->RedoSearch;
+    $objs->FirstPage;
+    return $objs->Next;
+}

-----------------------------------------------------------------------


hooks/post-receive
-- 
rt


More information about the rt-commit mailing list