Should you run away from DreamHost?

We curate and host WordPress and WP-eCommerce sites for ourselves and our customers. One of the hosting providers we use, and recommended WAS DreamHost. Their support and pricing had always been good. Their attitude used to be cooperative, communicative and considerate.

Then, last night, while at dinner with the bride, my phone vibrates indicating a priority message. As of that message, DreamHost is no longer on our recommended list.

DreamHost sent out a blast email notifying all of their customers that in 4 business days, and in the middle of holiday shopping season, DreamHost is making a change to their hosting configuration. The change DreamHost is making is a little hard core, removing “sudo” access to the servers. For people that don’t know, sudo is the tool that lets a user log in to make an administrative or configuration change to a server.

For your entertainment value, the message is below.

dumb-dreamhost
Dumb DreamHost

Why this matters? Every once in awhile something goes wrong on a server often a simple fix is restarting a process, or flushing a cache. In the case of e-commerce sites we sometimes have to make subtle adjustments to configurations in response to reports from periodic security scans or security patch notices. After this change, making any critical change will be impossible.

So, after the change, if a web site requires a little tweak or has an issue that is critical to it’s ongoing operations, just turn out the lights.

And no, we don’t think turn out the lights is an exaggeration! All of the commerce sites we curate for our customers are PCI Compliant and are periodically scanned by independent third parties. If a scan detects an issue, as sometimes happens with a recently discovered operating system or application software vulnerability, we get notified. If the issue is severe and is not promptly corrected, the PCI company will notify your credit card processor. If your credit card processor decides that the issue puts them at risk, your payment processing can be turned off.

With this change your sites’ performance is also at risk. Even a common performance enhancement to a WordPress site like turning on memcached now becomes impossible. For some of our commerce and blog sites memcached is important. Memcached speeds WordPress response times up by 5-10 times, and lets us handle spikes in traffic without any degradation in performance. So if your e-commerce site is lucky enough to get busy, even this most obvious performance tweak is not going to be useful.,

For any DreamHost customers that need to find the words to share with DreamHost to express their concern over this change feel free to borrow from the hastily written note we sent to DreamHost last night:

I just received an email that you are making a change to the VPS configuration for my sites in the middle of the christmas shopping season. WITH LESS THAN 10 BUSINESS DAYS NOTICE! “We will be removing admin (sudo) access from all DreamHost VPS instances.” Removing the administrative access to our server instance will cause substantial loss to our business. If you make this change it is a near certainty that my site will not be supportable, will fail, and you will cause a substantial financial loss to our company. The mitigation of your actions, even if they were technically possible in the inadequate time you have provided, will cost of tens of thousands of dollars to implement. The inadequate notice period makes it impossible for us to find another technical resource to host the site, move it and test it in the next few hours before the busiest shopping days of the year are upon us. This change and how you are planning to make it, most notably including the insufficient notice is negligent, and exudes arrogance and incompetence. I insist that I immediately get a call back from a manager explaining this change and why your management team thinks the timing is acceptable. I insist that you provide a viable alternative or cancel the plans that you have made unilaterally. I insist that you forward me the contact address that I need to use for legal notices and correspondence. Please include the postal address, the person’s name, and the telephone number so that I can have correspondence sent. Flabbergasted by this bonehead move, Pye Brook Company, Inc.  

This morning, we start work and check our host status DreamHost server control panel and find this notice:

 

dump-dreamhost-response
Dumb Dreamhost Response

You can get whiplash reading the back-peddling in this note. A very disturbing take-away from this posting is that DreamHost fails to recognize the critical timing of this change and how it could impact customers. Even worse, is the admission that they have not taken the time understand the impact of this change before making the decision to implement the change.

Our takes on this situation are these:

  1. This change makes it technically impossible to implement the standard recommended configuration for highly performing WordPress blogs and e-Commerce sites.
  2. This change makes it technically impossible for us to respond to critical situations that arise from time to time with the sites we host.
  3. MOST CRITICALLY: We can’t rely on a hosting provider whose internal decision making process is so flawed that changes like this are put in process during critical times, without making the necessary effort to understand the impacts, and without sufficient notice.

