Plugin Directory

Changeset 3847006


Ignore:
Timestamp:
12/06/2026 02:06:04 AM (less than one hour ago)
Author:
marnstudio
Message:

Release 1.2.3: Add FTP directory diagnostics on Test Connection

Location:
marn-easy-migrate
Files:
3 edited
12 copied

Legend:

Unmodified
Added
Removed
  • marn-easy-migrate/tags/1.2.3/includes/storage/class-wpzm-storage-ftp.php

    r3847002 r3847006  
    1414
    1515        /**
     16         * Last directory error encountered during mkdir/chdir.
     17         *
     18         * @var string
     19         */
     20        private $last_dir_error = '';
     21
     22        /**
    1623         * {@inheritdoc}
    1724         */
    … …  
    154161                foreach ( $parts as $part ) {
    155162                        if ( ! @ftp_chdir( $conn, $part ) ) {
    156                                 @ftp_mkdir( $conn, $part );
     163                                $created = @ftp_mkdir( $conn, $part );
     164                                if ( false === $created ) {
     165                                        $err = error_get_last();
     166                                        if ( is_array( $err ) && ! empty( $err['message'] ) ) {
     167                                                $this->last_dir_error = wp_strip_all_tags( $err['message'] );
     168                                        }
     169                                }
    157170                                if ( ! @ftp_chdir( $conn, $part ) ) {
    158171                                        return false;
    … …  
    161174                }
    162175                return true;
     176        }
     177
     178        /**
     179         * List up to 8 top-level entry names in the current FTP directory for diagnostics.
     180         *
     181         * @param resource|\FTP\Connection $conn Active FTP connection.
     182         * @return array
     183         */
     184        private function list_dir_entries( $conn ) {
     185                $raw   = @ftp_nlist( $conn, '.' );
     186                $names = array();
     187                if ( is_array( $raw ) ) {
     188                        foreach ( $raw as $item ) {
     189                                $name = basename( (string) $item );
     190                                if ( '' === $name || '.' === $name || '..' === $name ) {
     191                                        continue;
     192                                }
     193                                $names[] = $name;
     194                                if ( count( $names ) >= 8 ) {
     195                                        break;
     196                                }
     197                        }
     198                }
     199                return $names;
    163200        }
    164201
    … …  
    211248         */
    212249        public function test_connection( array $config ) {
    213                 $res = $this->connect( $config );
     250                $this->last_dir_error = '';
     251                $res                  = $this->connect( $config );
    214252                if ( empty( $res['success'] ) ) {
    215253                        return $res;
    … …  
    218256                $conn        = $res['conn'];
    219257                $home_dir    = @ftp_pwd( $conn );
     258                $home_items  = $this->list_dir_entries( $conn );
    220259                $remote_path = isset( $config['remote_path'] ) ? (string) $config['remote_path'] : '';
    221260
    222261                if ( '' !== trim( $remote_path ) && ! $this->ensure_remote_dir( $conn, $remote_path ) ) {
    223                         $last_err = error_get_last();
    224                         $detail   = ( is_array( $last_err ) && ! empty( $last_err['message'] ) ) ? ' ' . wp_strip_all_tags( $last_err['message'] ) : '';
     262                        $detail = '' !== $this->last_dir_error ? ' (' . $this->last_dir_error . ')' : '';
     263                        $hint   = ! empty( $home_items )
     264                                ? ' ' . sprintf(
     265                                        /* translators: %s: comma-separated list of existing folders/items in FTP home directory */
     266                                        __( 'Available items in home directory: %s', 'marn-easy-migrate' ),
     267                                        implode( ', ', $home_items )
     268                                )
     269                                : '';
    225270                        @ftp_close( $conn );
    226271                        return array(
    227272                                'success' => false,
    228273                                'message' => sprintf(
    229                                         /* translators: 1: initial FTP home directory, 2: optional FTP error detail */
    230                                         __( 'Connected to FTP server (home directory: %1$s), but could not access or create the specified remote directory.%2$s', 'marn-easy-migrate' ),
     274                                        /* translators: 1: initial FTP home directory, 2: optional error detail, 3: optional list of available folders */
     275                                        __( 'Connected to FTP server (home directory: %1$s), but could not access or create the specified remote directory.%2$s%3$s', 'marn-easy-migrate' ),
    231276                                        is_string( $home_dir ) && '' !== $home_dir ? $home_dir : '/',
    232                                         $detail
     277                                        $detail,
     278                                        $hint
    233279                                ),
    234280                        );
    … …  
    236282
    237283                $active_dir = @ftp_pwd( $conn );
     284                $items_hint = ! empty( $home_items ) && ( '/' === trim( $remote_path ) || '' === trim( $remote_path ) )
     285                        ? ' | ' . sprintf(
     286                                /* translators: %s: comma-separated list of items */
     287                                __( 'Items: %s', 'marn-easy-migrate' ),
     288                                implode( ', ', $home_items )
     289                        )
     290                        : '';
    238291                @ftp_close( $conn );
    239292
    … …  
    241294                        'success' => true,
    242295                        'message' => sprintf(
    243                                 /* translators: %s: active remote FTP directory */
    244                                 __( 'FTP connection successful! Active directory: %s', 'marn-easy-migrate' ),
    245                                 is_string( $active_dir ) && '' !== $active_dir ? $active_dir : '/'
     296                                /* translators: 1: active remote FTP directory, 2: optional list of items */
     297                                __( 'FTP connection successful! Active directory: %1$s%2$s', 'marn-easy-migrate' ),
     298                                is_string( $active_dir ) && '' !== $active_dir ? $active_dir : '/',
     299                                $items_hint
    246300                        ),
    247301                );
  • marn-easy-migrate/tags/1.2.3/marn-easy-migrate.php

    r3847002 r3847006  
    44 * Plugin URI:        https://marn-easy-migrate.marnstudio.click/
    55 * Description:       Export and import full WordPress site (database and files) as a clean .zip package with automated domain/path replacement.
    6  * Version:           1.2.2
     6 * Version:           1.2.3
    77 * Requires at least: 6.0
    88 * Requires PHP:      7.4
    … …  
    3333
    3434// Plugin constants.
    35 define( 'WPZM_VERSION', '1.2.2' );
     35define( 'WPZM_VERSION', '1.2.3' );
    3636define( 'WPZM_FILE', __FILE__ );
    3737define( 'WPZM_PATH', plugin_dir_path( __FILE__ ) );
  • marn-easy-migrate/tags/1.2.3/readme.txt

    r3847002 r3847006  
    66Tested up to: 7.1
    77Requires PHP: 7.4
    8 Stable tag: 1.2.2
     8Stable tag: 1.2.3
    99License: GPLv2 or later
    1010License URI: https://www.gnu.org/licenses/gpl-2.0.html
    … …  
    8383== Changelog ==
    8484
     85= 1.2.3 =
     86* Enhancement: Improve FTP Test Connection diagnostics to display exact `ftp_mkdir()` errors and list available folders in the FTP home directory.
     87
    8588= 1.2.2 =
    8689* Bugfix: Improve FTP remote directory creation (`ensure_remote_dir`) to automatically fall back to the FTP account's home directory when root `/` is not writable, fix nested subdirectory path handling, and report the active FTP directory on Test Connection.
  • marn-easy-migrate/trunk/includes/storage/class-wpzm-storage-ftp.php

    r3847002 r3847006  
    1414
    1515        /**
     16         * Last directory error encountered during mkdir/chdir.
     17         *
     18         * @var string
     19         */
     20        private $last_dir_error = '';
     21
     22        /**
    1623         * {@inheritdoc}
    1724         */
    … …  
    154161                foreach ( $parts as $part ) {
    155162                        if ( ! @ftp_chdir( $conn, $part ) ) {
    156                                 @ftp_mkdir( $conn, $part );
     163                                $created = @ftp_mkdir( $conn, $part );
     164                                if ( false === $created ) {
     165                                        $err = error_get_last();
     166                                        if ( is_array( $err ) && ! empty( $err['message'] ) ) {
     167                                                $this->last_dir_error = wp_strip_all_tags( $err['message'] );
     168                                        }
     169                                }
    157170                                if ( ! @ftp_chdir( $conn, $part ) ) {
    158171                                        return false;
    … …  
    161174                }
    162175                return true;
     176        }
     177
     178        /**
     179         * List up to 8 top-level entry names in the current FTP directory for diagnostics.
     180         *
     181         * @param resource|\FTP\Connection $conn Active FTP connection.
     182         * @return array
     183         */
     184        private function list_dir_entries( $conn ) {
     185                $raw   = @ftp_nlist( $conn, '.' );
     186                $names = array();
     187                if ( is_array( $raw ) ) {
     188                        foreach ( $raw as $item ) {
     189                                $name = basename( (string) $item );
     190                                if ( '' === $name || '.' === $name || '..' === $name ) {
     191                                        continue;
     192                                }
     193                                $names[] = $name;
     194                                if ( count( $names ) >= 8 ) {
     195                                        break;
     196                                }
     197                        }
     198                }
     199                return $names;
    163200        }
    164201
    … …  
    211248         */
    212249        public function test_connection( array $config ) {
    213                 $res = $this->connect( $config );
     250                $this->last_dir_error = '';
     251                $res                  = $this->connect( $config );
    214252                if ( empty( $res['success'] ) ) {
    215253                        return $res;
    … …  
    218256                $conn        = $res['conn'];
    219257                $home_dir    = @ftp_pwd( $conn );
     258                $home_items  = $this->list_dir_entries( $conn );
    220259                $remote_path = isset( $config['remote_path'] ) ? (string) $config['remote_path'] : '';
    221260
    222261                if ( '' !== trim( $remote_path ) && ! $this->ensure_remote_dir( $conn, $remote_path ) ) {
    223                         $last_err = error_get_last();
    224                         $detail   = ( is_array( $last_err ) && ! empty( $last_err['message'] ) ) ? ' ' . wp_strip_all_tags( $last_err['message'] ) : '';
     262                        $detail = '' !== $this->last_dir_error ? ' (' . $this->last_dir_error . ')' : '';
     263                        $hint   = ! empty( $home_items )
     264                                ? ' ' . sprintf(
     265                                        /* translators: %s: comma-separated list of existing folders/items in FTP home directory */
     266                                        __( 'Available items in home directory: %s', 'marn-easy-migrate' ),
     267                                        implode( ', ', $home_items )
     268                                )
     269                                : '';
    225270                        @ftp_close( $conn );
    226271                        return array(
    227272                                'success' => false,
    228273                                'message' => sprintf(
    229                                         /* translators: 1: initial FTP home directory, 2: optional FTP error detail */
    230                                         __( 'Connected to FTP server (home directory: %1$s), but could not access or create the specified remote directory.%2$s', 'marn-easy-migrate' ),
     274                                        /* translators: 1: initial FTP home directory, 2: optional error detail, 3: optional list of available folders */
     275                                        __( 'Connected to FTP server (home directory: %1$s), but could not access or create the specified remote directory.%2$s%3$s', 'marn-easy-migrate' ),
    231276                                        is_string( $home_dir ) && '' !== $home_dir ? $home_dir : '/',
    232                                         $detail
     277                                        $detail,
     278                                        $hint
    233279                                ),
    234280                        );
    … …  
    236282
    237283                $active_dir = @ftp_pwd( $conn );
     284                $items_hint = ! empty( $home_items ) && ( '/' === trim( $remote_path ) || '' === trim( $remote_path ) )
     285                        ? ' | ' . sprintf(
     286                                /* translators: %s: comma-separated list of items */
     287                                __( 'Items: %s', 'marn-easy-migrate' ),
     288                                implode( ', ', $home_items )
     289                        )
     290                        : '';
    238291                @ftp_close( $conn );
    239292
    … …  
    241294                        'success' => true,
    242295                        'message' => sprintf(
    243                                 /* translators: %s: active remote FTP directory */
    244                                 __( 'FTP connection successful! Active directory: %s', 'marn-easy-migrate' ),
    245                                 is_string( $active_dir ) && '' !== $active_dir ? $active_dir : '/'
     296                                /* translators: 1: active remote FTP directory, 2: optional list of items */
     297                                __( 'FTP connection successful! Active directory: %1$s%2$s', 'marn-easy-migrate' ),
     298                                is_string( $active_dir ) && '' !== $active_dir ? $active_dir : '/',
     299                                $items_hint
    246300                        ),
    247301                );
  • marn-easy-migrate/trunk/marn-easy-migrate.php

    r3847002 r3847006  
    44 * Plugin URI:        https://marn-easy-migrate.marnstudio.click/
    55 * Description:       Export and import full WordPress site (database and files) as a clean .zip package with automated domain/path replacement.
    6  * Version:           1.2.2
     6 * Version:           1.2.3
    77 * Requires at least: 6.0
    88 * Requires PHP:      7.4
    … …  
    3333
    3434// Plugin constants.
    35 define( 'WPZM_VERSION', '1.2.2' );
     35define( 'WPZM_VERSION', '1.2.3' );
    3636define( 'WPZM_FILE', __FILE__ );
    3737define( 'WPZM_PATH', plugin_dir_path( __FILE__ ) );
  • marn-easy-migrate/trunk/readme.txt

    r3847002 r3847006  
    66Tested up to: 7.1
    77Requires PHP: 7.4
    8 Stable tag: 1.2.2
     8Stable tag: 1.2.3
    99License: GPLv2 or later
    1010License URI: https://www.gnu.org/licenses/gpl-2.0.html
    … …  
    8383== Changelog ==
    8484
     85= 1.2.3 =
     86* Enhancement: Improve FTP Test Connection diagnostics to display exact `ftp_mkdir()` errors and list available folders in the FTP home directory.
     87
    8588= 1.2.2 =
    8689* Bugfix: Improve FTP remote directory creation (`ensure_remote_dir`) to automatically fall back to the FTP account's home directory when root `/` is not writable, fix nested subdirectory path handling, and report the active FTP directory on Test Connection.
Note: See TracChangeset for help on using the changeset viewer.