MediaWiki  1.33.0
updateCredits.php
Go to the documentation of this file.
1 <?php
25 if ( PHP_SAPI != 'cli' ) {
26  die( "This script can only be run from the command line.\n" );
27 }
28 
29 // class Collator is provided by the intl extension.
30 // It is only suggested in composer.json, so remind here when not loaded.
31 if ( !extension_loaded( 'intl' ) ) {
32  die( "This script needs the 'intl' extension to be loaded." );
33 }
34 
35 $CREDITS = 'CREDITS';
36 $START_CONTRIBUTORS = '<!-- BEGIN CONTRIBUTOR LIST -->';
37 $END_CONTRIBUTORS = '<!-- END CONTRIBUTOR LIST -->';
38 
39 $inHeader = true;
40 $inFooter = false;
41 $header = [];
43 $footer = [];
44 
45 if ( !file_exists( $CREDITS ) ) {
46  exit( 'No CREDITS file found. Are you running this script in the right directory?' );
47 }
48 
49 $lines = explode( "\n", file_get_contents( $CREDITS ) );
50 foreach ( $lines as $line ) {
51  if ( $inHeader ) {
52  $header[] = $line;
54  } elseif ( $inFooter ) {
55  $footer[] = $line;
56  } elseif ( $line == $END_CONTRIBUTORS ) {
57  $inFooter = true;
58  $footer[] = $line;
59  } else {
60  $name = substr( $line, 2 );
61  $contributors[$name] = true;
62  }
63 }
64 unset( $lines );
65 
66 $lines = explode( "\n", shell_exec( 'git log --format="%aN"' ) );
67 foreach ( $lines as $line ) {
68  if ( empty( $line ) ) {
69  continue;
70  }
71  if ( substr( $line, 0, 5 ) === '[BOT]' ) {
72  continue;
73  }
74  $contributors[$line] = true;
75 }
76 
77 $contributors = array_keys( $contributors );
78 $collator = Collator::create( 'root' );
79 $collator->setAttribute( Collator::NUMERIC_COLLATION, Collator::ON );
80 $collator->sort( $contributors );
81 array_walk( $contributors, function ( &$v, $k ) {
82  $v = "* {$v}";
83 } );
84 
85 file_put_contents( $CREDITS,
86  implode( "\n", array_merge( $header, $contributors, $footer ) ) );
$collator
$collator
Definition: updateCredits.php:78
$START_CONTRIBUTORS
$START_CONTRIBUTORS
Definition: updateCredits.php:36
$inHeader
$inHeader
Definition: updateCredits.php:39
php
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
$CREDITS
if(PHP_SAPI !='cli') if(!extension_loaded( 'intl')) $CREDITS
Update the CREDITS list by merging in the list of git commit authors.
Definition: updateCredits.php:35
$END_CONTRIBUTORS
$END_CONTRIBUTORS
Definition: updateCredits.php:37
$contributors
$contributors
Definition: updateCredits.php:42
$inFooter
$inFooter
Definition: updateCredits.php:40
$name
Allows to change the fields on the form that will be generated $name
Definition: hooks.txt:271
$line
$line
Definition: cdb.php:59
$header
$header
Definition: updateCredits.php:41
$lines
if(!file_exists( $CREDITS)) $lines
Definition: updateCredits.php:49
as
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Definition: distributors.txt:9
$footer
$footer
Definition: updateCredits.php:43