We are fortunate in that we also have sites running on Amazon AWS and Digital Ocean, so we have a path out the DreamHost debacle.

So the answer is yes, we think you should run away.

If you are already using our curated WordPress or WP-eCommerce services you will be migrated transparently after we consult with you and make sure it won’t impact any planned/expected commerce or marketing events.

If you work on your own, and you feel at risk by this dreamhost move we can migrate your WordPress blog or e-commerce site to your stand-alone AWS server / Digital Ocean server or our curated offering for a one time flat fee.

 

WP-eCommerce Tip: Hide Comments on Single Product Pages

If you have a store with hundreds of products it can be a little annoying to have to turn off comments on every product page.  But, you can add a few lines of code to a file in your mu-plugins directory, or your theme’s functions.php file.

This will turn off comments on your single product pages.

/**
 * Filter whether the current post is open for comments.
 *
 * @param bool        $open    Whether the current post is open for comments.
 * @param int|WP_Post $post_id The post ID or WP_Post object.
 */
function wpec_no_single_product_page_comments( $open, $post_id ) {
   if ( $open && is_singular() ) {
      $post_type = get_post_type( $post_id );
      if ( 'wpsc-product' == $post_type ) {
         $open = false;
      }
   }

   return $open;
}

add_filter( 'comments_open', 'wpec_no_single_product_page_comments', 10, 2 );

Use PhpStorm When Developing for WordPress

The title says it all.

The marketing folks at JetBrains might have the easiest job on the planet. At other companies marketing is about spin, at JetBrains it is mostly about just telling developers what the product does.

For a detailed feature description you want to visit https://www.jetbrains.com/phpstorm/features/

Let’s keep this short and to the point

There is much to this product, too much to go through every feature and function.  After a couple years of use I am still finding something new every time I look.

The key features that WordPress theme and plugin developers will very quickly appreciate are:

  • Easy navigation access to a WordPress function’s documentation, or  the function itself, with a single click.
  • Accurate code completion for WordPress function calls, with parameter descriptions. Same for code completion for your custom code, which leads to the next point…
  • Quick automatic creation of accurate phpDoc blocks, and basic class methods.
  • Thorough inspections of phpCode for compliance with WordPress coding conventions, as well as potential PHP Issues
  • Integration of jshint and many other common tools within the development environment.
  • Integrated, zero configuration, debugging
  • Ability to configure an entire WordPress site as a project, or just an individual theme or plugin as a project. It’s not an issue to have a WordPress site with 50 plugins loaded into the IDE and indexed while coding and testing.
  • Quickly change inspection profile between one PHP version and another. General use plugins and themes have to work with PHP 5.2, so changing the version number and running an inspection will quickly tell you where your backwards compatibility issues are!

Any developer should appreciate that JetBrains updates PhpStorm product very often.  Sometimes every week. If you join the EAP program you can get these rapid updates and use them immediately.  The quality of each of these updates is really very good, and the documentation includes release notes so you can make an informed decision if a specific update is appropriate for you.

Updates include a mix of new features, performance improvements and bug fixes.  The issue database is public, and current.  Making the issue tracking information public on a commercial project shows great confidence in their product and their development team.  Any serious developer should note this, and have a high degree of confidence in PhpStorm as their IDE of choice.

How to Show WP-eCommerce Products on Blog Main Page

If you are using the WP-eCommerce plugin to sell items in support of your WordPress blog you may have been wondering if it’s possible to have your products show up on your main page intermixed with your regular blog posts.

The WordPress main post “loop” can be adjusted using the pre_get_posts filter.

The filter lets you change how WordPress builds the list of posts displayed for your blog.

You can add code like what is below to a file in your mu-plugins directory or theme functions.php file.

add_action( 'pre_get_posts', 'pbci_show_products_in_loop' );

/**
 * @param WP_Query $query
 */
