Skip to content

Commit

Permalink
Tweak getApplicableAge to cope with articles that were temporarily re…
Browse files Browse the repository at this point in the history
…directs
  • Loading branch information
Jarry1250 committed Jun 21, 2017
1 parent 3c10d2f commit dcbc85d
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions script.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ function getApplicableAge( $pagename ) {
global $apiBase; global $apiBase;


$year = ( intval( date( 'Y' ) ) - 4 ); $year = ( intval( date( 'Y' ) ) - 4 );
$lastQualifyingYear = $year;
while( true ){ while( true ){
$year--; $year--;


Expand All @@ -262,15 +263,15 @@ function getApplicableAge( $pagename ) {
break; break;
} }
$page = array_shift( $json['query']['pages'] ); $page = array_shift( $json['query']['pages'] );
if( if( !isset( $page['revisions'], $page['revisions'][0], $page['revisions'][0]['size'] ) ){
!isset( $page['revisions'], $page['revisions'][0], $page['revisions'][0]['size'] )
|| ( intval( $page['revisions'][0]['size'] ) <= 100 )
){
// No such revision or redirect, etc // No such revision or redirect, etc
break; 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 ) { function getApplicableMultiplier( $pageName, $section, $line ) {
Expand Down

0 comments on commit dcbc85d

Please sign in to comment.