From 4e12de40f87725c842ba1e987047edf79006525c Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sat, 30 Aug 2014 07:19:37 +0200 Subject: [PATCH 01/19] Fix 'PHP Notice: unserialize(): Error at offset ...' errors These kind of errors are caused most of the time by: - unescaped quotes/slashes etc - miscounted unicode characters The change in this commit fixes this, though it does mean the cache directory has to be cleared completely (once - on upgrade to the version which includes this fix) for the fix to take effect. --- includes/Wpup/FileCache.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/Wpup/FileCache.php b/includes/Wpup/FileCache.php index aa76b2c..57c166e 100644 --- a/includes/Wpup/FileCache.php +++ b/includes/Wpup/FileCache.php @@ -18,7 +18,7 @@ public function __construct($cacheDirectory) { public function get($key) { $filename = $this->getCacheFilename($key); if ( is_file($filename) && is_readable($filename) ) { - $cache = unserialize(file_get_contents($filename)); + $cache = unserialize(base64_decode(file_get_contents($filename))); if ( $cache['expiration_time'] < time() ) { return null; //Cache expired. } else { @@ -41,7 +41,7 @@ public function set($key, $value, $expiration = 0) { 'expiration_time' => time() + $expiration, 'value' => $value, ); - file_put_contents($this->getCacheFilename($key), serialize($cache)); + file_put_contents($this->getCacheFilename($key), base64_encode(serialize($cache))); } /** From f4cb59e423e8752ce91f98c77519a8894ffd6b12 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sun, 31 Aug 2014 04:42:38 +0200 Subject: [PATCH 02/19] Improve the re-usability of the addQueryArg() function - Support SSL protocol - Make the serverUrl code re-usable --- includes/Wpup/UpdateServer.php | 55 ++++++++++++++++++++++++++++------ 1 file changed, 46 insertions(+), 9 deletions(-) diff --git a/includes/Wpup/UpdateServer.php b/includes/Wpup/UpdateServer.php index 2cb56eb..d0755c0 100644 --- a/includes/Wpup/UpdateServer.php +++ b/includes/Wpup/UpdateServer.php @@ -11,13 +11,7 @@ public function __construct($serverUrl = null, $serverDirectory = null) { $serverDirectory = realpath(__DIR__ . '/../..'); } if ( $serverUrl === null ) { - //Default to the current URL minus the query and "index.php". - $serverUrl = 'http://' . $_SERVER['HTTP_HOST']; - $path = $_SERVER['SCRIPT_NAME']; - if ( basename($path) === 'index.php' ) { - $path = dirname($path) . '/'; - } - $serverUrl .= $path; + $serverUrl = self::determineServerUrl(); } $this->serverUrl = $serverUrl; @@ -26,6 +20,46 @@ public function __construct($serverUrl = null, $serverDirectory = null) { $this->cache = new Wpup_FileCache($serverDirectory . '/cache'); } + /** + * Determine the Server Url based on the current request. + * + * Defaults to the current URL minus the query and "index.php". + * + * @static + * + * @return string Url + */ + public static function determineServerUrl() { + $serverUrl = ( self::isSsl() ? 'https' : 'http' ); + $serverUrl .= '://' . $_SERVER['HTTP_HOST']; + $path = $_SERVER['SCRIPT_NAME']; + if ( basename($path) === 'index.php' ) { + $path = dirname($path) . '/'; + } + $serverUrl .= $path; + return $serverUrl; + } + + /** + * Determine if ssl is used. + * + * @return bool True if SSL, false if not used. + */ + public static function isSsl() { + if ( isset($_SERVER['HTTPS']) ) { + if ( 'on' === strtolower($_SERVER['HTTPS']) ) { + return true; + } + if ( '1' == $_SERVER['HTTPS'] ) { + return true; + } + } + elseif ( isset($_SERVER['SERVER_PORT']) && ( '443' == $_SERVER['SERVER_PORT'] ) ) { + return true; + } + return false; + } + /** * Process an update API request. * @@ -312,10 +346,13 @@ protected function exitWithError($message, $httpStatus = 500) { * You can also set an argument to NULL to remove it. * * @param array $args An associative array of query arguments. - * @param string $url The old URL. + * @param string $url The old URL. Optional, defaults to the request url without query arguments. * @return string New URL. */ - protected static function addQueryArg($args, $url) { + protected static function addQueryArg($args, $url = null ) { + if ( !isset($url) ) { + $url = self::determineServerUrl(); + } if ( strpos($url, '?') !== false ) { $parts = explode('?', $url, 2); $base = $parts[0] . '?'; From 8312dd5d672a2c6faca8884840408519670c49e7 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sun, 31 Aug 2014 07:33:35 +0200 Subject: [PATCH 03/19] Fix issues with dirname() on Windows --- includes/Wpup/UpdateServer.php | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/includes/Wpup/UpdateServer.php b/includes/Wpup/UpdateServer.php index d0755c0..aee6e9f 100644 --- a/includes/Wpup/UpdateServer.php +++ b/includes/Wpup/UpdateServer.php @@ -33,13 +33,25 @@ public static function determineServerUrl() { $serverUrl = ( self::isSsl() ? 'https' : 'http' ); $serverUrl .= '://' . $_SERVER['HTTP_HOST']; $path = $_SERVER['SCRIPT_NAME']; + if ( basename($path) === 'index.php' ) { - $path = dirname($path) . '/'; + if ( DIRECTORY_SEPARATOR === '/' ) { + $path = dirname($path) . '/'; + } + else { + // Fix Windows + if ( dirname($path) === '\\' ) { + $path = '/'; + } + else { + $path = str_replace('\\', '/', dirname($path)) . '/'; + } + } } + $serverUrl .= $path; return $serverUrl; } - /** * Determine if ssl is used. * From 5f8a332a27cfda98536bfe9565d061b5adf1b5d8 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sun, 31 Aug 2014 07:35:29 +0200 Subject: [PATCH 04/19] Whitespace --- includes/Wpup/UpdateServer.php | 1 + 1 file changed, 1 insertion(+) diff --git a/includes/Wpup/UpdateServer.php b/includes/Wpup/UpdateServer.php index aee6e9f..a21a8e6 100644 --- a/includes/Wpup/UpdateServer.php +++ b/includes/Wpup/UpdateServer.php @@ -52,6 +52,7 @@ public static function determineServerUrl() { $serverUrl .= $path; return $serverUrl; } + /** * Determine if ssl is used. * From df7a39d88008f5fc962855f3b3ba55ebd93cc9cc Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sun, 31 Aug 2014 08:47:28 +0200 Subject: [PATCH 05/19] Make cache files identifiable again as with the base64 encoding, there was no way to determine which package the cache referred to which makes selective (manual) deletion difficult. --- includes/Wpup/Package.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/Wpup/Package.php b/includes/Wpup/Package.php index 082a928..36c5840 100644 --- a/includes/Wpup/Package.php +++ b/includes/Wpup/Package.php @@ -68,7 +68,7 @@ public function getMetadata() { */ public static function fromArchive($filename, $slug = null, Wpup_Cache $cache = null) { $modified = filemtime($filename); - $cacheKey = 'metadata-' . md5($filename . '|' . filesize($filename) . '|' . $modified); + $cacheKey = 'metadata-' . $slug . '-' . md5($filename . '|' . filesize($filename) . '|' . $modified); $metadata = null; //Try the cache first. From 57ed71fdb728ac649e45cebba2d1ab4d0a17577a Mon Sep 17 00:00:00 2001 From: jrfnl Date: Wed, 3 Sep 2014 00:20:01 +0200 Subject: [PATCH 06/19] Code style --- includes/Wpup/UpdateServer.php | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/includes/Wpup/UpdateServer.php b/includes/Wpup/UpdateServer.php index a21a8e6..de8beb9 100644 --- a/includes/Wpup/UpdateServer.php +++ b/includes/Wpup/UpdateServer.php @@ -58,19 +58,19 @@ public static function determineServerUrl() { * * @return bool True if SSL, false if not used. */ - public static function isSsl() { - if ( isset($_SERVER['HTTPS']) ) { - if ( 'on' === strtolower($_SERVER['HTTPS']) ) { - return true; + public static function isSsl() { + if ( isset($_SERVER['HTTPS']) ) { + if ( 'on' === strtolower($_SERVER['HTTPS']) ) { + return true; } - if ( '1' == $_SERVER['HTTPS'] ) { - return true; - } - } + if ( '1' == $_SERVER['HTTPS'] ) { + return true; + } + } elseif ( isset($_SERVER['SERVER_PORT']) && ( '443' == $_SERVER['SERVER_PORT'] ) ) { - return true; + return true; } - return false; + return false; } /** @@ -262,7 +262,7 @@ protected function logRequest($query) { $columns = array( isset($_SERVER['REMOTE_ADDR']) ? str_pad($_SERVER['REMOTE_ADDR'], 15, ' ') : '-', isset($query['action']) ? $query['action'] : '-', - isset($query['slug']) ? $query['slug'] : '-', + isset($query['slug']) ? $query['slug'] : '-', isset($query['installed_version']) ? $query['installed_version'] : '-', isset($wpVersion) ? $wpVersion : '-', isset($wpSiteUrl) ? $wpSiteUrl : '-', From e7d3e7d4eda4cd98ce0a2d70ee24f62a6d46a74f Mon Sep 17 00:00:00 2001 From: jrfnl Date: Wed, 3 Sep 2014 00:57:37 +0200 Subject: [PATCH 07/19] Add support for metainfo about plugin dependencies @see http://wordpress.org/plugins/plugin-dependencies/ @see https://github.com/x-team/wp-plugin-dependencies --- includes/Wpup/Package.php | 7 ++++++- includes/extension-meta/extension-meta.php | 14 ++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/includes/Wpup/Package.php b/includes/Wpup/Package.php index 082a928..b2065b7 100644 --- a/includes/Wpup/Package.php +++ b/includes/Wpup/Package.php @@ -138,7 +138,12 @@ public static function extractMetadata($zipFilename){ } if ( !empty($packageInfo['readme']) ){ - $mapping = array('requires', 'tested'); + $mapping = array( + 'requires', + 'tested', + 'depends', + 'provides', + ); foreach($mapping as $readmeField){ if ( !empty($packageInfo['readme'][$readmeField]) ){ $meta[$readmeField] = $packageInfo['readme'][$readmeField]; diff --git a/includes/extension-meta/extension-meta.php b/includes/extension-meta/extension-meta.php index fd30bda..7b12fde 100644 --- a/includes/extension-meta/extension-meta.php +++ b/includes/extension-meta/extension-meta.php @@ -128,6 +128,8 @@ public static function parseReadme($readmeTxtContents, $applyMarkdown = false){ 'stable' => '', 'short_description' => '', 'sections' => array(), + 'depends' => array(), + 'provides' => array(), ); //The readme.txt header has a fairly fixed structure, so we can parse it line-by-line @@ -148,6 +150,8 @@ public static function parseReadme($readmeTxtContents, $applyMarkdown = false){ 'Requires at least' => 'requires', 'Tested up to' => 'tested', 'Stable tag' => 'stable', + 'Depends' => 'depends', + 'Provides' => 'provides', ); do { //Parse each readme.txt header $pieces = explode(':', array_shift($lines), 2); @@ -170,6 +174,16 @@ public static function parseReadme($readmeTxtContents, $applyMarkdown = false){ $headers['tags'] = array_map('trim', explode(',', $headers['tags'])); } + //And for "Depends" + if ( !empty($headers['depends']) ){ + $headers['depends'] = array_map('trim', explode(',', $headers['depends'])); + } + + //As well as for "Provides" + if ( !empty($headers['provides']) ){ + $headers['provides'] = array_map('trim', explode(',', $headers['provides'])); + } + $readme = array_merge($readme, $headers); //After the headers comes the short description From 12b8dc16c7d5fb7ce539e9ef4b7ee44940ad9a51 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Wed, 3 Sep 2014 18:12:05 +0200 Subject: [PATCH 08/19] Small fixes --- includes/Wpup/UpdateServer.php | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/includes/Wpup/UpdateServer.php b/includes/Wpup/UpdateServer.php index de8beb9..4c46e3e 100644 --- a/includes/Wpup/UpdateServer.php +++ b/includes/Wpup/UpdateServer.php @@ -42,8 +42,7 @@ public static function determineServerUrl() { // Fix Windows if ( dirname($path) === '\\' ) { $path = '/'; - } - else { + } else { $path = str_replace('\\', '/', dirname($path)) . '/'; } } @@ -56,14 +55,13 @@ public static function determineServerUrl() { /** * Determine if ssl is used. * + * @see WP core - wp-includes/functions.php + * * @return bool True if SSL, false if not used. */ public static function isSsl() { if ( isset($_SERVER['HTTPS']) ) { - if ( 'on' === strtolower($_SERVER['HTTPS']) ) { - return true; - } - if ( '1' == $_SERVER['HTTPS'] ) { + if ( $_SERVER['HTTPS'] == '1' || strtolower($_SERVER['HTTPS']) === 'on' ) { return true; } } @@ -261,8 +259,8 @@ protected function logRequest($query) { $columns = array( isset($_SERVER['REMOTE_ADDR']) ? str_pad($_SERVER['REMOTE_ADDR'], 15, ' ') : '-', - isset($query['action']) ? $query['action'] : '-', - isset($query['slug']) ? $query['slug'] : '-', + isset($query['action']) ? $query['action'] : '-', + isset($query['slug']) ? $query['slug'] : '-', isset($query['installed_version']) ? $query['installed_version'] : '-', isset($wpVersion) ? $wpVersion : '-', isset($wpSiteUrl) ? $wpSiteUrl : '-', From c13099ace4d5f7f8ab01d263803792e8ee2dd4d0 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Wed, 3 Sep 2014 18:15:50 +0200 Subject: [PATCH 09/19] Missed one else --- includes/Wpup/UpdateServer.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/includes/Wpup/UpdateServer.php b/includes/Wpup/UpdateServer.php index 4c46e3e..2f6bc35 100644 --- a/includes/Wpup/UpdateServer.php +++ b/includes/Wpup/UpdateServer.php @@ -37,8 +37,7 @@ public static function determineServerUrl() { if ( basename($path) === 'index.php' ) { if ( DIRECTORY_SEPARATOR === '/' ) { $path = dirname($path) . '/'; - } - else { + } else { // Fix Windows if ( dirname($path) === '\\' ) { $path = '/'; From d7c244f7c88cf195ecb3362b50a19f268e70e717 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Wed, 3 Sep 2014 20:03:20 +0200 Subject: [PATCH 10/19] Slight simplification --- includes/Wpup/UpdateServer.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/includes/Wpup/UpdateServer.php b/includes/Wpup/UpdateServer.php index 2f6bc35..4376379 100644 --- a/includes/Wpup/UpdateServer.php +++ b/includes/Wpup/UpdateServer.php @@ -35,14 +35,15 @@ public static function determineServerUrl() { $path = $_SERVER['SCRIPT_NAME']; if ( basename($path) === 'index.php' ) { + $dir = dirname($path); if ( DIRECTORY_SEPARATOR === '/' ) { - $path = dirname($path) . '/'; + $path = $dir . '/'; } else { // Fix Windows - if ( dirname($path) === '\\' ) { - $path = '/'; - } else { - $path = str_replace('\\', '/', dirname($path)) . '/'; + $path = str_replace('\\', '/', $dir); + //Make sure there's a trailing slash. + if ( substr($path, -1) !== '/' ) { + $path .= '/'; } } } From 5182614fa41364ebf677a7cee3e7d0765a823b17 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Tue, 9 Sep 2014 10:39:16 +0200 Subject: [PATCH 11/19] Use native json pretty printing if available --- includes/Wpup/UpdateServer.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/includes/Wpup/UpdateServer.php b/includes/Wpup/UpdateServer.php index b868f36..f550785 100644 --- a/includes/Wpup/UpdateServer.php +++ b/includes/Wpup/UpdateServer.php @@ -256,9 +256,13 @@ protected function filterLogInfo($columns) { */ protected function outputAsJson($response) { header('Content-Type: application/json'); - $output = json_encode($response); - if ( function_exists('wsh_pretty_json') ) { - $output = wsh_pretty_json($output); + $output = ''; + if ( defined('JSON_PRETTY_PRINT') && JSON_PRETTY_PRINT ) { + $output = json_encode($response, JSON_PRETTY_PRINT); + } elseif ( function_exists('wsh_pretty_json') ) { + $output = wsh_pretty_json(json_encode($response)); + } else { + $output = json_encode($response); } echo $output; } From e799ef3a4439da1525d2e00efb6757046abbf091 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Tue, 9 Sep 2014 19:04:45 +0200 Subject: [PATCH 12/19] Constant not ini variable... --- includes/Wpup/UpdateServer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/Wpup/UpdateServer.php b/includes/Wpup/UpdateServer.php index f550785..f6c6530 100644 --- a/includes/Wpup/UpdateServer.php +++ b/includes/Wpup/UpdateServer.php @@ -257,7 +257,7 @@ protected function filterLogInfo($columns) { protected function outputAsJson($response) { header('Content-Type: application/json'); $output = ''; - if ( defined('JSON_PRETTY_PRINT') && JSON_PRETTY_PRINT ) { + if ( defined('JSON_PRETTY_PRINT') ) { $output = json_encode($response, JSON_PRETTY_PRINT); } elseif ( function_exists('wsh_pretty_json') ) { $output = wsh_pretty_json(json_encode($response)); From 498ef41229b30d57e2abaa27772e7ebd8252fe53 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Thu, 11 Sep 2014 09:46:43 +0200 Subject: [PATCH 13/19] Darn.. let's get the tags from the correct file --- includes/extension-meta/extension-meta.php | 27 +++++++++++----------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/includes/extension-meta/extension-meta.php b/includes/extension-meta/extension-meta.php index 7b12fde..bf987c2 100644 --- a/includes/extension-meta/extension-meta.php +++ b/includes/extension-meta/extension-meta.php @@ -128,8 +128,6 @@ public static function parseReadme($readmeTxtContents, $applyMarkdown = false){ 'stable' => '', 'short_description' => '', 'sections' => array(), - 'depends' => array(), - 'provides' => array(), ); //The readme.txt header has a fairly fixed structure, so we can parse it line-by-line @@ -150,8 +148,6 @@ public static function parseReadme($readmeTxtContents, $applyMarkdown = false){ 'Requires at least' => 'requires', 'Tested up to' => 'tested', 'Stable tag' => 'stable', - 'Depends' => 'depends', - 'Provides' => 'provides', ); do { //Parse each readme.txt header $pieces = explode(':', array_shift($lines), 2); @@ -174,16 +170,6 @@ public static function parseReadme($readmeTxtContents, $applyMarkdown = false){ $headers['tags'] = array_map('trim', explode(',', $headers['tags'])); } - //And for "Depends" - if ( !empty($headers['depends']) ){ - $headers['depends'] = array_map('trim', explode(',', $headers['depends'])); - } - - //As well as for "Provides" - if ( !empty($headers['provides']) ){ - $headers['provides'] = array_map('trim', explode(',', $headers['provides'])); - } - $readme = array_merge($readme, $headers); //After the headers comes the short description @@ -276,6 +262,9 @@ public static function getPluginHeaders($fileContents) { 'TextDomain' => 'Text Domain', 'DomainPath' => 'Domain Path', 'Network' => 'Network', + 'Depends' => 'Depends', + 'Provides' => 'Provides', + //Site Wide Only is deprecated in favor of Network. '_sitewide' => 'Site Wide Only', ); @@ -291,6 +280,16 @@ public static function getPluginHeaders($fileContents) { //For backward compatibility by default Title is the same as Name. $headers['Title'] = $headers['Name']; + + //"Depends" is a comma-separated list. Convert it to an array. + if ( !empty($headers['depends']) ){ + $headers['depends'] = array_map('trim', explode(',', $headers['depends'])); + } + + //Same for "Provides" + if ( !empty($headers['provides']) ){ + $headers['provides'] = array_map('trim', explode(',', $headers['provides'])); + } //If it doesn't have a name, it's probably not a plugin. if ( empty($headers['Name']) ){ From cc7a6368def5aeff4b228707400ec72da6c1c7d0 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Thu, 11 Sep 2014 09:50:55 +0200 Subject: [PATCH 14/19] Same for package --- includes/Wpup/Package.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/includes/Wpup/Package.php b/includes/Wpup/Package.php index b2065b7..b324ff8 100644 --- a/includes/Wpup/Package.php +++ b/includes/Wpup/Package.php @@ -122,6 +122,9 @@ public static function extractMetadata($zipFilename){ 'Author' => 'author', 'AuthorURI' => 'author_homepage', 'DetailsURI' => 'details_url', //Only for themes. + 'Depends' => 'depends', // plugin-dependencies plugin + 'Provides' => 'provides', // plugin-dependencies plugin + ); foreach($mapping as $headerField => $metaField){ if ( array_key_exists($headerField, $packageInfo['header']) && !empty($packageInfo['header'][$headerField]) ){ @@ -141,8 +144,6 @@ public static function extractMetadata($zipFilename){ $mapping = array( 'requires', 'tested', - 'depends', - 'provides', ); foreach($mapping as $readmeField){ if ( !empty($packageInfo['readme'][$readmeField]) ){ From a6ae2c940739c8722129800152910a4a129da9dd Mon Sep 17 00:00:00 2001 From: jrfnl Date: Thu, 11 Sep 2014 09:53:24 +0200 Subject: [PATCH 15/19] Whitespace --- includes/Wpup/Package.php | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/includes/Wpup/Package.php b/includes/Wpup/Package.php index b324ff8..809085d 100644 --- a/includes/Wpup/Package.php +++ b/includes/Wpup/Package.php @@ -116,15 +116,14 @@ public static function extractMetadata($zipFilename){ if ( isset($packageInfo['header']) && !empty($packageInfo['header']) ){ $mapping = array( 'Name' => 'name', - 'Version' => 'version', - 'PluginURI' => 'homepage', - 'ThemeURI' => 'homepage', - 'Author' => 'author', - 'AuthorURI' => 'author_homepage', - 'DetailsURI' => 'details_url', //Only for themes. + 'Version' => 'version', + 'PluginURI' => 'homepage', + 'ThemeURI' => 'homepage', + 'Author' => 'author', + 'AuthorURI' => 'author_homepage', + 'DetailsURI' => 'details_url', //Only for themes. 'Depends' => 'depends', // plugin-dependencies plugin 'Provides' => 'provides', // plugin-dependencies plugin - ); foreach($mapping as $headerField => $metaField){ if ( array_key_exists($headerField, $packageInfo['header']) && !empty($packageInfo['header'][$headerField]) ){ From 1f409560ddc33ac1b19cff23619ad95018fc1da7 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Thu, 11 Sep 2014 09:58:08 +0200 Subject: [PATCH 16/19] Capitalisation --- includes/extension-meta/extension-meta.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/includes/extension-meta/extension-meta.php b/includes/extension-meta/extension-meta.php index bf987c2..f88d165 100644 --- a/includes/extension-meta/extension-meta.php +++ b/includes/extension-meta/extension-meta.php @@ -282,13 +282,13 @@ public static function getPluginHeaders($fileContents) { $headers['Title'] = $headers['Name']; //"Depends" is a comma-separated list. Convert it to an array. - if ( !empty($headers['depends']) ){ - $headers['depends'] = array_map('trim', explode(',', $headers['depends'])); + if ( !empty($headers['Depends']) ){ + $headers['Depends'] = array_map('trim', explode(',', $headers['Depends'])); } //Same for "Provides" - if ( !empty($headers['provides']) ){ - $headers['provides'] = array_map('trim', explode(',', $headers['provides'])); + if ( !empty($headers['Provides']) ){ + $headers['Provides'] = array_map('trim', explode(',', $headers['Provides'])); } //If it doesn't have a name, it's probably not a plugin. From 595b05825be0a517d646b14cde9b7ca4dc8f16e5 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Thu, 11 Sep 2014 21:37:17 +0200 Subject: [PATCH 17/19] Minor changes / code style, method naming --- includes/Wpup/UpdateServer.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/includes/Wpup/UpdateServer.php b/includes/Wpup/UpdateServer.php index 70612df..ea6d333 100644 --- a/includes/Wpup/UpdateServer.php +++ b/includes/Wpup/UpdateServer.php @@ -11,7 +11,7 @@ public function __construct($serverUrl = null, $serverDirectory = null) { $serverDirectory = realpath(__DIR__ . '/../..'); } if ( $serverUrl === null ) { - $serverUrl = self::determineServerUrl(); + $serverUrl = self::guessServerUrl(); } $this->serverUrl = $serverUrl; @@ -21,7 +21,7 @@ public function __construct($serverUrl = null, $serverDirectory = null) { } /** - * Determine the Server Url based on the current request. + * Guess the Server Url based on the current request. * * Defaults to the current URL minus the query and "index.php". * @@ -29,7 +29,7 @@ public function __construct($serverUrl = null, $serverDirectory = null) { * * @return string Url */ - public static function determineServerUrl() { + public static function guessServerUrl() { $serverUrl = ( self::isSsl() ? 'https' : 'http' ); $serverUrl .= '://' . $_SERVER['HTTP_HOST']; $path = $_SERVER['SCRIPT_NAME']; @@ -64,8 +64,7 @@ public static function isSsl() { if ( $_SERVER['HTTPS'] == '1' || strtolower($_SERVER['HTTPS']) === 'on' ) { return true; } - } - elseif ( isset($_SERVER['SERVER_PORT']) && ( '443' == $_SERVER['SERVER_PORT'] ) ) { + } elseif ( isset($_SERVER['SERVER_PORT']) && ( '443' == $_SERVER['SERVER_PORT'] ) ) { return true; } return false; @@ -389,7 +388,7 @@ protected function exitWithError($message = '', $httpStatus = 500) { */ protected static function addQueryArg($args, $url = null ) { if ( !isset($url) ) { - $url = self::determineServerUrl(); + $url = self::guessServerUrl(); } if ( strpos($url, '?') !== false ) { $parts = explode('?', $url, 2); From 2584169052dd1fa6b50c94a9ed77caa55477f5cc Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sun, 28 Sep 2014 18:45:51 +0200 Subject: [PATCH 18/19] Added documentation about the use of base64 encoding --- includes/Wpup/FileCache.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/includes/Wpup/FileCache.php b/includes/Wpup/FileCache.php index 57c166e..11bd33f 100644 --- a/includes/Wpup/FileCache.php +++ b/includes/Wpup/FileCache.php @@ -1,6 +1,14 @@ Date: Sun, 28 Sep 2014 18:46:17 +0200 Subject: [PATCH 19/19] Added 'b64' indicator to cache file name --- includes/Wpup/Package.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/Wpup/Package.php b/includes/Wpup/Package.php index 36c5840..8d4617c 100644 --- a/includes/Wpup/Package.php +++ b/includes/Wpup/Package.php @@ -68,7 +68,7 @@ public function getMetadata() { */ public static function fromArchive($filename, $slug = null, Wpup_Cache $cache = null) { $modified = filemtime($filename); - $cacheKey = 'metadata-' . $slug . '-' . md5($filename . '|' . filesize($filename) . '|' . $modified); + $cacheKey = 'metadata-b64-' . $slug . '-' . md5($filename . '|' . filesize($filename) . '|' . $modified); $metadata = null; //Try the cache first.