← All changes
|
jetpack_vendor/automattic/jetpack-backup-helper-script-manager/src/class-helper-script-manager-impl.php
+16
-17
13.0.2
→
16.3
View file →
| @@ -8,9 +8,9 @@ | ||
| 8 | 8 | // After changing this file, consider increasing the version number ("VXXX") in all the files using this namespace, in |
| 9 | 9 | // order to ensure that the specific version of this file always get loaded. Otherwise, Jetpack autoloader might decide |
| 10 | 10 | // to load an older/newer version of the class (if, for example, both the standalone and bundled versions of the plugin |
| 11 | 11 | // are installed, or in some other cases). |
| 12 | -namespace Automattic\Jetpack\Backup\V0001; | |
| 12 | +namespace Automattic\Jetpack\Backup\V0005; | |
| 13 | 13 | |
| 14 | 14 | use Exception; |
| 15 | 15 | use WP_Error; |
| 16 | 16 | use function content_url; |
| @@ -122,13 +122,25 @@ | ||
| 122 | 122 | $abspath_url = get_site_url(); |
| 123 | 123 | |
| 124 | 124 | $locations = array(); |
| 125 | 125 | |
| 126 | - // Prioritize trying to write to "wp-content/" and "wp-content/uploads/" first, because those locations are | |
| 127 | - // expected to be writable more often (unlike ABSPATH), and ABSPATH on some setups might have a weird value | |
| 128 | - // which doesn't point to document root. | |
| 126 | + // Prioritize ABSPATH first, because even though ABSPATH constant's value might be weird sometimes, it's the | |
| 127 | + // path where the PHP scripts will be most likely be able to get executed. | |
| 129 | 128 | |
| 130 | 129 | try { |
| 130 | + if ( Throw_On_Errors::t_is_dir( ABSPATH ) ) { | |
| 131 | + $abspath_dir = Throw_On_Errors::t_realpath( ABSPATH ); | |
| 132 | + $locations[ $abspath_dir ] = $abspath_url; | |
| 133 | + } | |
| 134 | + } catch ( Exception $exception ) { | |
| 135 | + $locations[ ABSPATH ] = new WP_Error( | |
| 136 | + 'abspath_missing', | |
| 137 | + 'Unable to access WordPress root "' . ABSPATH . '": ' . $exception->getMessage(), | |
| 138 | + array( 'status' => 500 ) | |
| 139 | + ); | |
| 140 | + } | |
| 141 | + | |
| 142 | + try { | |
| 131 | 143 | if ( Throw_On_Errors::t_is_dir( WP_CONTENT_DIR ) ) { |
| 132 | 144 | $wp_content_dir = Throw_On_Errors::t_realpath( WP_CONTENT_DIR ); |
| 133 | 145 | |
| 134 | 146 | // Using content_url() instead of WP_CONTENT_URL as it tests for whether we're using SSL. |
| @@ -175,21 +187,8 @@ | ||
| 175 | 187 | } catch ( Exception $exception ) { |
| 176 | 188 | $locations[ $wp_uploads_dir ] = new WP_Error( |
| 177 | 189 | 'uploads_path_missing', |
| 178 | 190 | 'Unable to access uploads path "' . $wp_uploads_dir . '"' . $exception->getMessage(), |
| 179 | - array( 'status' => 500 ) | |
| 180 | - ); | |
| 181 | - } | |
| 182 | - | |
| 183 | - try { | |
| 184 | - if ( Throw_On_Errors::t_is_dir( ABSPATH ) ) { | |
| 185 | - $abspath_dir = Throw_On_Errors::t_realpath( ABSPATH ); | |
| 186 | - $locations[ $abspath_dir ] = $abspath_url; | |
| 187 | - } | |
| 188 | - } catch ( Exception $exception ) { | |
| 189 | - $locations[ ABSPATH ] = new WP_Error( | |
| 190 | - 'abspath_missing', | |
| 191 | - 'Unable to access WordPress root "' . ABSPATH . '": ' . $exception->getMessage(), | |
| 192 | 191 | array( 'status' => 500 ) |
| 193 | 192 | ); |
| 194 | 193 | } |
| 195 | 194 | |