1 | <?php |
||
30 | class DumpBackup extends BackupDumper { |
||
31 | function __construct( $args = null ) { |
||
32 | parent::__construct(); |
||
33 | |||
34 | $this->addDescription( <<<TEXT |
||
35 | This script dumps the wiki page or logging database into an |
||
36 | XML interchange wrapper format for export or backup. |
||
37 | |||
38 | XML output is sent to stdout; progress reports are sent to stderr. |
||
39 | |||
40 | WARNING: this is not a full database dump! It is merely for public export |
||
41 | of your wiki. For full backup, see our online help at: |
||
42 | https://www.mediawiki.org/wiki/Backup |
||
43 | TEXT |
||
44 | ); |
||
45 | $this->stderr = fopen( "php://stderr", "wt" ); |
||
46 | // Actions |
||
47 | $this->addOption( 'full', 'Dump all revisions of every page' ); |
||
48 | $this->addOption( 'current', 'Dump only the latest revision of every page.' ); |
||
49 | $this->addOption( 'logs', 'Dump all log events' ); |
||
50 | $this->addOption( 'stable', 'Dump stable versions of pages' ); |
||
51 | $this->addOption( 'revrange', 'Dump range of revisions specified by revstart and ' . |
||
52 | 'revend parameters' ); |
||
53 | $this->addOption( 'orderrevs', 'Dump revisions in ascending revision order ' . |
||
54 | '(implies dump of a range of pages)' ); |
||
55 | $this->addOption( 'pagelist', |
||
56 | 'Dump only pages included in the file', false, true ); |
||
57 | // Options |
||
58 | $this->addOption( 'start', 'Start from page_id or log_id', false, true ); |
||
59 | $this->addOption( 'end', 'Stop before page_id or log_id n (exclusive)', false, true ); |
||
60 | $this->addOption( 'revstart', 'Start from rev_id', false, true ); |
||
61 | $this->addOption( 'revend', 'Stop before rev_id n (exclusive)', false, true ); |
||
62 | $this->addOption( 'skip-header', 'Don\'t output the <mediawiki> header' ); |
||
63 | $this->addOption( 'skip-footer', 'Don\'t output the </mediawiki> footer' ); |
||
64 | $this->addOption( 'stub', 'Don\'t perform old_text lookups; for 2-pass dump' ); |
||
65 | $this->addOption( 'uploads', 'Include upload records without files' ); |
||
66 | $this->addOption( 'include-files', 'Include files within the XML stream' ); |
||
67 | |||
68 | if ( $args ) { |
||
69 | $this->loadWithArgv( $args ); |
||
70 | $this->processOptions(); |
||
71 | } |
||
72 | } |
||
73 | |||
74 | function execute() { |
||
93 | |||
94 | function processOptions() { |
||
134 | } |
||
135 | |||
138 |
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.