Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the WWW-Mechanize-Cached CPAN distribution.

Report information
The Basics
Id: 56757
Status: resolved
Worked: 2.8 hours (170 min)
Priority: 0/
Queue: WWW-Mechanize-Cached

People
Owner: Nobody in particular
Requestors: doubiman [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 1.35
Fixed in: (no value)



Subject: Iteration bug?
Hi there, I had a strange problem concerning iteration. Asked in #perl-help and was advised that it looked like a bug. The scenario is: you have an array of @targets which get looped through by the same cached $mech object. - When the script is run the first time, obviously nothing in the cache. - When the script is run the second time with the same @targets, all $targets are retrieved from the cache, yay. - But if you remove one of the $targets from the array and run the script again, the $target Immediately After the one removed is no longer retrieved from the cache. - You can remove several $targets and the one following each of them will not be retrieved from the cache. See file attached. Also available under the kind auspices of jhannah at http://github.com/jhannah/sandbox/blob/master/doubi/mech.pl (although lines 37 and 38 here are irrelevant leftovers :s) I'm on Strawberry Perl 5.10.1, using W:M:C 1.35. Sorry if this turns out to be a mistake on my part. Thanks!
Subject: wwwMechCached_query.pl
#! /usr/bin/perl use strict; use warnings; use WWW::Mechanize::Cached; use HTML::TreeBuilder; use Cache::FileCache; # # Run this script once as it is. Then, remove one of the $target's below, and re-run it. # From the output you'll see that the entry Immediately After the removed entry is no # longer retrieved from the cache. # my @targets = ( 'http://www.sheffieldhelpyourself.org.uk/full_search_new.asp?group=24231&searchname=', # 104 Holgate Road 'http://www.sheffieldhelpyourself.org.uk/full_search_new.asp?group=16469&searchname=', # Age Concern Sheffield 'http://www.sheffieldhelpyourself.org.uk/full_search_new.asp?group=19691&searchname=', # Access Space 'http://www.sheffieldhelpyourself.org.uk/full_search_new.asp?group=16440&searchname=', # Action for Stannington 'http://www.sheffieldhelpyourself.org.uk/full_search_new.asp?group=23009&searchname=', # Activity Sheffield Council 'http://www.sheffieldhelpyourself.org.uk/full_search_new.asp?group=24630&searchname=' # Activity Sheffield Over 50s ); my $cache = new Cache::FileCache( { 'namespace' => 'shef', 'cache_root' => "./shef", 'cache_depth' => 8, 'default_expires' => '1d' } ); my $mech = WWW::Mechanize::Cached->new( cache => $cache ); for( my $i = 0; $i <= $#targets ; $i++ ) { # Prepare the tree... my $tree = HTML::TreeBuilder->new; $tree->parse( $mech->get( $targets[$i] )->content ); $tree->eof; $tree->objectify_text(); # print the name of the organisation fetched in this iteration print $tree->address("0.1.0.3.1.1.2.0.1.0.0.0")->attr('text') . ": "; if( $mech->is_cached() ) { print "this WAS cached.\n" } else { print "this was NOT cached.\n" }; } 1;
On Tue Apr 20 15:11:26 2010, https://www.google.com/accounts/o8/id?id=AItOawmkU1-LOLk6xueuW9vgZcQ1T3o8mlBsCX8 wrote: Show quoted text
> Hi there, > > I had a strange problem concerning iteration. Asked in #perl-help and > was advised that it looked like a bug. > > The scenario is: you have an array of @targets which get looped through > by the same cached $mech object. > > - When the script is run the first time, obviously nothing in the cache. > > - When the script is run the second time with the same @targets, all > $targets are retrieved from the cache, yay. > > - But if you remove one of the $targets from the array and run the > script again, the $target Immediately After the one removed is no longer > retrieved from the cache.
Ugh. I just noticed this ticket now. The notification must not have made it to my inbox. I'll have a look at it and see what the issue may be. Thanks for reporting it! Olaf
On Thu Jul 29 10:23:23 2010, OALDERS wrote: Show quoted text
> On Tue Apr 20 15:11:26 2010, > https://www.google.com/accounts/o8/id?id=AItOawmkU1- > LOLk6xueuW9vgZcQ1T3o8mlBsCX8 > wrote:
> > Hi there, > > > > I had a strange problem concerning iteration. Asked in #perl-help
> and
> > was advised that it looked like a bug. > > > > The scenario is: you have an array of @targets which get looped
> through
> > by the same cached $mech object. > > > > - When the script is run the first time, obviously nothing in the
> cache.
> > > > - When the script is run the second time with the same @targets, all > > $targets are retrieved from the cache, yay. > > > > - But if you remove one of the $targets from the array and run the > > script again, the $target Immediately After the one removed is no
> longer
> > retrieved from the cache.
> > Ugh. I just noticed this ticket now. The notification must not have > made it to my inbox. I'll have a look at it and see what the issue > may > be. Thanks for reporting it! > > Olaf
I can confirm that this is indeed a bug. If you run the script and then reverse the array, it reports *every* URL as not having been cached. I'll see if I can find the root of the problem. Thanks for reporting this. Olaf
On Wed Aug 11 01:00:38 2010, OALDERS wrote: Show quoted text
> On Thu Jul 29 10:23:23 2010, OALDERS wrote:
> > On Tue Apr 20 15:11:26 2010, > > https://www.google.com/accounts/o8/id?id=AItOawmkU1- > > LOLk6xueuW9vgZcQ1T3o8mlBsCX8 > > wrote:
> > > Hi there, > > > > > > I had a strange problem concerning iteration. Asked in #perl-help
> > and
> > > was advised that it looked like a bug. > > > > > > The scenario is: you have an array of @targets which get looped
> > through
> > > by the same cached $mech object. > > > > > > - When the script is run the first time, obviously nothing in the
> > cache.
> > > > > > - When the script is run the second time with the same @targets, all > > > $targets are retrieved from the cache, yay. > > > > > > - But if you remove one of the $targets from the array and run the > > > script again, the $target Immediately After the one removed is no
> > longer
> > > retrieved from the cache.
> > > > Ugh. I just noticed this ticket now. The notification must not have > > made it to my inbox. I'll have a look at it and see what the issue > > may > > be. Thanks for reporting it! > > > > Olaf
> > I can confirm that this is indeed a bug. If you run the script and then > reverse the array, it reports *every* URL as not having been cached. > I'll see if I can find the root of the problem. Thanks for reporting
this. Show quoted text
> > Olaf
This has now been fixed in 1.36, which will be released in the next week or so. Just have to tidy a few things up before I upload it. Thanks again for your bug report. The test case proved to be very helpful. Olaf
From: doubiman [...] gmail.com
On Sat Aug 14 00:32:15 2010, OALDERS wrote: Show quoted text
> > This has now been fixed in 1.36, which will be released in the next week > or so. Just have to tidy a few things up before I upload it. > > Thanks again for your bug report. The test case proved to be very
helpful. Show quoted text
> > Olaf >
Great! Thanks a lot :) Glad I could help a bit. --doubi
On Sat Aug 14 05:40:41 2010, doubi wrote: Show quoted text
> On Sat Aug 14 00:32:15 2010, OALDERS wrote:
> > > > This has now been fixed in 1.36, which will be released in the next week > > or so. Just have to tidy a few things up before I upload it. > > > > Thanks again for your bug report. The test case proved to be very
> helpful.
> > > > Olaf > >
> > Great! Thanks a lot :) Glad I could help a bit. > > --doubi >
1.36 is now on it's way to the CPAN.