Default out-of-range paginated queries to the last available page

Started from #3075