function pbci_show_products_in_loop( $query ) {
    if ( ! is_admin() ) {
        if ( $query->is_home() && $query->is_main_query() ) {
            $query->set( 'post_type', array( 'post', 'wpsc-product' ) );
            $query->set( 'orderby', 'modified' );
            $query->set( 'order', 'DESC' );
        }

        if ( $query->is_main_query() && $query->is_search ) {
            $query->set( 'post_type', array( 'post', 'wpsc-product' ) );
        }
    }
}


Notice the check if ( ! is_admin() ) {.  This is to be sure we don't change the post listings in the WordPress dashboard.

The check if ( $query->is_home() && $query->is_main_query() ) { tests to see if we are on the main page in the main loop.

Then $query->set( 'post_type', array( 'post', 'wpsc-product' ) ); sets the desired post types to regular posts and product posts.

If you don’t want to play with the code, but want to give this idea a try, we have put the code into a FREE PLUGIN in our store.

WordPress Tip – Stopping Post Navigation

Every once in a while you may want to display a post but not have the theme show navigation links.  This can happen if you are showing an error message, a private, or perhaps a custom post type.

Your first instinct is probably to modify the theme files. Doing this might be quick, but every time the theme is updated, or every time you change themes you are going to have to be changed the theme files.  So what is the best way.

One technique is to make WordPress think that there aren’t any next or previous posts to link to.  Create a file in your mu-plugins directory with code similar to what is below and the navigation links will never show.  If you wrap the add_filter calls in a conditional that matches your needs you will be all set, no theme mods required!

function stop_post_navigation( $where ) {
   return 'WHERE 1 = 0 ';
}

add_filter( 'get_next_post_where',  'stop_post_navigation', 10, 1 );
add_filter( 'get_previous_post_where',  'stop_post_navigation', 10, 1 );

Creating a Coupon for a Free Product in WP-eCommerce

From time to time you may want to give a product away as a promotion.  This is how to create a coupon for a free product.

 

In the WordPress Dashboard, on the PRODUCTS menu select COUPONS

coupon menu

 

 

 

 

 

 

 

 

Add the coupon for your product using the new coupon form:

add-coupon-button

 

 

 

 

Use a unique coupon code, in the example we use “FreeGift”

Set the discount amount to 100%, this will reduce the cart sub-total by the value of the product being given away

Set a start and end date

DO NOT CHECK  “This coupon affects each product at checkout”, if you check this the shopper will get the whole cart for free 🙁

In Conditions select “Item Name” and “Is Equal To” and enter the name of the product you are giving away.

create-coupon




That’s it!

Customizing PayPal Checkout for WP-eCommerce

PayPal offers a really nice feature that lets you customize the look and feel of the PayPal checkout page to match the look and feel of your web site.  We highly recommend that you use this feature to have your PayPal checkout page look similar to your WP-eCommerce shopping cart pages.  It makes for a much friendlier feeling checkout experience.

But what do you do when you have one PayPal account and multiple stores.  The PayPal Payments Standard 2.0 gateway that comes with WP-eCommerce doesn’t let you override the look and feel settings on a store by store basis.  And the newer PayPal gateways that come with WP-e Commerce may not be suitable for your store for some reason.

There is an easy answer!

The PayPal gateway that comes with WP-eCommerce  has a nifty “filter” that we can use to pick any of the “styles” you have set up in your PayPal settings.  It’s only a few lines of code that you can drop into a file in the mu-plugins directory, or into your theme’s functions.php.

This little snippet of code will tell PayPal to use the ‘pyebrook’ style sheet whenever  WP-eCommerce sends a shopper to PayPal.

add_filter( 'wpsc_paypal_standard_post_data', 'my_wpsc_paypal_standard_post_data', 10 , 1 );

function my_wpsc_paypal_standard_post_data( $paypal_vars ) {
    $paypal_vars['page_style'] = 'pyebrook';
    return $paypal_vars;
}

 

And this is what your shoppers will see:

paypal-checkout-screen
Customized PayPal Checkout

 

 

 

 

 

 

 

 

 

 

Site Check Up for WP-eCommerce

When we are contacted for to help build a new WP-eCommerce site, upgrade an older WP-eCommerce installation, or fix an issue in a WP-eCommerce store there we try to gather a little technical information to understand what we are working with.

The questions we ask, and the things that we look at have been moved into a FREE, easy to use plugin that you can install to check your WP-eCommerce / WordPress configuration health.

Download the Site Check-up Plugin for WP-eCommerce here!

Checks for the following unfortunate conditions existing on your site:

  • Unreachable links to products, checkout, results and user profile pages. Checks HTTP and HTTPS.
  • Too many options in the WordPress options table
  • Too many autoload options in the WordPress options table
  • Too much autoload data in the WordPress options table
  • Too many transients in the WordPress database
  • Expired transients in the WordPress database
  • Orphaned WordPress post meta
  • Orphaned WordPress taxonomy terms
  • Memcache not present
  • APC not present
  • Object cache not functioning
  • Slow un-cached query performance
  • Slow cached query performance

Makes available to the store administrator individual actions that will:

  • Delete all WordPress Transients from the WordPress database
  • Delete expired WordPress transients from the WordPress database
  • Delete orphaned WordPress post meta
  • Delete orphaned WordPress taxonomy meta
  • Delete all files that are part of the WordPress cache
  • Flush the WordPress cache
  • Test the configuration of memcache object cache
  • Initiate a memcache (object cache) flush

WP-e-Commerce Random Cart Emptying – fix your server configuration

Using one of the less expensive hosting providers and a shared hosting plan for your WP-e-Commerce site is a great way to get started.  The hosting providers often have easy one-click setups that they have already been optimized for a WordPress blog.  These configurations can be a convenient as a starting point for setting up your WPeC site.  Not having to set up and tune your Web Server and WordPress configurations can save hours or even days worth of work.

Optimizing a server for WordPress almost always includes setting up a cache to improve the ability of your server to handle requests quickly and consistently. If you aren’t familiar with how a cache works it’s pretty simple. If the result of a computation, database request or file read might be needed later, save the result close by so that if it is needed again it both easy and fast to get.

Caching on a blog is useful because the intent is for each piece of content to be read over and over again, perhaps thousands of times. Keeping the raw data close to where the web page is created not only speeds the  experience for the end-user, it helps balance the utilization of server components.  This means more requests can be processed by less hardware and software.

About Caches

There are lots of caches that can be configured for a WordPress site.  The common types are proxy-caches, op-code caches, object (attribute-value) caching and content delivery networks (CDN).  Hosting provider’s will setup whatever a combination of cache types that matches what they anticipate to be met their users needs.

There a many implementations of each cache type some are bundled with server software, some are commercial products, some are services.  For example, there are probably hundreds of CDN that could be used with any given web site. If your web site is running on any type of Linux variant with Apache it could be the case that your hosting provider has preconfigured a server to APC for WordPress Caching.

About APC

APC offers two caching capabilities, op-code caching and attribute caching. Your site can be configured to use either APC capability, or both, or neither. It’s important to understand each cache capability, and how it helps your site.

Op-code caching stores pre-processed copies of your web site’s PHP source code so that pages will load very fast.  I benchmarked this site with APC op-code caching enabled and disabled and WordPress loaded 20 times ( 210 vs 10 milliseconds) faster with APC op-code caching enabled.  That is a huge improvement.

APC also offers attribute (object) caching.  Two things about WordPress blogs that make it a perfect fit for very active attribute caching.  First is that content is very rarely changed, it is added to.  This means that if WordPress saves an extra copy of a piece of content it doesn’t have to worry about has the value of the attribute being changed.

Second is that under the hood, WordPress data is broken into lots of distinct, small, easy to manage, pieces of data, sometimes called objects. These pieces of data used to create web pages can come from attributes and values saved in a database, or somewhere else.

Post objects have attributes with values. User objects have attributes with values. Comment also have attributes with values.  If you take a quick look at your WordPress database you will see many of these attributes and values saved in the wp_commentmeta, wp_postmeta and wp_usermeta database tables.

The core WordPress code is tuned to take advantage of attribute value (object) caching if it is available. WordPress does this by saving the attributes and their values in the object cache at the same time they are saved to, or read from, the database.

WP-e-Commerce (WPeC) is architected to take advantage of the WordPress platform and all of the performance benefits that it provides.  In WPeC products are just another WordPress post type, visitors are just another meta type, and carts are just attributes attached to visitors.

How does add to cart work?

  1. Shopper looking at a product page clicks the add to cart button,
  2. WPeC get’s the shoppers cart through the WordPress API
  3. Product is added to the shopper’s cart
  4. WPeC saves the shoppers cart through  the WordPress API

Shopper goes to checkout page and cart is empty! 🙁

What happened?

If our server configuration includes Linux, Apache using Fast CGI and APC, and is set up to use APC for attribute value caching it is likely the case that we just got hit by the behavior in this bug report.

When your web server gets a request to serve a web page or add something to a cart the web server gives the request to one of many “workers” that are available.  Each of these workers is thought to be an exact duplicate of each other. This means that any worker should be able to process any request, and the result should be the same.

But this isn’t always entirely true with regards to APC.  Each worker could have its own copy of the APC cache.

How about a demo?

We installed the apc.php statistics file that comes with the APC cache on a production web server.  Watch file cache information as we refresh the page.

Notice the hit/misses change, and they and go down.  The other stats change also.  This is because the request to serve this page is using statistics from the APC cache unique to the worker that is serving the page.

 Here is what is going on…

  1. Worker 1 gets the request to create the product page when the users cart is empty. WPeC asks WordPress to save the empty cart. A copy of the cart is put into the database and a copy gets put into worker 1’s APC cache.
  2. Worker 2 gets the request to add a product to the shoppers cart.  WPeC asks WordPress for the shopper’s cart. WordPress checks the APC cache first, it’s not there. WordPress gives WPeC the cart that is stored in the database.
  3. Worker 1 gets the request to show the checkout page. WPeC asks WordPress for the shopper’s cart. WordPress checks the APC cache first, finds the cart. But the cart is the original (empty) cart.
  4. WPeC tells the user nothing is in the cart.

What to do?

Easy.  Don’t use APC for object ( attribute-value ) caching with WordPress.  Use APC for op-code caching only.

Can object caching be turned off?

Yes.  But it’s not a good idea.  Without an object cache your site will slow down. The impact on user experience will be noticeable. However, If you want to  you can turn off object caching entirely rename or delete the object-cache.php file in your wp_content directory.

Can I fix the APC configuration?

Perhaps.  This is an article that describes what you have to do.  Not for uninitiated or the faint of heart 😉

Use a different object cache (the best  solution)

If your host is sophisticated enough to try to make APC available to you it’s also very likely that your host has memcached available.  If so, you can switch to using memcache as your object cache by replacing the object-cache.php in your wp_content directory with an object-cache.php that sends the request to memcache rather than APC.  You might want to take a look at this plugin that includes the object-cache.php you need and some installation instructions. If your host hasn’t made memcached available it’s requires some basic Linux skills to set up. Just make sure you host has given you the required permissions.

Is there an easy way to see if a site has this problem?

If you want to see if your site has this configuration problem you could also try our Snappy WPeC plugin that does provides some WPeC and WordPress diagnostic information.  The plugin is free.

If you find the snappy plugin helpful and want to tell us how much you like it, why not purchase one of our other WPeC plugins.  Perhaps the Shopper Watch plugin that let’s you see what users are looking at, and what they have in their carts, or maybe our stamps.com plugin that let’s you print postage from the WPeC sales log page.

If you need some help diagnosing and fixing up your WordPress + WPeC configuration email us and we can work with you and your hosting provider to get things set up correctly.

 

snappy-site snappy