Add ability to export a WXR to STDOUT#13
Conversation
src/Export_Command.php
Outdated
|
|
||
| private function stdout ( $path ) { | ||
| if ( ! empty( $this->wxr_path ) ) { | ||
| WP_CLI::error( sprintf( "--stdout and --dir are mutually exclusive" ) ); |
There was a problem hiding this comment.
Please add . at the end of the message.
src/Export_Command.php
Outdated
| public function __invoke( $_, $assoc_args ) { | ||
| $defaults = array( | ||
| 'dir' => NULL, | ||
| 'stdout' => NULL, |
There was a problem hiding this comment.
It should be false instead of null?
You just run |
|
updated the PR, but but at least I was able to run the |
4f01db3 to
7a1329f
Compare
|
updated the PR to avoid cluttering the XML with |
You seem to have a connectivity issue. Does |
|
Re code, you should remove $stdout = WP_CLI\Utils\get_flag_value( $assoc_args, 'stdout' );
if ( $stdout && WP_CLI\Utils\get_flag_value( $assoc_args, 'dir' ) ) {
WP_CLI::error( '--stdout and --dir are mutually exclusive.' );
}(or maybe |
|
you were right. I went a bit further. But every tests throw this: updated the PR |
7938f57 to
bbcc22a
Compare
|
You're getting some very strange errors. What is your development environment? For some reason WP isn't loading correctly. You could try doing |
|
Actually got an error yesterday similar to
due to Anyway I'll open an issue re a) and b). |
|
I found out that There are 2 options.
Related: wp-cli/db-command#35 |
|
If it supports |
|
semantics: option vs positional arguments. The same apply for |
|
The general convention in the Unix world is that when a positional parameter denotes a file, the Here's the relevant signatures: The main difference between |
|
Ah, I (probably) understand. 😄
Thanks! I will add example for |
|
I'm amenable to adding |
|
(only "export" produces files) I don't think it should be set in stone. On the contrary, the road should be to improve import so that this chunking mechanism may almost disappear in the future. Dumping to stdout by default (and use Moreover, splitting XML IMHO, if even needed it's up to XML importer to manage heavy XML files. |
|
Thanks @drzraf
I understand. I'll keep in my mind your advise, thanks. 👍 |
|
@drzraf did you resolve your issue in #13 (comment) re WP loading incorrectly? |
|
[edit]
[edit2]
Not so bad for a 1/10 of the time |
|
Is that a hard limit? 200M isn't much by today's standards. Most of it is probably in If you're stuck with that limitation, you could try first doing a vendor/bin/behat features/export.feature:3
rm -rf /tmp/wp-cli-test-run-*
vendor/bin/behat features/export.feature:12
rm -rf /tmp/wp-cli-test-run-*Re code, it's still failing because of https://github.com/wp-cli/export-command/pull/13/files#diff-e3d90c1b28e749135782faa062b59c9dR212 which should be removed. Also I don't see the advantage of the variant https://github.com/wp-cli/export-command/pull/13/files#diff-e3d90c1b28e749135782faa062b59c9dR126 as opposed to the suggestion in #13 (comment), nor the need to check for |
best regards |
danielbachhuber
left a comment
There was a problem hiding this comment.
Looking pretty good from my perspective. Just a few minor things to finish up.
src/Export_Command.php
Outdated
|
|
||
| if (! empty( $assoc_args['stdout'] ) && ( ! empty( $assoc_args['dir'] ) || ! empty( $assoc_args['filename_format'] ) ) ) { | ||
| WP_CLI::error( "--stdout and --dir cannot be used together." ); | ||
| WP_CLI::halt(1); |
There was a problem hiding this comment.
WP_CLI::halt(1) isn't necessary here, because WP_CLI::error() will halt the process.
src/Export_Command.php
Outdated
| * [--dir=<dirname>] | ||
| * : Full path to directory where WXR export files should be stored. Defaults | ||
| * to current working directory. | ||
|
|
There was a problem hiding this comment.
Looks like we're missing a * here.
src/WP_Export_Stdout_Writer.php
Outdated
|
|
||
| function __construct( $formatter, $writer_args = array() ) { | ||
| parent::__construct( $formatter ); | ||
| //TODO: check if args are not missing |
There was a problem hiding this comment.
Is this // TODO still necessary?
src/WP_Export_Stdout_Writer.php
Outdated
| } | ||
|
|
||
| public function export() { | ||
| // WP_CLI\Utils\wp_clear_object_cache(); ? |
There was a problem hiding this comment.
Is there a reason this is commented out?
|
fixed 3o4 comments |
I agree with the reasoning, but this is not how the current So, yes, we can add the |
|
@drzraf ^ Worth taking a look through the changes I made, for your own information. |
|
Indeed I had a look. I hope new behat steps could be made like " |
Certainly, could. WP-CLI command tests inherit from the main WP-CLI test suite, so it typically makes sense to add new steps when the same test pattern is used in multiple places. Also, my preference is to use more literal steps so it's more obvious what process is being followed. The more abstraction we add, the higher base knowledge required for a new person to come into the project. |
Add ability to export a WXR to STDOUT
Ability to export to stdout.
Sorry for the lack of testing (yet), but having I didn't find a way to use my common
wpphar file while overriding theexportusing the git local copy.Neither
requir'ing inwp-config.php, neitherwp --require=made it (hint welcome)Fixes #9