Commit Graph

226 Commits

Author SHA1 Message Date
Yahnis Elsts e4854cdb38 BitBucket fix: When looking for the latest tags, sort them by commit date in descending order.
Previously, PUC didn't specify any explicit sorting criteria. I incorrectly assumed that BitBucket would return the most recent tags first. As a result, when a repository had enough tags to trigger API response pagination, PUC could miss some recent tags. Related: #48
2017-01-24 12:18:34 +02:00
Yahnis Elsts fbff383b7e Fix downloads from private GitHub repositories.
Cause: GitHub API client didn't sign download URLs (oops!). See #84
2017-01-17 09:13:17 +02:00
Yahnis Elsts f171bdf42e Merge pull request #83 from LDAV/patch-1
Add Italian translation. Props to @LDAV
2017-01-16 12:52:34 +02:00
LDAV 495c29a02d Italian language 2017-01-16 10:54:47 +01:00
LDAV a44a53da5e Italian translation 2017-01-15 12:28:16 +01:00
Yahnis Elsts 8a04b9679e Improve plugin detection. Related to #82.
Technically, it's possible to place a plugin anywhere outside the WordPress directory and then create a symlink inside /wp-content/plugins that points to the plugin directory. If the plugin developer then passes the real, symlink-resolved path to the PUC factory, PUC will assume it can't be a plugin because it's not inside the expected directory.
  
Semi-fixed by checking if the input file contains a valid plugin header. However, I would still recommend against using symlinks in this manner because it's likely to cause odd bugs elsewhere. For example, __FILE__ resolves symlinks but plugin_basename() doesn't. This means that the basename that WP sees and the basename you generate in your own code might not match.
2017-01-14 12:39:24 +02:00
Yahnis Elsts 467000eb73 Fail immediately if PUC can't tell whether it's being used in a plugin or a theme.
In theory, that should never happen, but the bug reported in #82 shows that it does.
2017-01-14 11:28:30 +02:00
Yahnis Elsts fd62858e90 Fix "Cannot declare class Puc_v4_Autoloader".
Oops, I knew I'd missed something! Well, this is that something.
2017-01-13 18:49:54 +02:00
Yahnis Elsts 1bf50ba942 Merge pull request #79 from YahnisElsts/version4
Fix some BitBucket and compat. bugs that were missed during testing
2017-01-12 11:38:49 +02:00
Yahnis Elsts 0ed1785fb1 Merge pull request #78 from rvola/master
Fix localization loading by removing extraneous space character
2017-01-12 11:37:29 +02:00
Yahnis Elsts 385ecf8df4 Fix pre-WP 4.7 compatibility.
get_user_locale() is not available in older WordPress versions. Also, according to WP docs, load_plugin_textdomain (and, presumably, its siblings) should be called in `init` or later.
2017-01-12 11:36:35 +02:00
Nicolas GEHIN e506d65915 Space in path not load language 2017-01-12 08:48:14 +01:00
Yahnis Elsts 0d5de0d4cc Fix zip error when installing update from a private BitBucket repository.
The code that updates the OAuth signature didn't account for the fact that the oauth_signature query parameter would end up in the wrong place. Instead of being sorted alphabetically with the rest of parameters, it must be the *last* one.
2017-01-11 22:17:49 +02:00
Yahnis Elsts 5d60e87cb6 Fix version number parsing.
The code that checks if the first character is a number was just plain wrong. It checked if the whole string is numeric.
2017-01-11 22:15:37 +02:00
Yahnis Elsts dd3b8a1b48 Merge pull request #77 from YahnisElsts/version4
Version 4.0

