Last modified: 2007-12-06 21:08:51 UTC
All seems well:
$ php dumpBackup.php --current > backup.xml
Until one day one looks inside:
$ cat backup.xml
DB connection error: Unknown MySQL server host 'mysql.mywiki.tw' (1) (mysql.mywiki.tw)
Therefore, please make sure stderr stuff goes to stderr, and not
(Yes, one can still do php dumpBackup.php||echo 1>&2 FAILED)
PHP spews errors to stdout by default. It may be possible to redirect it to stderr, though...
Ok, made changes on two fronts in r28222:
First, the exception reporting has been updated to send output to stderr when in command-line mode. This takes care of database connection errors and various other reportage from MediaWiki code that's done with exceptions.
Second, the commandLine.inc setup checks if 'display_errors' is on and, for PHP 5.2.4 or later, switches it to the 'stderr' setting instead. This will cause PHP warnings and errors to also be sent to stderr instead of the stdout stream. However it won't apply to errors which occur before that point in setup is reached, nor will it have any affect on older versions of PHP.
I also tweaked backup.inc and dumpTextPass to use the stderr mode, which will just disable for older versions of PHP (eg, same as the old behavior setting to false).
As of PHP 5.2.4:
- Changed "display_errors" php.ini option to accept "stderr" as value which
makes the error messages to be outputted to STDERR instead of STDOUT with
CGI and CLI SAPIs (FR #22839). (Jani)