Permalink
Browse files

Fix bug in getApplicablelength where same DYK block includes quintupl…

…e apostrophes
  • Loading branch information...
Jarry1250 committed May 12, 2018
1 parent 5524f4e commit a6e39aa538d2a32bc101a725a809683b6a0324a2
Showing with 3 additions and 1 deletion.
  1. +3 −1 script.php
View
@@ -200,8 +200,10 @@ function getApplicableLength( $pagename, $dykname ) {
$json = getJSON( $apiBase . "action=query&prop=revisions&titles=" . urlencode( $backlink['title'] ) . "&rvprop=content&rvlimit=1" );
$page = array_shift( $json['query']['pages'] );
$text = str_replace( '_', ' ', $page['revisions'][0]['*'] );
$bits = explode( str_replace( '_', ' ', $pagename ), $text, 2 );
// Wierdly we want the timestamp after and not before...
if( preg_match("/" . preg_quote( str_replace( '_', ' ', $pagename ) ) . ".*?'''''(.*?) \(UTC\)'''''/is", $text, $matches ) ) {
if( count( $bits ) > 1 && preg_match("/'''''([^']+) \(UTC\)'''''/i", $bits[1], $matches ) ) {
$timestamp = date( 'YmdHis', strtotime( $matches[1] ) );
break;
}

0 comments on commit a6e39aa

Please sign in to comment.