Skip to content

Commit

Permalink
Bump version number to 4.6
Browse files Browse the repository at this point in the history
  • Loading branch information
YahnisElsts committed Apr 2, 2019
1 parent 006bb93 commit 45374e3
Show file tree
Hide file tree
Showing 35 changed files with 202 additions and 202 deletions.
2 changes: 1 addition & 1 deletion Puc/v4/Factory.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
if ( !class_exists('Puc_v4_Factory', false) ):

class Puc_v4_Factory extends Puc_v4p5_Factory { }
class Puc_v4_Factory extends Puc_v4p6_Factory { }

endif;
4 changes: 2 additions & 2 deletions Puc/v4p5/Autoloader.php → Puc/v4p6/Autoloader.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

if ( !class_exists('Puc_v4p5_Autoloader', false) ):
if ( !class_exists('Puc_v4p6_Autoloader', false) ):

class Puc_v4p5_Autoloader {
class Puc_v4p6_Autoloader {
private $prefix = '';
private $rootDir = '';
private $libraryDir = '';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?php
if ( !class_exists('Puc_v4p5_DebugBar_Extension', false) ):
if ( !class_exists('Puc_v4p6_DebugBar_Extension', false) ):

class Puc_v4p5_DebugBar_Extension {
class Puc_v4p6_DebugBar_Extension {
const RESPONSE_BODY_LENGTH_LIMIT = 4000;

/** @var Puc_v4p5_UpdateChecker */
/** @var Puc_v4p6_UpdateChecker */
protected $updateChecker;
protected $panelClass = 'Puc_v4p5_DebugBar_Panel';
protected $panelClass = 'Puc_v4p6_DebugBar_Panel';

public function __construct($updateChecker, $panelClass = null) {
$this->updateChecker = $updateChecker;
Expand Down Expand Up @@ -150,11 +150,11 @@ private function getLibraryUrl($filePath) {
$absolutePath = realpath(dirname(__FILE__) . '/../../../' . ltrim($filePath, '/'));

//Where is the library located inside the WordPress directory structure?
$absolutePath = Puc_v4p5_Factory::normalizePath($absolutePath);
$absolutePath = Puc_v4p6_Factory::normalizePath($absolutePath);

$pluginDir = Puc_v4p5_Factory::normalizePath(WP_PLUGIN_DIR);
$muPluginDir = Puc_v4p5_Factory::normalizePath(WPMU_PLUGIN_DIR);
$themeDir = Puc_v4p5_Factory::normalizePath(get_theme_root());
$pluginDir = Puc_v4p6_Factory::normalizePath(WP_PLUGIN_DIR);
$muPluginDir = Puc_v4p6_Factory::normalizePath(WPMU_PLUGIN_DIR);
$themeDir = Puc_v4p6_Factory::normalizePath(get_theme_root());

if ( (strpos($absolutePath, $pluginDir) === 0) || (strpos($absolutePath, $muPluginDir) === 0) ) {
//It's part of a plugin.
Expand Down
6 changes: 3 additions & 3 deletions Puc/v4p5/DebugBar/Panel.php → Puc/v4p6/DebugBar/Panel.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php

if ( !class_exists('Puc_v4p5_DebugBar_Panel', false) && class_exists('Debug_Bar_Panel', false) ):
if ( !class_exists('Puc_v4p6_DebugBar_Panel', false) && class_exists('Debug_Bar_Panel', false) ):

class Puc_v4p5_DebugBar_Panel extends Debug_Bar_Panel {
/** @var Puc_v4p5_UpdateChecker */
class Puc_v4p6_DebugBar_Panel extends Debug_Bar_Panel {
/** @var Puc_v4p6_UpdateChecker */
protected $updateChecker;

private $responseBox = '<div class="puc-ajax-response" style="display: none;"></div>';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?php
if ( !class_exists('Puc_v4p5_DebugBar_PluginExtension', false) ):
if ( !class_exists('Puc_v4p6_DebugBar_PluginExtension', false) ):

class Puc_v4p5_DebugBar_PluginExtension extends Puc_v4p5_DebugBar_Extension {
/** @var Puc_v4p5_Plugin_UpdateChecker */
class Puc_v4p6_DebugBar_PluginExtension extends Puc_v4p6_DebugBar_Extension {
/** @var Puc_v4p6_Plugin_UpdateChecker */
protected $updateChecker;

public function __construct($updateChecker) {
parent::__construct($updateChecker, 'Puc_v4p5_DebugBar_PluginPanel');
parent::__construct($updateChecker, 'Puc_v4p6_DebugBar_PluginPanel');

add_action('wp_ajax_puc_v4_debug_request_info', array($this, 'ajaxRequestInfo'));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php

if ( !class_exists('Puc_v4p5_DebugBar_PluginPanel', false) ):
if ( !class_exists('Puc_v4p6_DebugBar_PluginPanel', false) ):

class Puc_v4p5_DebugBar_PluginPanel extends Puc_v4p5_DebugBar_Panel {
class Puc_v4p6_DebugBar_PluginPanel extends Puc_v4p6_DebugBar_Panel {
/**
* @var Puc_v4p5_Plugin_UpdateChecker
* @var Puc_v4p6_Plugin_UpdateChecker
*/
protected $updateChecker;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php

if ( !class_exists('Puc_v4p5_DebugBar_ThemePanel', false) ):
if ( !class_exists('Puc_v4p6_DebugBar_ThemePanel', false) ):

class Puc_v4p5_DebugBar_ThemePanel extends Puc_v4p5_DebugBar_Panel {
class Puc_v4p6_DebugBar_ThemePanel extends Puc_v4p6_DebugBar_Panel {
/**
* @var Puc_v4p5_Theme_UpdateChecker
* @var Puc_v4p6_Theme_UpdateChecker
*/
protected $updateChecker;

Expand Down
8 changes: 4 additions & 4 deletions Puc/v4p5/Factory.php → Puc/v4p6/Factory.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
if ( !class_exists('Puc_v4p5_Factory', false) ):
if ( !class_exists('Puc_v4p6_Factory', false) ):

/**
* A factory that builds update checker instances.
Expand All @@ -11,7 +11,7 @@
* At the moment it can only build instances of the UpdateChecker class. Other classes are
* intended mainly for internal use and refer directly to specific implementations.
*/
class Puc_v4p5_Factory {
class Puc_v4p6_Factory {
protected static $classVersions = array();
protected static $sorted = false;

Expand All @@ -24,15 +24,15 @@ class Puc_v4p5_Factory {
* This method automatically detects if you're using it for a plugin or a theme and chooses
* the appropriate implementation for your update source (JSON file, GitHub, BitBucket, etc).
*
* @see Puc_v4p5_UpdateChecker::__construct
* @see Puc_v4p6_UpdateChecker::__construct
*
* @param string $metadataUrl The URL of the metadata file, a GitHub repository, or another supported update source.
* @param string $fullPath Full path to the main plugin file or to the theme directory.
* @param string $slug Custom slug. Defaults to the name of the main plugin file or the theme directory.
* @param int $checkPeriod How often to check for updates (in hours).
* @param string $optionName Where to store book-keeping info about update checks.
* @param string $muPluginFile The plugin filename relative to the mu-plugins directory.
* @return Puc_v4p5_Plugin_UpdateChecker|Puc_v4p5_Theme_UpdateChecker|Puc_v4p5_Vcs_BaseChecker
* @return Puc_v4p6_Plugin_UpdateChecker|Puc_v4p6_Theme_UpdateChecker|Puc_v4p6_Vcs_BaseChecker
*/
public static function buildUpdateChecker($metadataUrl, $fullPath, $slug = '', $checkPeriod = 12, $optionName = '', $muPluginFile = '') {
$fullPath = self::normalizePath($fullPath);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<?php
if ( !class_exists('Puc_v4p5_InstalledPackage', false) ):
if ( !class_exists('Puc_v4p6_InstalledPackage', false) ):

/**
* This class represents a currently installed plugin or theme.
*
* Not to be confused with the "package" field in WP update API responses that contains
* the download URL of a the new version.
*/
abstract class Puc_v4p5_InstalledPackage {
abstract class Puc_v4p6_InstalledPackage {
/**
* @var Puc_v4p5_UpdateChecker
* @var Puc_v4p6_UpdateChecker
*/
protected $updateChecker;

Expand Down
4 changes: 2 additions & 2 deletions Puc/v4p5/Metadata.php → Puc/v4p6/Metadata.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
if ( !class_exists('Puc_v4p5_Metadata', false) ):
if ( !class_exists('Puc_v4p6_Metadata', false) ):

/**
* A base container for holding information about updates and plugin metadata.
Expand All @@ -8,7 +8,7 @@
* @copyright 2016
* @access public
*/
abstract class Puc_v4p5_Metadata {
abstract class Puc_v4p6_Metadata {

/**
* Create an instance of this class from a JSON document.
Expand Down
4 changes: 2 additions & 2 deletions Puc/v4p5/OAuthSignature.php → Puc/v4p6/OAuthSignature.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?php

if ( !class_exists('Puc_v4p5_OAuthSignature', false) ):
if ( !class_exists('Puc_v4p6_OAuthSignature', false) ):

/**
* A basic signature generator for zero-legged OAuth 1.0.
*/
class Puc_v4p5_OAuthSignature {
class Puc_v4p6_OAuthSignature {
private $consumerKey = '';
private $consumerSecret = '';

Expand Down
4 changes: 2 additions & 2 deletions Puc/v4p5/Plugin/Info.php → Puc/v4p6/Plugin/Info.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
if ( !class_exists('Puc_v4p5_Plugin_Info', false) ):
if ( !class_exists('Puc_v4p6_Plugin_Info', false) ):

/**
* A container class for holding and transforming various plugin metadata.
Expand All @@ -8,7 +8,7 @@
* @copyright 2016
* @access public
*/
class Puc_v4p5_Plugin_Info extends Puc_v4p5_Metadata {
class Puc_v4p6_Plugin_Info extends Puc_v4p6_Metadata {
//Most fields map directly to the contents of the plugin's info.json file.
//See the relevant docs for a description of their meaning.
public $name;
Expand Down
10 changes: 5 additions & 5 deletions Puc/v4p5/Plugin/Package.php → Puc/v4p6/Plugin/Package.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php
if ( !class_exists('Puc_v4p5_Plugin_Package', false) ):
if ( !class_exists('Puc_v4p6_Plugin_Package', false) ):

class Puc_v4p5_Plugin_Package extends Puc_v4p5_InstalledPackage {
class Puc_v4p6_Plugin_Package extends Puc_v4p6_InstalledPackage {
/**
* @var Puc_v4p5_Plugin_UpdateChecker
* @var Puc_v4p6_Plugin_UpdateChecker
*/
protected $updateChecker;

Expand Down Expand Up @@ -170,8 +170,8 @@ public function isMuPlugin() {
$pluginPath = realpath($this->pluginAbsolutePath);
//If realpath() fails, just normalize the syntax instead.
if (($muPluginDir === false) || ($pluginPath === false)) {
$muPluginDir = Puc_v4p5_Factory::normalizePath(WPMU_PLUGIN_DIR);
$pluginPath = Puc_v4p5_Factory::normalizePath($this->pluginAbsolutePath);
$muPluginDir = Puc_v4p6_Factory::normalizePath(WPMU_PLUGIN_DIR);
$pluginPath = Puc_v4p6_Factory::normalizePath($this->pluginAbsolutePath);
}

$cachedResult = (strpos($pluginPath, $muPluginDir) === 0);
Expand Down
6 changes: 3 additions & 3 deletions Puc/v4p5/Plugin/Ui.php → Puc/v4p6/Plugin/Ui.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<?php
if ( !class_exists('Puc_v4p5_Plugin_Ui', false) ):
if ( !class_exists('Puc_v4p6_Plugin_Ui', false) ):
/**
* Additional UI elements for plugins.
*/
class Puc_v4p5_Plugin_Ui {
class Puc_v4p6_Plugin_Ui {
private $updateChecker;
private $manualCheckErrorTransient = '';

/**
* @param Puc_v4p5_Plugin_UpdateChecker $updateChecker
* @param Puc_v4p6_Plugin_UpdateChecker $updateChecker
*/
public function __construct($updateChecker) {
$this->updateChecker = $updateChecker;
Expand Down
16 changes: 8 additions & 8 deletions Puc/v4p5/Plugin/Update.php → Puc/v4p6/Plugin/Update.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
if ( !class_exists('Puc_v4p5_Plugin_Update', false) ):
if ( !class_exists('Puc_v4p6_Plugin_Update', false) ):

/**
* A simple container class for holding information about an available update.
Expand All @@ -8,7 +8,7 @@
* @copyright 2016
* @access public
*/
class Puc_v4p5_Plugin_Update extends Puc_v4p5_Update {
class Puc_v4p6_Plugin_Update extends Puc_v4p6_Update {
public $id = 0;
public $homepage;
public $upgrade_notice;
Expand All @@ -24,13 +24,13 @@ class Puc_v4p5_Plugin_Update extends Puc_v4p5_Update {
* Create a new instance of PluginUpdate from its JSON-encoded representation.
*
* @param string $json
* @return Puc_v4p5_Plugin_Update|null
* @return Puc_v4p6_Plugin_Update|null
*/
public static function fromJson($json){
//Since update-related information is simply a subset of the full plugin info,
//we can parse the update JSON as if it was a plugin info string, then copy over
//the parts that we care about.
$pluginInfo = Puc_v4p5_Plugin_Info::fromJson($json);
$pluginInfo = Puc_v4p6_Plugin_Info::fromJson($json);
if ( $pluginInfo !== null ) {
return self::fromPluginInfo($pluginInfo);
} else {
Expand All @@ -42,8 +42,8 @@ public static function fromJson($json){
* Create a new instance of PluginUpdate based on an instance of PluginInfo.
* Basically, this just copies a subset of fields from one object to another.
*
* @param Puc_v4p5_Plugin_Info $info
* @return Puc_v4p5_Plugin_Update
* @param Puc_v4p6_Plugin_Info $info
* @return Puc_v4p6_Plugin_Update
*/
public static function fromPluginInfo($info){
return self::fromObject($info);
Expand All @@ -52,8 +52,8 @@ public static function fromPluginInfo($info){
/**
* Create a new instance by copying the necessary fields from another object.
*
* @param StdClass|Puc_v4p5_Plugin_Info|Puc_v4p5_Plugin_Update $object The source object.
* @return Puc_v4p5_Plugin_Update The new copy.
* @param StdClass|Puc_v4p6_Plugin_Info|Puc_v4p6_Plugin_Update $object The source object.
* @return Puc_v4p6_Plugin_Update The new copy.
*/
public static function fromObject($object) {
$update = new self();
Expand Down
Loading

2 comments on commit 45374e3

@etlam
Copy link
Contributor

@etlam etlam commented on 45374e3 May 16, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@YahnisElsts Changeing class names leads to fatal errors during the update-process when you update the library with your own WordPress plugin using the WordPress update function.
This seem to have something to do with the order the classes are loaded.
The updater starts with version 4.5 for example and when the update is finished the 4.5 updater class is missing, so there must be always a fatal error.
On the other hand, there is for me no good reason to change class names every release., it is just a lot of work and you are messing up the repository.

Could you please stop always changeing the class names?

@YahnisElsts
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm using this library in a couple of my own plugins and I haven't noticed any fatal errors during updates. I also haven't received any reports about update-related fatal errors from my users. Could you show an example, like a minimal plugin that reproduces the error?

I'd love to stop changing the class names. I'm currently doing it to avoid compatibility issues that would be caused by different plugins loading different versions of this library at the same time. Can you suggest a solution to this problem that doesn't require changing class names?

Please sign in to comment.