Files
FreshRSS/cli/export-opml-for-user.php
Marien Fressinaud 8f188ffa84 Fix filenames for files exported with CLI (#2932)
Filenames were created with the username of the current user. However,
when we export the files with the CLI, the current user is "_".

This commit makes the username always required in the `exportFile`
method so we make sure to always manipulate a real value. Consequently,
the filenames can be formatted correctly.

Obviously, this has absolutely no impacts since the CLI doesn't consider
the HTTP headers. It just makes things a bit more clear. It's a first
step to remove the concept of "default user".
2020-04-30 12:11:51 +02:00

27 lines
598 B
PHP
Executable File

#!/usr/bin/php
<?php
require(__DIR__ . '/_cli.php');
$params = array(
'user:',
);
$options = getopt('', $params);
if (!validateOptions($argv, $params) || empty($options['user'])) {
fail('Usage: ' . basename(__FILE__) . " --user username > /path/to/file.opml.xml");
}
$username = cliInitUser($options['user']);
fwrite(STDERR, 'FreshRSS exporting OPML for user “' . $username . "”…\n");
$importController = new FreshRSS_importExport_Controller();
$ok = false;
$ok = $importController->exportFile($username, true, false, false, array(), 0);
invalidateHttpCache($username);
done($ok);