diff --git a/includes/class-CategoryYearMonthDayTypeOrdinary.php b/includes/class-CategoryYearMonthDayTypeOrdinary.php index 901f4ea..5cdb3d8 100644 --- a/includes/class-CategoryYearMonthDayTypeOrdinary.php +++ b/includes/class-CategoryYearMonthDayTypeOrdinary.php @@ -1,46 +1,50 @@ . namespace itwikidelbot; /** * Handle a daily ordinary PDC category * * e.g. https://it.wikipedia.org/wiki/Categoria:Cancellazioni_ordinarie_del_25_giugno_2012 + * + * @deprecated This category has not been in use since 2013. + * https://it.wikipedia.org/wiki/Speciale:Diff/62875319 + * https://it.wikipedia.org/wiki/Discussioni_utente:BotCancellazioni#c-Sakretsu-20260810150200-Categorie_delle_cancellazioni_"ordinarie" */ class CategoryYearMonthDayTypeOrdinary extends CategoryYearMonthDayType { /** * PDC type * * @override CategoryYearMonthDay::PDC_TYPE */ const PDC_TYPE = 'ordinarie'; /** * PDC human type * * @override CategoryYearMonthDay::PDC_TYPE_HUMAN */ const PDC_TYPE_HUMAN = 'ordinaria'; } diff --git a/includes/class-CategoryYearMonthDayTypes.php b/includes/class-CategoryYearMonthDayTypes.php index 288d451..93cbba3 100644 --- a/includes/class-CategoryYearMonthDayTypes.php +++ b/includes/class-CategoryYearMonthDayTypes.php @@ -1,157 +1,160 @@ . namespace itwikidelbot; use InvalidArgumentException; /** * Handler of all the PDC type categories */ class CategoryYearMonthDayTypes { /** * PDC types * * Categories in order of importance (I think) * * @var array */ public static $TYPES = [ CategoryYearMonthDayTypeVoting ::class, // voting - CategoryYearMonthDayTypeOrdinary ::class, // ordinary + // The 'ordinary' category has been deprecated since 2013. + // https://it.wikipedia.org/w/index.php?diff=62875319 + // https://it.wikipedia.org/wiki/Discussioni_utente:BotCancellazioni#c-Valerio_Bozzolan-20260810153600-Sakretsu-20260810150200 +// CategoryYearMonthDayTypeOrdinary ::class, // ordinary CategoryYearMonthDayTypeProlonged ::class, // prolonged CategoryYearMonthDayTypeConsensual::class, // consensual CategoryYearMonthDay ::class, // simple ]; /** * Other types of categories * * @var array */ private static $OTHER_KNOWN_CATEGORIES = [ 'Categoria:Procedure di cancellazione protette', 'Categoria:Procedure di cancellazione multiple in corso', 'Categoria:Pagine protette - scadute', 'Categoria:Pagine di servizio protette', ]; /** * Get all the types * * @return array */ public static function all() { return self::$TYPES; } /** * Create the corresponding category object from its title * * @param $title string Page title * @return CategoryYearMonthDay|false * @throw PDCUnkownCategoryException */ public static function createParsingTitle( $title ) { foreach( self::all() as $Type ) { $category = $Type::createParsingTitle( $title ); if( $category ) { return $category; } } if( !in_array( $title, self::$OTHER_KNOWN_CATEGORIES, true ) ) { throw new PDCUnknownCategoryException( "unexpected PDC category '$title'" ); } return false; } /** * Get a "genericity" score of a certain PDC category class name. * * Useful to comparate PDC types. * * E.g. a "simple" PDC has an higher score over a "consensual" PDC. * * @param $category string Class name * @return int 0-4 */ public static function genericityFromClass( $category_class_name ) { $i = array_search( $category_class_name, self::all(), true ); if( false === $i ) { throw new InvalidArgumentException( "unknown class name $category_class_name" ); } return $i; } /** * Get a "genericity" score of a certain PDC category instance. * * @see self::genericity() * @param $category CategoryYearMonthDay * @return int 0-4 */ public static function genericityFromObject( CategoryYearMonthDay $category ) { return self::genericityFromClass( get_class( $category ) ); } /** * Find the best category (the most recent) from a list * * @param $categories CategoryYearMonthDay[] * @return CategoryYearMonthDay One of the $categories */ public static function findBestCategory( $categories ) { $best = null; foreach( $categories as $category ) { if( ! $best ) { $best = $category; } elseif( $category->getDateTime()->format('Y-m-d') === $best->getDateTime()->format('Y-m-d') ) { // the day is the same: take the most precise if( self::genericityFromObject( $category ) < self::genericityFromObject( $best ) ) { $best = $category; } } elseif( $category->getDateTime() > $best->getDateTime() ) { // take the newest $best = $category; } } if( ! $best ) { throw new PDCException( 'cannot find the best categories' ); } return $best; } /** * * * @param $year int * @param $month int * @param $day int * @return PDC[] */ public static function fetchYearMonthDayPDCs( $year, $month, $day ) { $pdcs_by_id = []; } }