- Theme updates.
- BitBucket support.
- PSR-0.
- Lots of refactoring and generally more classes.
2017-01-11 15:00:40 +02:00
Yahnis Elsts e1be09dc44 Move blog post link down to the "resources" because it's outdated 2017-01-11 11:19:20 +02:00
Yahnis Elsts 911d4cf7a0 Minor documentation updates 2017-01-10 18:08:25 +02:00
Yahnis Elsts 6ba1aeb362 Minor: Move condition so that the fixDirectoryName filter never gets called if there's no valid directory name. 2017-01-10 17:05:07 +02:00
Yahnis Elsts d71578067d Minor: Rename parameter to $collection because it accepts both arrays and objects 2017-01-10 16:20:33 +02:00
Yahnis Elsts 4f1ec59f98 Remove unused property 2017-01-10 16:20:01 +02:00
Yahnis Elsts 57df68d407 Extract state storage as a new class.
Lazy-loading is a bit messy. Could it be improved with magic __get() and __set()?
2017-01-10 15:25:36 +02:00
Yahnis Elsts 844516d1f5 Treat null entries as non-existent. Add a startsWith() method.
This is necessary to avoid fatal errors when trying to retrieve existing but inaccessible properties (i.e. private or protected).
2017-01-10 13:13:01 +02:00
Yahnis Elsts aeeda3c330 Reduce code duplication by moving most similar code from requestUpdate and requestInfo into a new method: requestMetadata. 2017-01-06 10:40:42 +02:00
Yahnis Elsts 1905ed84dd Add API client class name to the debug panel. 2017-01-03 13:37:43 +02:00
Yahnis Elsts 1e709c6199 Add branch name and authentication state (on/off) to the Debug Bar panel.
There's some code duplication here. Unpleasant.
2017-01-03 13:22:38 +02:00
Yahnis Elsts 06eba37b27 Remove unused parameter.
Move stable tag detection to a method.
Make null-comparison explicit in the factory.
2017-01-01 14:25:18 +02:00
Yahnis Elsts b74182cb47 Minor: Simplify maybeCheckForUpdates.
We don't need to check if $state is empty; isset() suffices.
2016-12-31 21:10:48 +02:00
Yahnis Elsts b1fce3c2f4 Minor: Update PHPDoc to show that $update can be null (i.e. no update available). 2016-12-31 14:19:10 +02:00
Yahnis Elsts 13ca09ed1c Explicitly allow null input to Utils::get(). It just returns $default. 2016-12-31 14:17:24 +02:00
Yahnis Elsts e9b377e999 Simplify VCS-based theme checker. 2016-12-31 14:12:17 +02:00
Yahnis Elsts 870901b1f2 Let themes hosted on BitBucket use the "Stable tag" header to specify the latest version. 2016-12-31 13:46:10 +02:00
Yahnis Elsts 0e67e4c588 Extract VCS service detection as a method 2016-12-30 21:08:50 +02:00
Yahnis Elsts 36ef731e4f Remove redundant if condition.
is_object(null) is false, so we don't need a separate empty($state) condition.
2016-12-30 19:44:00 +02:00
Yahnis Elsts 8e5bc8c321 Extract translation filter as a method. 2016-12-30 19:29:28 +02:00
Yahnis Elsts fd78fc9250 Fix spacing of code examples 2016-12-30 15:53:13 +02:00
Yahnis Elsts 635ca65604 Add table of contents and rename some headings 2016-12-30 15:51:11 +02:00
Yahnis Elsts 592453cffb Update description and add JSON examples 2016-12-30 13:28:13 +02:00
Yahnis Elsts 6e31d27187 Minor: Rename and comment.
Apparently "latest compatible version" is a more common expression than "greatest compatible version". Also, lets move away from the idea of using the factory class to build anything other than update checker instances; it's probably not necessary.
2016-12-28 22:12:32 +02:00
Yahnis Elsts 35a04faee6 Apparently BitBucket downloads only work over HTTPS.
Lest build the download URL from scratch to ensure that the correct protocol is used.
2016-12-28 18:17:11 +02:00
Yahnis Elsts 3004e10f75 Add a way to filter the HTTP options used when making GitHub/BitBucket API requests.
Example: 
 
 $updateChecker->addHttpRequestArgFilter('my_callback');
 
 function my_callback($options) {
     $options['timeout'] = 30;
     return $options;
 }
2016-12-28 17:15:42 +02:00
Yahnis Elsts f41dc30d28 Minor fixes and some comments 2016-12-28 16:09:28 +02:00
Yahnis Elsts cdf2d22243 Refactoring GitHub and BitBucket support.
Move most GitHub and BitBucket stuff to a general "VCS checker" class and put service-specific logic in API classes that follow a common interface.

Rationale: Upon further reflection, there's no need to have different theme & plugin checker implementations for each Git hosting service. The overall update detection algorithm stays the same. Only the API and authentication are different. 
 
 Not entirely happy with the code duplication in Vcs_PluginUpdateChecker and Vcs_ThemeUpdateChecker. Traits would be one solution, but can't use that in PHP 5.2. There's probably a "good enough" way to achieve the same thing through composition, but I haven't figured it out yet. 
 
 For private GH repositories, use setAuthentication('access_token_here') instead of setAccessToken().
2016-12-27 18:03:06 +02:00
Yahnis Elsts cde890f5d4 Minor: Update comments. 2016-12-24 16:03:58 +02:00
Yahnis Elsts f62a3d40fe Simplify tag sorting.
We don't need two different implementation for GitHub and BitBucket, they use the same property name. But lets make the property configurable anyway in case other APIs do differ.
2016-12-24 15:14:34 +02:00
Yahnis Elsts 365792edde Refactor BitBucket and GitHub checkers to be more similar.
In the future, it would probably be possible to add a general base class for repository-based updates.
2016-12-24 15:04:25 +02:00
Yahnis Elsts f64c3170cc BitBucket support is now semi-usable.
More testing required. Could probably refactor to reduce duplication; lots of overlap with GitHub integration.
2016-12-22 19:10:05 +02:00
Yahnis Elsts 3692f5201e Fix autoloading of files in the "vendor" subdirectory.
I was using the wrong directory path, oops.
2016-12-22 18:49:51 +02:00
Yahnis Elsts 5b427b4e28 Minor: Fix typo in a comment. 2016-12-22 16:05:15 +02:00
Yahnis Elsts 55077f4a03 WIP: BitBucket support. Not usable yet! 2016-12-20 17:06:14 +02:00
Yahnis Elsts 16ab2457df Support themes hosted on GitHub.
What should "View version 1.2.3 details" link to? Theme URI, the changelog, the release, or the repository itself?
2016-12-19 19:26:34 +02:00