UPS Shipping labels no longer displayed: the path was wrong returned from patch in file_create_url()

In admin/settings/cdn/other, put File URL */sites/default/files/ups_labels* on the Blacklist. Cleared cached, resync'd with CloudFront. Still the path for the UPS labels was on the cdn, when they should not have been.

In the end had to resort to 2 ugly mods to avoid file_create_url():

1/ uc_ups.admin.inc:
function theme_uc_ups_label_image() {
+ global $base_url;
$args = func_get_args();
- $image_path = file_create_url(implode('/', $args));
+ $image_path = $base_url .'/'. file_directory_path() .'/'. implode('/', $args);

2/ uc_shipping.admin.inc:
function theme_uc_shipping_shipment_print($order, $shipment, $labels = TRUE) {
+ global $base_url;
...
if ($labels) {
foreach ($shipment->packages as $id => $package) {
if ($package->label_image && ($path = file_create_path($package->label_image)) && file_exists($path)) {
// TODO: Find a way to store these magic numbers specifically for UPS.
list($width, $height) = array(672, 392);
+ $url = $base_url . '/' . $path;
$output .= '
' . "\n";
- $output .= theme('image', file_create_url($package->label_image), '', '', array('width' => $width, 'height' => $height), FALSE) ."\n";
+ $output .= theme('image', $url, '', '', array('width' => $width, 'height' => $height), FALSE) ."\n";

I did not research the root cause of the problem in file_create_url(). Does anyone know ?

Comments

wim leers’s picture

Project: CDN » e-Commerce | UPS Shipping
Version: 6.x-2.x-dev » 6.x-4.x-dev
Component: Module » Code

This is extremely unhelpful. You basically posted plaintext changes instead of using code tags. WTF. You should've posted a patch!

Also, you did not provide an example of what file_create_url() returned.

Finally: there's not a bug in file_create_url(). There's a bug in the parameter you pass it. Look at its documentation: you have to make sure you're including file_directory_path() in the path, and that you're not passing in URLs relative to file_directory_path().

Moving to the correct issue queue.