Bug with 3.1 and Prune

Found a bug with the CensusPlus UI Mod? Post it here!
Post Reply
User avatar
Jenlor
Posts: 27
Joined: Thu Aug 25, 2005 2:38 pm
Location: Moonrunner

Bug with 3.1 and Prune

Post by Jenlor »

When I press Prune with the new 3.1 I get the following error:

Interface\Addons\CensusPlus\CensusPlus.lu
a:2588: attempt to perform arithmetic on gl
obal `timesPruneCount' (a nil value)
Image

User avatar
Rollie
Site Admin
Posts: 4783
Joined: Sun Nov 28, 2004 11:52 am
Location: Austin, TX
Contact:

Post by Rollie »

Did you click the Prune button? Or use a /census prune command?
phpbb:phpinfo()

semidar
Posts: 14
Joined: Tue Jan 25, 2005 5:41 am
Location: Jacksonville, FL USA

Post by semidar »

was just about to post the same problem. I used the button.

I tried /census prune and received a command line help listing, so I tried /censusplus prune 30 and got the same/original error msg.

User avatar
Rollie
Site Admin
Posts: 4783
Joined: Sun Nov 28, 2004 11:52 am
Location: Austin, TX
Contact:

Post by Rollie »

Hrm.. okay, thanks, will look into it tonight.
phpbb:phpinfo()

User avatar
Rollie
Site Admin
Posts: 4783
Joined: Sun Nov 28, 2004 11:52 am
Location: Austin, TX
Contact:

Post by Rollie »

Ah, okay, I just took a look at the code and found the culprit.

I cannot test this until I get home tonight, but would one of you (or someone else having this issue) that is comfortable editing the files make this modification and post here the results?

In the file \Interface\AddOns\CensusPlus\CensusPlus.lua, on line 2566, remove the function CensusPlus_PruneTimes(), as shown here:

Code: Select all

function CensusPlus_PruneTimes()
	local pruneDays = 60*60*24*21; --  num seconds 

	for realmName, realmDatabase in pairs(CensusPlus_Database["TimesPlus"]) do
		if (realmName ~= nil ) then
			for factionName, factionDatabase in pairs(realmDatabase) do
				if ( factionName ~= nil) then
					for moment, count in pairs( factionDatabase ) do
						--  Moment is in format of YYYY-MM-DD&HH:MM
						local test = string.sub( moment, 1, 2 );
						local tYear, tMonth, tDay;
						tYear = string.sub( moment,  1, 4 );
						tMonth = string.sub( moment, 6, 7 );
						tDay   = string.sub( moment, 9, 10 );
						local momentTime = time( {year=tYear, month=tMonth, day=tDay, hour=0} );

						if( time() - momentTime > pruneDays ) then
							--  cull entry
							CensusPlus_Database["TimesPlus"][realmName][UnitFactionGroup("player")][moment] = nil;
							moment = nil;
							timesPruneCount = timesPruneCount + 1;
						end
					end
				end
			end
		end
	end
end
and replace with:

Code: Select all

function CensusPlus_PruneTimes()
	local pruneDays = 60*60*24*21; --  num seconds 

    local accumTimesData = {};
	for realmName, realmDatabase in pairs(CensusPlus_Database["TimesPlus"]) do
		if (realmName ~= nil ) then
			for factionName, factionDatabase in pairs(realmDatabase) do
				if ( factionName ~= nil) then
					for moment, count in pairs( factionDatabase ) do
						--  Moment is in format of YYYY-MM-DD&HH:MM
						local test = string.sub( moment, 1, 2 );
						local tYear, tMonth, tDay;
						tYear = string.sub( moment,  1, 4 );
						tMonth = string.sub( moment, 6, 7 );
						tDay   = string.sub( moment, 9, 10 );
						local momentTime = time( {year=tYear, month=tMonth, day=tDay, hour=0} );

						if( time() - momentTime > pruneDays ) then
							--  cull entry
	                        local pruneData = {};
	                        pruneData.realm = realm;
	                        pruneData.faction = faction;
-- EDIT: change the above 2 lines to :

Code: Select all

	                        pruneData.realm = realmName;
	                        pruneData.faction = factionName;
and the rest:

Code: Select all

	                        pruneData.entry = moment;
	                        table.insert(accumTimesData, pruneData);
						end
					end
				end
			end
		end
	end
	
	local num = table.getn(accumTimesData);
	while( num > 0 )do
		--
		-- Remove the top job from the queue and send it
		--
		local pruneData = accumTimesData[num];

        CensusPlus_Database["TimesPlus"][pruneData.realm][pruneData.faction][pruneData.entry] = {};
        CensusPlus_Database["TimesPlus"][pruneData.realm][pruneData.faction][pruneData.entry] = nil;

		table.remove(accumTimesData);
		num = table.getn(accumTimesData);
	end
end
Last edited by Rollie on Thu Jan 05, 2006 1:06 am, edited 2 times in total.
phpbb:phpinfo()

Khryss
Posts: 1
Joined: Wed Nov 09, 2005 8:15 am

Post by Khryss »

Tried to make above modifications, now I get

Error: Interface\AddOns\CensusPlus\CensusPlus.lua:2606: attempt to index field `?' (a nil value)

User avatar
Rollie
Site Admin
Posts: 4783
Joined: Sun Nov 28, 2004 11:52 am
Location: Austin, TX
Contact:

Post by Rollie »

bah, okay, I'll be home shortly, can check it out in a bit
phpbb:phpinfo()

User avatar
Rollie
Site Admin
Posts: 4783
Joined: Sun Nov 28, 2004 11:52 am
Location: Austin, TX
Contact:

Post by Rollie »

Fix posted:

http://www.warcraftrealms.com/censusmod ... -3.1.2.zip

alternately, in the above code segment, you can change the

Code: Select all

                          pruneData.realm = realm;
                           pruneData.faction = faction;
to

Code: Select all

	                        pruneData.realm = realmName;
	                        pruneData.faction = factionName;
phpbb:phpinfo()

Post Reply