PluginProbe
Redirection / 2.9
Redirection v2.9
5.10.0 5.9.0 5.8.1 5.8.0 3.7.2 3.7.3 4.0 4.0.1 4.1 4.1.1 4.2 4.2.1 4.2.2 4.2.3 4.3 4.3.1 4.3.2 4.3.3 4.4 4.4.1 4.4.2 4.5 4.5.1 4.6.2 4.7.1 All 130 releases
← All changes | redirection-cli.php +9 -80 4.02.9 View file →
@@ -56,21 +56,21 @@
56 56 return;
57 57 }
58 58
59 59 if ( $format === 'csv' ) {
60 - $file = fopen( $args[0], 'r' );
60 + $file = fopen( $args[ 0 ], 'r' );
61 61
62 62 if ( $file ) {
63 - $count = $importer->load( $group, $args[0], '' );
64 - WP_CLI::success( 'Imported ' . $count . ' as ' . $format );
63 + $count = $importer->load( $group, $args[ 0 ], '' );
64 + WP_CLI::success( 'Imported ' . $count . ' as '.$format );
65 65 } else {
66 66 WP_CLI::error( 'Invalid import file' );
67 67 }
68 68 } else {
69 - $data = @file_get_contents( $args[0] );
69 + $data = @file_get_contents( $args[ 0 ] );
70 70 if ( $data ) {
71 - $count = $importer->load( $group, $args[0], $data );
72 - WP_CLI::success( 'Imported ' . $count . ' as ' . $format );
71 + $count = $importer->load( $group, $args[ 0 ], $data );
72 + WP_CLI::success( 'Imported ' . $count . ' as '.$format );
73 73 }
74 74 }
75 75 }
76 76
@@ -100,11 +100,11 @@
100 100 WP_CLI::error( 'Invalid export format - json, csv, htaccess, or nginx supported' );
101 101 return;
102 102 }
103 103
104 - $file = fopen( $args[1] === '-' ? 'php://stdout' : $args[1], 'w' );
104 + $file = fopen( $args[ 1 ] === '-' ? 'php://stdout' : $args[ 1 ], 'w' );
105 105 if ( $file ) {
106 - $export = Red_FileIO::export( $args[0], $format );
106 + $export = Red_FileIO::export( $args[ 0 ], $format );
107 107
108 108 if ( $export === false ) {
109 109 WP_CLI::error( 'Invalid module - must be wordpress, apache, nginx, or all' );
110 110 return;
@@ -112,86 +112,15 @@
112 112
113 113 fwrite( $file, $export['data'] );
114 114 fclose( $file );
115 115
116 - WP_CLI::success( 'Exported ' . $export['total'] . ' to ' . $format );
116 + WP_CLI::success( 'Exported ' . $export['total'] .' to '.$format );
117 117 } else {
118 118 WP_CLI::error( 'Invalid output file' );
119 119 }
120 120 }
121 -
122 - /**
123 - * Perform Redirection database actions
124 - *
125 - * ## OPTIONS
126 - *
127 - * <action>
128 - * : The database action to perform: install, remove, upgrade
129 - *
130 - * ## EXAMPLES
131 - *
132 - * wp redirection database install
133 - */
134 - public function database( $args, $extra ) {
135 - $action = false;
136 -
137 - if ( count( $args ) === 0 || ! in_array( $args[0], array( 'install', 'remove', 'upgrade' ), true ) ) {
138 - WP_CLI::error( 'Invalid database action - please use install, remove, or upgrade' );
139 - return;
140 - }
141 -
142 - if ( $args[0] === 'install' ) {
143 - Red_Database::apply_to_sites( function() {
144 - $latest = Red_Database::get_latest_database();
145 - $latest->install();
146 - } );
147 -
148 - WP_CLI::success( 'Database installed' );
149 - } elseif ( $args[0] === 'upgrade' ) {
150 - $database = new Red_Database();
151 - $status = new Red_Database_Status();
152 -
153 - if ( ! $status->needs_updating() ) {
154 - WP_CLI::success( 'Database is already the latest version' );
155 - return;
156 - }
157 -
158 - $loop = 0;
159 -
160 - while ( $loop < 50 ) {
161 - $result = $database->apply_upgrade( $status );
162 - $info = $status->get_json();
163 -
164 - if ( ! $info['inProgress'] ) {
165 - break;
166 - }
167 -
168 - if ( $info['status'] === 'error' ) {
169 - WP_CLI::error( 'Database failed to upgrade: ' . $info['reason'] );
170 - return;
171 - }
172 -
173 - $loop++;
174 - }
175 -
176 - WP_CLI::success( 'Database upgraded' );
177 - } elseif ( $args[0] === 'remove' ) {
178 - Red_Database::apply_to_sites( function() {
179 - $latest = Red_Database::get_latest_database();
180 - $latest->remove();
181 - } );
182 -
183 - WP_CLI::success( 'Database removed' );
184 - }
185 - }
186 121 }
187 122
188 123 if ( defined( 'WP_CLI' ) && WP_CLI ) {
189 124 WP_CLI::add_command( 'redirection import', array( 'Redirection_Cli', 'import' ) );
190 125 WP_CLI::add_command( 'redirection export', array( 'Redirection_Cli', 'export' ) );
191 - WP_CLI::add_command( 'redirection database', array( 'Redirection_Cli', 'database' ) );
192 -
193 - add_action( Red_Flusher::DELETE_HOOK, function() {
194 - $flusher = new Red_Flusher();
195 - $flusher->flush();
196 - } );
197 126 }