Bug in thumbnailer.inc.php (with fix)
-
Hello Dan,
We have a few tickets in our support desk for a WP-Portfolio bug that was uncovered due to a recent change in our system (https://www.shrinktheweb.com/content/now-inside-pages-are-automatic-when-upgraded.html).
In order for “Inside Pages” to work automatically, we must assume that &stwurl is the last parameter in the request. This has always been recommended “Best Practice” but now it is mandatory for all requests. Based on a comment in your code, it looks like you took this into account originally. However, somewhere along the way, you added an $args[‘filetype’] AFTER the &stwurl.
The downside is that not following the guideline of &stwurl being last means that the request will fail with error “Invalid Characters in Domain Name.”
Fortunately, the fix is simple:
Open the file:
/wp-content/wp-portfolio/lib/thumbnailer.inc.phpFIND THESE LINES:
// Add arguments not yet added
$args[“Service”] = “ShrinkWebUrlThumbnail”;
$args[“Action”] = “Thumbnail”;
$args[“stwurl”] = $url; // now url is added to the parameters at the end// Check the error cache for the error rather than do a fresh request.
// If there’s an error, return the cached error rather than wasting a request
$cachedError = WPPortfolio_errors_checkForCachedError($args, $pendingThumbPath);
if ($cachedError) {
return $cachedError;
}$actualThumbPath = trailingslashit($actualThumbPath);
$type = strtolower(substr(strrchr($url, ‘.’), 0));
$args[‘filetype’] = $type;
REPLACE WITH:
// Check the error cache for the error rather than do a fresh request.
// If there’s an error, return the cached error rather than wasting a request
$cachedError = WPPortfolio_errors_checkForCachedError($args, $pendingThumbPath);
if ($cachedError) {
return $cachedError;
}$actualThumbPath = trailingslashit($actualThumbPath);
$type = strtolower(substr(strrchr($url, ‘.’), 0));
$args[‘filetype’] = $type;
// Add arguments not yet added
$args[“stwurl”] = $url; // now url is added to the parameters at the end***** END FIX *****
I also removed two deprecated $args just to keep the code/requests clean.
- The topic ‘Bug in thumbnailer.inc.php (with fix)’ is closed to new replies.