Skip to content

Commit

Permalink
fix: installation errors when upgrading plugin via the WordPress back…
Browse files Browse the repository at this point in the history
…end (#388)

* fix: update plugin-update-checker and set explicit filename

* ci: include top-level plugin folder in release zip.

* chore: update changelog

* chore: typo
  • Loading branch information
justlevine committed Sep 30, 2023
1 parent 07d6471 commit d4e6551
Show file tree
Hide file tree
Showing 63 changed files with 1,726 additions and 2,746 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/upload-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ jobs:
composer install --no-dev --optimize-autoloader
- name: Create Artifact
run: |
mkdir plugin-build
composer archive -vvv --format=zip --file="plugin-build/wp-graphql-gravity-forms"
mkdir -p plugin-build/wp-graphql-gravity-forms
rsync -rc --exclude-from=.distignore --exclude=plugin-build . plugin-build/wp-graphql-gravity-forms/ --delete --delete-excluded -v
cd plugin-build ; zip -r wp-graphql-gravity-forms.zip wp-graphql-gravity-forms
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

- fix: Fix installation errors when upgrading plugin via the WordPress backend.
- chore: Update `yahnis-elsts/plugin-update-checker` to v5.2.
- ci: Include top-level plugin folder in release zip.

## v0.12.3

This _minor_ release fixes a few bugs when resolving `GfEntry` data, and addresses some code smells from the updated WPGraphQL Coding Standards. We're also now testing the plugin against WordPress 6.3 and PHP 8.1.
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
],
"require": {
"php": ">=7.4",
"yahnis-elsts/plugin-update-checker": "~4.13.0"
"yahnis-elsts/plugin-update-checker": "^5.2.0"
},
"require-dev": {
"codeception/lib-innerbrowser": "^1.0",
Expand Down
525 changes: 263 additions & 262 deletions composer.lock

Large diffs are not rendered by default.

11 changes: 5 additions & 6 deletions src/UpdateChecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

namespace WPGraphQL\GF;

use Puc_v4_Factory;
use WPGraphQL\GF\Interfaces\Hookable;
use YahnisElsts\PluginUpdateChecker\v5\PucFactory;

/**
* Class - Update Checker
Expand Down Expand Up @@ -37,17 +37,16 @@ public static function check_updates(): void {
*
* @param string $repo_link The url to the repo.
*/
$repo_link = apply_filters( 'graphql_gf_update_repo_url', 'https://github.com/axewp/wp-graphql-gravity-forms/' );
$repo_link = apply_filters( 'graphql_gf_update_repo_url', 'https://github.com/AxeWP/wp-graphql-gravity-forms/' );

/** @var \Puc_v4p13_Vcs_PluginUpdateChecker */
$update_checker = Puc_v4_Factory::buildUpdateChecker(
$update_checker = PucFactory::buildUpdateChecker(
trailingslashit( $repo_link ),
WPGRAPHQL_GF_PLUGIN_FILE,
'wp-graphql-gravity-forms',
);

// @phpstan-ignore-next-line
$update_checker->getVcsApi()->enableReleaseAssets();
$update_checker->getVcsApi()->enableReleaseAssets( '/wp-graphql-gravity-forms\.zip/' );
}

/**
Expand Down
2 changes: 1 addition & 1 deletion vendor/composer/autoload_files.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
$baseDir = dirname($vendorDir);

return array(
'7166494aeff09009178f278afd86c83f' => $vendorDir . '/yahnis-elsts/plugin-update-checker/load-v4p13.php',
'efd9d646f43178e7ba3f07758c02ce1d' => $vendorDir . '/yahnis-elsts/plugin-update-checker/load-v5p2.php',
);
2 changes: 1 addition & 1 deletion vendor/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
class ComposerStaticInitf35655797d6bdd77951f2274b8dc4a3f
{
public static $files = array (
'7166494aeff09009178f278afd86c83f' => __DIR__ . '/..' . '/yahnis-elsts/plugin-update-checker/load-v4p13.php',
'efd9d646f43178e7ba3f07758c02ce1d' => __DIR__ . '/..' . '/yahnis-elsts/plugin-update-checker/load-v5p2.php',
);

public static $prefixLengthsPsr4 = array (
Expand Down
20 changes: 10 additions & 10 deletions vendor/composer/installed.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,29 @@
"packages": [
{
"name": "yahnis-elsts/plugin-update-checker",
"version": "v4.13",
"version_normalized": "4.13.0.0",
"version": "v5.2",
"version_normalized": "5.2.0.0",
"source": {
"type": "git",
"url": "https://github.com/YahnisElsts/plugin-update-checker.git",
"reference": "6eb27a6911e0e0880d09e5b11f577d3f688f7da7"
"reference": "5a270988c5f76bfdfbbb42cccc7c9627f7dd64d0"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/YahnisElsts/plugin-update-checker/zipball/6eb27a6911e0e0880d09e5b11f577d3f688f7da7",
"reference": "6eb27a6911e0e0880d09e5b11f577d3f688f7da7",
"url": "https://api.github.com/repos/YahnisElsts/plugin-update-checker/zipball/5a270988c5f76bfdfbbb42cccc7c9627f7dd64d0",
"reference": "5a270988c5f76bfdfbbb42cccc7c9627f7dd64d0",
"shasum": ""
},
"require": {
"ext-json": "*",
"php": ">=5.2.0"
"php": ">=5.6.20"
},
"time": "2022-07-29T12:36:25+00:00",
"time": "2023-08-17T12:44:32+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
"files": [
"load-v4p13.php"
"load-v5p2.php"
]
},
"notification-url": "https://packagist.org/downloads/",
Expand All @@ -35,7 +35,7 @@
{
"name": "Yahnis Elsts",
"email": "whiteshadow@w-shadow.com",
"homepage": "http://w-shadow.com/",
"homepage": "https://w-shadow.com/",
"role": "Developer"
}
],
Expand All @@ -49,7 +49,7 @@
],
"support": {
"issues": "https://github.com/YahnisElsts/plugin-update-checker/issues",
"source": "https://github.com/YahnisElsts/plugin-update-checker/tree/v4.13"
"source": "https://github.com/YahnisElsts/plugin-update-checker/tree/v5.2"
},
"install-path": "../yahnis-elsts/plugin-update-checker"
}
Expand Down
18 changes: 9 additions & 9 deletions vendor/composer/installed.php
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
<?php return array(
'root' => array(
'name' => 'harness-software/wp-graphql-gravity-forms',
'pretty_version' => 'dev-develop',
'version' => 'dev-develop',
'reference' => '2b5a054a418805892516a3ea6b322afdb890dd79',
'pretty_version' => 'dev-main',
'version' => 'dev-main',
'reference' => '07d6471beff1304aa7e8db183ec63df20ab89800',
'type' => 'wordpress-plugin',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
'dev' => false,
),
'versions' => array(
'harness-software/wp-graphql-gravity-forms' => array(
'pretty_version' => 'dev-develop',
'version' => 'dev-develop',
'reference' => '2b5a054a418805892516a3ea6b322afdb890dd79',
'pretty_version' => 'dev-main',
'version' => 'dev-main',
'reference' => '07d6471beff1304aa7e8db183ec63df20ab89800',
'type' => 'wordpress-plugin',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
'dev_requirement' => false,
),
'yahnis-elsts/plugin-update-checker' => array(
'pretty_version' => 'v4.13',
'version' => '4.13.0.0',
'reference' => '6eb27a6911e0e0880d09e5b11f577d3f688f7da7',
'pretty_version' => 'v5.2',
'version' => '5.2.0.0',
'reference' => '5a270988c5f76bfdfbbb42cccc7c9627f7dd64d0',
'type' => 'library',
'install_path' => __DIR__ . '/../yahnis-elsts/plugin-update-checker',
'aliases' => array(),
Expand Down
1 change: 1 addition & 0 deletions vendor/yahnis-elsts/plugin-update-checker/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build export-ignore
6 changes: 0 additions & 6 deletions vendor/yahnis-elsts/plugin-update-checker/Puc/v4/Factory.php

This file was deleted.

70 changes: 0 additions & 70 deletions vendor/yahnis-elsts/plugin-update-checker/Puc/v4p13/Autoloader.php

This file was deleted.

This file was deleted.

10 changes: 10 additions & 0 deletions vendor/yahnis-elsts/plugin-update-checker/Puc/v5/PucFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace YahnisElsts\PluginUpdateChecker\v5;

if ( !class_exists(PucFactory::class, false) ):

class PucFactory extends \YahnisElsts\PluginUpdateChecker\v5p2\PucFactory {
}

endif;
86 changes: 86 additions & 0 deletions vendor/yahnis-elsts/plugin-update-checker/Puc/v5p2/Autoloader.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<?php

namespace YahnisElsts\PluginUpdateChecker\v5p2;

if ( !class_exists(Autoloader::class, false) ):

class Autoloader {
const DEFAULT_NS_PREFIX = 'YahnisElsts\\PluginUpdateChecker\\';

private $prefix;
private $rootDir;
private $libraryDir;

private $staticMap;

public function __construct() {
$this->rootDir = dirname(__FILE__) . '/';

$namespaceWithSlash = __NAMESPACE__ . '\\';
$this->prefix = $namespaceWithSlash;

$this->libraryDir = $this->rootDir . '../..';
if ( !self::isPhar() ) {
$this->libraryDir = realpath($this->libraryDir);
}
$this->libraryDir = $this->libraryDir . '/';

//Usually, dependencies like Parsedown are in the global namespace,
//but if someone adds a custom namespace to the entire library, they
//will be in the same namespace as this class.
$isCustomNamespace = (
substr($namespaceWithSlash, 0, strlen(self::DEFAULT_NS_PREFIX)) !== self::DEFAULT_NS_PREFIX
);
$libraryPrefix = $isCustomNamespace ? $namespaceWithSlash : '';

$this->staticMap = array(
$libraryPrefix . 'PucReadmeParser' => 'vendor/PucReadmeParser.php',
$libraryPrefix . 'Parsedown' => 'vendor/Parsedown.php',
);

//Add the generic, major-version-only factory class to the static map.
$versionSeparatorPos = strrpos(__NAMESPACE__, '\\v');
if ( $versionSeparatorPos !== false ) {
$versionSegment = substr(__NAMESPACE__, $versionSeparatorPos + 1);
$pointPos = strpos($versionSegment, 'p');
if ( ($pointPos !== false) && ($pointPos > 1) ) {
$majorVersionSegment = substr($versionSegment, 0, $pointPos);
$majorVersionNs = __NAMESPACE__ . '\\' . $majorVersionSegment;
$this->staticMap[$majorVersionNs . '\\PucFactory'] =
'Puc/' . $majorVersionSegment . '/Factory.php';
}
}

spl_autoload_register(array($this, 'autoload'));
}

/**
* Determine if this file is running as part of a Phar archive.
*
* @return bool
*/
private static function isPhar() {
//Check if the current file path starts with "phar://".
static $pharProtocol = 'phar://';
return (substr(__FILE__, 0, strlen($pharProtocol)) === $pharProtocol);
}

public function autoload($className) {
if ( isset($this->staticMap[$className]) && file_exists($this->libraryDir . $this->staticMap[$className]) ) {
include($this->libraryDir . $this->staticMap[$className]);
return;
}

if ( strpos($className, $this->prefix) === 0 ) {
$path = substr($className, strlen($this->prefix));
$path = str_replace(array('_', '\\'), '/', $path);
$path = $this->rootDir . $path . '.php';

if ( file_exists($path) ) {
include $path;
}
}
}
}

endif;
Loading

0 comments on commit d4e6551

Please sign in to comment.