Skip to content

Commit

Permalink
bugfix: errors were caused when the page number was less than 1, and …
Browse files Browse the repository at this point in the history
…big cpu spikes occured when requesting a page greater than the max number of pages available
  • Loading branch information
Kieran Pilkington committed Oct 15, 2008
1 parent 9d7c8f0 commit 85c712f
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions app/controllers/search_controller.rb
Expand Up @@ -134,7 +134,7 @@ def search
@contributor = params[:contributor] ? User.find(params[:contributor]) : nil

# calculate where to start and end based on page
@current_page = params[:page] ? params[:page].to_i : 1
@current_page = (params[:page] && params[:page].to_i > 0) ? params[:page].to_i : 1
@next_page = @current_page + 1
@previous_page = @current_page - 1

Expand Down Expand Up @@ -221,17 +221,17 @@ def rss
def load_results(from_result_set)
@results = Array.new

# protect against malformed requests
# for a start record that is more than the numbers of matching records, return a 404
# since it only seems to be bots that make the malformed request
@end_record = from_result_set.size if from_result_set.size < @end_record
if @start_record > @end_record
rescue_404
return false
end

if from_result_set.size > 0
still_image_results = Array.new
# protect against malformed requests
# for a start record that is more than the numbers of matching records
# not handling adjust @start_record in view
# since it only seems to be bots that make the malformed request
if @start_record > @end_record
@start_record = 0
end

# get the raw xml results from zoom
raw_results = Module.class_eval(@current_class).records_from_zoom_result_set( :result_set => from_result_set,
Expand Down Expand Up @@ -888,7 +888,7 @@ def store_results_for_slideshow

# if @results_sets is emtpy, then @result_sets[@current_class] is nil so we have
# to stop here if thats the case, or we get a 500 error calling .size below
return if @result_sets[@current_class].nil?
return if @result_sets[@current_class].nil? or @displaying_error

results = @results.map{ |r| r['url'] }

Expand Down

0 comments on commit 85c712f

Please sign in to comment.