X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fspecials%2FSpecialLog.php;h=9931614458cf29d2886caf7bf3c87d0ee40fdc28;hb=0770f85a0a293e6c7af6f1d3d3a1dbd2d13c1e09;hp=216031295a36f8c8d38d5bbd95992b2082eebebf;hpb=55ffac2024448afd1c73c56fdd369c0f67409afb;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/specials/SpecialLog.php b/includes/specials/SpecialLog.php index 216031295a..9931614458 100644 --- a/includes/specials/SpecialLog.php +++ b/includes/specials/SpecialLog.php @@ -21,6 +21,8 @@ * @ingroup SpecialPage */ +use Wikimedia\Timestamp\TimestampException; + /** * A special page that lists log entries * @@ -63,12 +65,18 @@ class SpecialLog extends SpecialPage { // Set date values $dateString = $this->getRequest()->getVal( 'wpdate' ); if ( !empty( $dateString ) ) { - $dateStamp = MWTimestamp::getInstance( $dateString . ' 00:00:00' ); - $dateStamp->setTimezone( $this->getConfig()->get( 'Localtimezone' ) ); - - $opts->setValue( 'year', (int)$dateStamp->format( 'Y' ) ); - $opts->setValue( 'month', (int)$dateStamp->format( 'm' ) ); - $opts->setValue( 'day', (int)$dateStamp->format( 'd' ) ); + try { + $dateStamp = MWTimestamp::getInstance( $dateString . ' 00:00:00' ); + } catch ( TimestampException $e ) { + // If users provide an invalid date, silently ignore it + // instead of letting an exception bubble up (T201411) + $dateStamp = false; + } + if ( $dateStamp ) { + $opts->setValue( 'year', (int)$dateStamp->format( 'Y' ) ); + $opts->setValue( 'month', (int)$dateStamp->format( 'm' ) ); + $opts->setValue( 'day', (int)$dateStamp->format( 'd' ) ); + } } # Don't let the user get stuck with a certain date @@ -96,30 +104,12 @@ class SpecialLog extends SpecialPage { $offenderName = $opts->getValue( 'offender' ); $offender = empty( $offenderName ) ? null : User::newFromName( $offenderName, false ); if ( $offender ) { - if ( $wgActorTableSchemaMigrationStage === MIGRATION_NEW ) { + if ( $wgActorTableSchemaMigrationStage & SCHEMA_COMPAT_READ_NEW ) { $qc = [ 'ls_field' => 'target_author_actor', 'ls_value' => $offender->getActorId() ]; + } elseif ( $offender->getId() > 0 ) { + $qc = [ 'ls_field' => 'target_author_id', 'ls_value' => $offender->getId() ]; } else { - if ( $offender->getId() > 0 ) { - $field = 'target_author_id'; - $value = $offender->getId(); - } else { - $field = 'target_author_ip'; - $value = $offender->getName(); - } - if ( !$offender->getActorId() ) { - $qc = [ 'ls_field' => $field, 'ls_value' => $value ]; - } else { - $db = wfGetDB( DB_REPLICA ); - $qc = [ - 'ls_field' => [ 'target_author_actor', $field ], // So LogPager::getQueryInfo() works right - $db->makeList( [ - $db->makeList( - [ 'ls_field' => 'target_author_actor', 'ls_value' => $offender->getActorId() ], LIST_AND - ), - $db->makeList( [ 'ls_field' => $field, 'ls_value' => $value ], LIST_AND ), - ], LIST_OR ), - ]; - } + $qc = [ 'ls_field' => 'target_author_ip', 'ls_value' => $offender->getName() ]; } } } else {