Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
afragen committed Apr 4, 2022
2 parents ae7f293 + 113158c commit 65adf78
Show file tree
Hide file tree
Showing 13 changed files with 146 additions and 96 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#### [unreleased]

#### 10.8.0 / 2022-04-03
* use `move_dir()` and `is_virtualbox()` from [#51875](https://core.trac.wordpress.org/ticket/51857) [PR #2225](https://github.com/WordPress/wordpress-develop/pull/2225/files)
* revert fix directory rename for single file plugin update

#### 10.7.2 / 2022-03-31
* fix directory rename for single file plugin update
* revert GitHub_API release asset URL to return to redirect URL
Expand Down
2 changes: 1 addition & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion git-updater.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* Plugin Name: Git Updater
* Plugin URI: https://git-updater.com
* Description: A plugin to automatically update GitHub hosted plugins, themes, and language packs. Additional API plugins available for Bitbucket, GitLab, Gitea, and Gist.
* Version: 10.7.2
* Version: 10.8.0
* Author: Andy Fragen
* License: MIT
* Domain Path: /languages
Expand Down
20 changes: 10 additions & 10 deletions languages/git-updater.pot
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
# This file is distributed under the MIT.
msgid ""
msgstr ""
"Project-Id-Version: Git Updater 10.7.1\n"
"Project-Id-Version: Git Updater 10.8.0\n"
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/git-updater\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"POT-Creation-Date: 2022-03-12T22:24:53+00:00\n"
"POT-Creation-Date: 2022-04-04T04:35:59+00:00\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"X-Generator: WP-CLI 2.6.0\n"
"X-Domain: git-updater\n"
Expand Down Expand Up @@ -110,35 +110,35 @@ msgstr ""
msgid "Free Trial"
msgstr ""

#: src/Git_Updater/API/GitHub_API.php:354
#: src/Git_Updater/API/GitHub_API.php:351
msgid "GitHub Personal Access Token"
msgstr ""

#: src/Git_Updater/API/GitHub_API.php:361
#: src/Git_Updater/API/GitHub_API.php:358
msgid "GitHub.com Access Token"
msgstr ""

#: src/Git_Updater/API/GitHub_API.php:377
#: src/Git_Updater/API/GitHub_API.php:374
msgid "GitHub Private Settings"
msgstr ""

#: src/Git_Updater/API/GitHub_API.php:404
#: src/Git_Updater/API/GitHub_API.php:401
msgid "Enter your GitHub Access Token. Leave empty for public repositories."
msgstr ""

#: src/Git_Updater/API/GitHub_API.php:411
#: src/Git_Updater/API/GitHub_API.php:408
msgid "Enter your personal GitHub.com or GitHub Enterprise Access Token to avoid API access limits."
msgstr ""

#: src/Git_Updater/API/GitHub_API.php:422
#: src/Git_Updater/API/GitHub_API.php:419
msgid "GitHub Access Token"
msgstr ""

#: src/Git_Updater/API/GitHub_API.php:436
#: src/Git_Updater/API/GitHub_API.php:433
msgid "GitHub"
msgstr ""

#: src/Git_Updater/API/GitHub_API.php:450
#: src/Git_Updater/API/GitHub_API.php:447
msgid "Enter GitHub Access Token for private GitHub repositories."
msgstr ""

Expand Down
16 changes: 5 additions & 11 deletions src/Git_Updater/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,11 @@ public function upgrader_source_selection( $source, $remote_source, $upgrader, $
$new_source = $this->fix_misnamed_directory( $new_source, $remote_source, $upgrader_object, $slug );

if ( $source !== $new_source ) {
$this->move( $source, $new_source );
if ( function_exists( 'move_dir' ) ) {
move_dir( $source, $new_source );
} else {
$this->move_dir( $source, $new_source );
}
}

return trailingslashit( $new_source );
Expand Down Expand Up @@ -545,16 +549,6 @@ private function fix_misnamed_directory( $new_source, $remote_source, $upgrader_
$new_source = trailingslashit( $remote_source ) . $slug;
}

// Move single file plugins into their own directory.
$single_file_plugin = isset( $config['.'] ) ? $config['.'] : false;
if ( $single_file_plugin
&& ( \property_exists( $single_file_plugin, 'slug' ) && '.' === $single_file_plugin->slug )
) {
// Strip `.php` from the filename.
$slug = substr( $single_file_plugin->file, 0, -4 );
$new_source = trailingslashit( $remote_source ) . $slug;
}

return $new_source;
}

Expand Down
157 changes: 113 additions & 44 deletions src/Git_Updater/Traits/GU_Trait.php
Original file line number Diff line number Diff line change
Expand Up @@ -688,71 +688,140 @@ public static function get_plugin_version() {
}

/**
* Rename or recursive file copy and delete.
* Moves a directory from one location to another via the rename() PHP function.
* If the renaming failed, falls back to copy_dir().
*
* This is more versatile than `$wp_filesystem->move()` for FS_METHOD 'direct'.
* It moves/renames directories as well as files.
* Fix for https://github.com/afragen/github-updater/issues/826,
* strange failure of `rename()`.
* Assumes that WP_Filesystem() has already been called and setup.
*
* @param string $source File path of source.
* @param string $destination File path of destination.
* @since 6.1.0
*
* @return bool True for success, false for failure.
* @global WP_Filesystem_Base $wp_filesystem WordPress filesystem subclass.
*
* @param string $from Source directory.
* @param string $to Destination directory.
*
* @return true|WP_Error True on success, WP_Error on failure.
*/
public function move( $source, $destination ) {
if ( $this->filesystem_move( $source, $destination ) ) {
return true;
public function move_dir( $from, $to ) {
global $wp_filesystem;

$result = false;

/*
* Skip the rename() call on VirtualBox environments.
* There are some known issues where rename() can fail on shared folders
* without reporting an error properly.
*
* More details:
* https://www.virtualbox.org/ticket/8761#comment:24
* https://www.virtualbox.org/ticket/17971
*/
if ( 'direct' === $wp_filesystem->method && ! $this->is_virtualbox() ) {
$wp_filesystem->rmdir( $to );

$result = @rename( $from, $to );
}
if ( is_dir( $destination ) && rename( $source, $destination ) ) {
return true;

// Non-direct filesystems use some version of rename without a fallback.
if ( 'direct' !== $wp_filesystem->method ) {
$result = $wp_filesystem->move( $from, $to );
}
// phpcs:ignore WordPress.CodeAnalysis.AssignmentInCondition.Found, Squiz.PHP.DisallowMultipleAssignments.FoundInControlStructure
if ( $dir = opendir( $source ) ) {
if ( ! file_exists( $destination ) ) {
mkdir( $destination );
}
$source = untrailingslashit( $source );
// phpcs:ignore WordPress.CodeAnalysis.AssignmentInCondition.FoundInWhileCondition
while ( false !== ( $file = readdir( $dir ) ) ) {
if ( ( '.' !== $file ) && ( '..' !== $file ) && "{$source}/{$file}" !== $destination ) {
if ( is_dir( "{$source}/{$file}" ) ) {
$this->move( "{$source}/{$file}", "{$destination}/{$file}" );
} else {
copy( "{$source}/{$file}", "{$destination}/{$file}" );
unlink( "{$source}/{$file}" );
}

if ( ! $result ) {
if ( ! $wp_filesystem->is_dir( $to ) ) {
if ( ! $wp_filesystem->mkdir( $to, FS_CHMOD_DIR ) ) {
return new WP_Error( 'mkdir_failed_move_dir', __( 'Could not create directory.' ), $to );
}
}
$iterator = new \FilesystemIterator( $source );
if ( ! $iterator->valid() ) { // True if directory is empty.
rmdir( $source );
}
closedir( $dir );

return true;
$result = copy_dir( $from, $to );

if ( ! is_wp_error( $result ) ) {
// Clear the source directory.
$wp_filesystem->delete( $from, true );
}
}

return false;
return $result;
}

/**
* Non-direct filesystem move.
* Attempt to detect a VirtualBox environment.
*
* This attempts all known methods of detecting VirtualBox.
*
* @uses $wp_filesystem->move() when FS_METHOD is not 'direct'
* @global $wp_filesystem The filesystem.
*
* @param string $source File path of source.
* @param string $destination File path of destination.
* @since 6.1.0
*
* @return bool|void True on success, false on failure.
* @return bool Whether or not VirtualBox was detected.
*/
public function filesystem_move( $source, $destination ) {
public function is_virtualbox() {
global $wp_filesystem;
if ( 'direct' !== $wp_filesystem->method ) {
return $wp_filesystem->move( $source, $destination );
static $is_virtualbox;

if ( null !== $is_virtualbox ) {
return $is_virtualbox;
}

return false;
// Detection via filter.
if ( apply_filters( 'is_virtualbox', false ) ) {
$is_virtualbox = true;
return $is_virtualbox;
}

// Detection via Composer.
if ( function_exists( 'getenv' ) && 'virtualbox' === getenv( 'COMPOSER_RUNTIME_ENV' ) ) {
$is_virtualbox = true;
return $is_virtualbox;
}

$virtualbox_unames = [ 'vvv' ];

// Detection via `php_uname()`.
if ( function_exists( 'php_uname' ) && in_array( php_uname( 'n' ), $virtualbox_unames, true ) ) {
$is_virtualbox = true;
return $is_virtualbox;
}

/*
* Vagrant can use alternative providers.
* This isn't reliable without some additional check(s).
*/
$virtualbox_usernames = [ 'vagrant' ];

// Detection via user name with POSIX.
if ( function_exists( 'posix_getpwuid' ) && function_exists( 'posix_geteuid' ) ) {
$user = posix_getpwuid( posix_geteuid() );

if ( $user && in_array( $user['name'], $virtualbox_usernames, true ) ) {
$is_virtualbox = true;
return $is_virtualbox;
}
}

// Initialize the filesystem if not set.
if ( ! $wp_filesystem ) {
require_once ABSPATH . '/wp-admin/includes/file.php';
WP_Filesystem();
}

// Detection via file owner.
if ( in_array( $wp_filesystem->owner( __FILE__ ), $virtualbox_usernames, true ) ) {
$is_virtualbox = true;
return $is_virtualbox;
}

// Detection via file group.
if ( in_array( $wp_filesystem->group( __FILE__ ), $virtualbox_usernames, true ) ) {
$is_virtualbox = true;
return $is_virtualbox;
}

// Give up.
$is_virtualbox = false;

return $is_virtualbox;
}

/**
Expand Down
2 changes: 2 additions & 0 deletions vendor/composer/InstalledVersions.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
* See also https://getcomposer.org/doc/07-runtime.md#installed-versions
*
* To require its presence, you can require `composer-runtime-api ^2.0`
*
* @final
*/
class InstalledVersions
{
Expand Down
2 changes: 1 addition & 1 deletion vendor/composer/autoload_classmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

// autoload_classmap.php @generated by Composer

$vendorDir = dirname(dirname(__FILE__));
$vendorDir = dirname(__DIR__);
$baseDir = dirname($vendorDir);

return array(
Expand Down
2 changes: 1 addition & 1 deletion vendor/composer/autoload_namespaces.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

// autoload_namespaces.php @generated by Composer

$vendorDir = dirname(dirname(__FILE__));
$vendorDir = dirname(__DIR__);
$baseDir = dirname($vendorDir);

return array(
Expand Down
2 changes: 1 addition & 1 deletion vendor/composer/autoload_psr4.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

// autoload_psr4.php @generated by Composer

$vendorDir = dirname(dirname(__FILE__));
$vendorDir = dirname(__DIR__);
$baseDir = dirname($vendorDir);

return array(
Expand Down
25 changes: 3 additions & 22 deletions vendor/composer/autoload_real.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,30 +25,11 @@ public static function getLoader()
require __DIR__ . '/platform_check.php';

spl_autoload_register(array('ComposerAutoloaderInita27e6a3df8c435e2b136f961f0442be2', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
spl_autoload_unregister(array('ComposerAutoloaderInita27e6a3df8c435e2b136f961f0442be2', 'loadClassLoader'));

$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
if ($useStaticLoader) {
require __DIR__ . '/autoload_static.php';

call_user_func(\Composer\Autoload\ComposerStaticInita27e6a3df8c435e2b136f961f0442be2::getInitializer($loader));
} else {
$map = require __DIR__ . '/autoload_namespaces.php';
foreach ($map as $namespace => $path) {
$loader->set($namespace, $path);
}

$map = require __DIR__ . '/autoload_psr4.php';
foreach ($map as $namespace => $path) {
$loader->setPsr4($namespace, $path);
}

$classMap = require __DIR__ . '/autoload_classmap.php';
if ($classMap) {
$loader->addClassMap($classMap);
}
}
require __DIR__ . '/autoload_static.php';
\Composer\Autoload\ComposerStaticInita27e6a3df8c435e2b136f961f0442be2::getInitializer($loader)();

$loader->register(true);

Expand Down
2 changes: 1 addition & 1 deletion vendor/composer/installed.json
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,6 @@
"install-path": "../freemius/wordpress-sdk"
}
],
"dev": false,
"dev": true,
"dev-package-names": []
}
Loading

0 comments on commit 65adf78

Please sign in to comment.