Permalink
Browse files

Tweak getApplicableAge to cope with articles that were temporarily re…

…directs
  • Loading branch information...
Jarry1250 committed Jun 21, 2017
1 parent 3c10d2f commit dcbc85de815ab764200d1f898265539aa374960d
Showing with 6 additions and 5 deletions.
  1. +6 −5 script.php
View
@@ -250,6 +250,7 @@ function getApplicableAge( $pagename ) {
global $apiBase;
$year = ( intval( date( 'Y' ) ) - 4 );
$lastQualifyingYear = $year;
while( true ){
$year--;
@@ -262,15 +263,15 @@ function getApplicableAge( $pagename ) {
break;
}
$page = array_shift( $json['query']['pages'] );
if(
!isset( $page['revisions'], $page['revisions'][0], $page['revisions'][0]['size'] )
|| ( intval( $page['revisions'][0]['size'] ) <= 100 )
){
if( !isset( $page['revisions'], $page['revisions'][0], $page['revisions'][0]['size'] ) ){
// No such revision or redirect, etc
break;
}
if( intval( $page['revisions'][0]['size'] ) >= 100 ) {
$lastQualifyingYear = $year;
}
}
return ( intval( date( 'Y' ) ) - $year - 1 );
return ( intval( date( 'Y' ) ) - $lastQualifyingYear );
}
function getApplicableMultiplier( $pageName, $section, $line ) {

0 comments on commit dcbc85d

Please sign in to comment.