|
Post by hazelorb on Mar 15, 2010 21:32:12 GMT -5
Okay, so I'm at 4,913 entries at this point. Anyways was that 5000 D&R entries bug ever fixed? If so I'm going to port the code into my GM asap. If not I'm going to fix it and post the code here. Not sure how much of a fix is needed, if it should just get the current number of entries and loop less than that or if there was a reason for 5000? Anyways keep me posted...
|
|
|
Post by stryker on May 3, 2010 5:12:10 GMT -5
Wow - that's a huge pile of entries you have there. I had not heard of that bug before reading your post.
|
|
|
Post by hazelorb on Jun 7, 2010 16:52:04 GMT -5
Okay, here is it, as I am currently at 4997 and this needed to be done.
I still use GM1.21b. In GM.cgi, replace
$oldentrynumbercount = $newentrynumber; $countentriesfromhere = 5000; $foundtopentry = "no";
do { $countentriesfromherepadded = sprintf ("%8d", $countentriesfromhere); $countentriesfromherepadded =~ tr/ /0/; if (-e "$EntriesPath/$countentriesfromherepadded.cgi") { $newentrynumber = $countentriesfromhere; $foundtopentry = "yes"; } $countentriesfromhere--; if ($countentriesfromhere eq "0") { $newentrynumber = 0; $foundtopentry = "yes"; } } until $foundtopentry eq "yes";
with this:
#-----------------------------D&R 5000 (5k) bug fix------------------------- # Lesley Hogan; bunnie[@]bunnie.net; June 6 2010 #-----------------------------------Notes----------------------------------- #-- Bug originally made GM overwrite entries >5000 #-- Legacy code left in with tweak for variable consistency in later code #-- Deleted ridiculous do-while -e loop; replaced with sort grep #-- New limit of 99999999 via regular expressions #---------------------------------------------------------------------------
#legacy code $oldentrynumbercount = $newentrynumber; $countentriesfromhere = 9999; #minor tweak... $foundtopentry = "no";
#new code opendir (DRFIVEK, "$EntriesPath") || die ("$EntriesPath cannot be opened.");#dangermouse? @grep5k = grep /^[0-9]{8}\.cgi$/, readdir DRFIVEK; closedir DRFIVEK;
$foundtopentry = "yes"; if (scalar(@grep5k) == 0) { $countentriesfromhere = 0; $countentriesfromherepadded = "00000000"; #elusive 00000000.cgi } else { $drfivekfile = (sort {$b <=> $a} @grep5k)[0]; ($countentriesfromherepadded) = $drfivekfile =~ /([0-9]{8})/; #new limit: 99999999 = 0*[1-9][0-9]* ($countentriesfromhere) = $countentriesfromherepadded =~ /^0*([1-9][0-9]*)$/; #potential pitfalls: missing entries } $newentrynumber = $countentriesfromhere; #end legacy and new code
I have nothing kind to say about the old code....... Noah Grey was clearly just learning Perl when he wrote this software, and it really shows there! use strict anyone?
The original code might also be a modified do-until loop if you added the 00000000.cgi fix implemented a few years ago which was showing up when D&R was run with no entries if I remember correctly.
I tested this with Perl 5.8.8 on my site with 4997 entries and D&R ran perfectly.
I question some of my consistency with Noah Grey, ie dangermouse vs die. Possible pitfalls include the 00000000.cgi thing as well as any missing entries (this version opts for the latest [0-9]{8}.cgi instead of just scalar(grep...) in case a 00000000.cgi exists (entrynumber would be smaller than scalar, 1 less in fact, so it would then overwrite your most recent entry) or missing entries (in which case the entrynumber would be bigger than scalar).
Finally, I found no other places where 5000 appeared in gm.cgi, gm-library.cgi, gm-comments.cgi, or gm-upload.cgi fwiw.
|
|
|
Post by hazelorb on Jun 7, 2010 16:56:38 GMT -5
Also that might be a bug if your only entry is 00000000.cgi but you have some issues if that is true
|
|