banner-772x250

AppEngine WordPress plugin version 1.4 released.

We’re happy to announce the latest release of the AppEngine WordPress plugin, version 1.4. We encourage all users of WordPress on App Engine to upgrade to this new version as soon as possible.

This new versions includes a number of bug fixes, as well as a new feature for serving media files over HTTPs.

Bug Fixes

This version of the plugin includes fixes for the following bugs:

  • The default HTTP fetch timeout is now 30 seconds, and fetch errors include a more descriptive message.
  • The public URLs for uploaded media now work correctly in the development environment.
  • The plugin now uses autoloading in the AppEngine SDK to improve load time performance.

New Features

This version of the plugin includes a new feature, that makes it possible to serve uploaded media files over HTTPs or HTTP.

To enable HTTPs serving of uploaded media, select the checkbox in the plugin settings page, as shown below.

Secure URLs checkbox.

Once selected, all media files that are subsequently uploaded will be served over https. Note: Changing this setting has no affect on media files that have already been uploaded.

Please report any issues with the plugin in the support forum, or ask questions on stackoverflow where members of the team actively participate.

We also gladly accept pull requests – you can find the plugin source on Github.

Upcoming changes in App Engine 1.9.0 for SCRIPT_NAME and PHP_SELF

The implementation of $_SERVER['SCRIPT_NAME'] and $_SERVER['PHP_SELF'] prior to 1.9.0 differs significantly from 1.9.0 and onward. The changes were made to be consistent with the Apache implementation generally expected by PHP applications.

The following examples demonstrate the difference.

<= 1.8.9 >= 1.9.0
app.yaml:
- url: /.*
  script: index.php
REQUEST_URI: /
SCRIPT_FILENAME: /path/to/index.php
SCRIPT_NAME: /
PHP_SELF: /
REQUEST_URI: /
SCRIPT_FILENAME: /path/to/index.php
SCRIPT_NAME: /index.php
PHP_SELF: /index.php
REQUEST_URI: /bar
SCRIPT_FILENAME: /path/to/index.php
SCRIPT_NAME: /bar
PHP_SELF: /bar
REQUEST_URI: /bar
SCRIPT_FILENAME: /path/to/index.php
SCRIPT_NAME: /index.php
PHP_SELF: /index.php
REQUEST_URI: /index.php/foo/bar
SCRIPT_FILENAME: /path/to/index.php
SCRIPT_NAME: /index.php/foo/bar
PHP_SELF: /index.php/foo/bar
REQUEST_URI: /index.php/foo/bar
SCRIPT_FILENAME: /path/to/index.php
SCRIPT_NAME: /index.php
PHP_SELF: /index.php/foo/bar
REQUEST_URI: /test.php/foo/bar
SCRIPT_FILENAME: /path/to/index.php
SCRIPT_NAME: /test.php/foo/bar
PHP_SELF: /test.php/foo/bar
REQUEST_URI: /test.php/foo/bar
SCRIPT_FILENAME: /path/to/index.php
SCRIPT_NAME: /index.php
PHP_SELF: /index.php
app.yaml:
- url: /.*
  script: foo/index.php
REQUEST_URI: /bar
SCRIPT_FILENAME: /path/to/foo/index.php
SCRIPT_NAME: /bar
PHP_SELF: /bar
REQUEST_URI: /bar
SCRIPT_FILENAME: /path/to/foo/index.php
SCRIPT_NAME: /foo/index.php
PHP_SELF: /foo/index.php

Note the odd behavior of PHP_SELF which is consistent with PHP on Apache.

Many frameworks and applications depend on SCRIPT_NAME to determine if the application is running within a subdirectory, typically within an Apache virtual host, and as such will not be affected by this change. On the other hand this may break custom applications or frameworks that have been configured to work with the previous implementation.

Using the WordPress Importer From the App Engine Plugin

As we announced recently, the new version of our App Engine WordPress Plugin includes import support for WordPress export files, forked from the popular WordPress importer plugin.
This plugin lets you take content that you’ve exported from another WordPress site, in the form of an .xml file, and import it into your App Engine WordPress site.

This post walks through the process of doing such an import. It assumes that you already have a WordPress installation on App Engine— if not, see these instructions.

If you will be doing an import of a large .xml file, see the section below on “What to Do if You Have a Large Import“.  As described in that section, you should make a temporary configuration change to your app before you do the import, to ensure that it finishes successfully.

Continue reading

banner-772x250

AppEngine WordPress plugin Version 1.3 Released

We’re happy to announce that we’ve just released version 1.3 of the AppEngine WordPress plugin. We encourage all users of WordPress on App Engine to upgrade to this new version as soon as possible.

The new version of the plugin includes the following features and bug fixes.

  • Import support for WordPress export files, forked from the popular WordPress importer plugin.
  • URLFetch support for WordPress versions 3.7 and above, that fixes issues caused by core WordPress changes to the WT_HTTP Class.
  • Bug fix for incorrectly detecting if a Google Cloud Storage bucket was writable by the application during setup.
  • Better logging of plugin errors.

Like always, please report any issues with the plugin in the support forum.

We also gladly accept pull requests – you can find the plugin source on Github.

PHP App Engine Apps and File System Concepts

If you’re new to App Engine, then the file system model may be a bit different from what you might have experienced using other hosts.

With an App Engine application, you cannot write to the file-system where your application is deployed. Your application can read any files from the deployed directory structure, but it can’t write to that file-system. Instead, the application can use Google Cloud Storage (GCS) for both reading and writing files.
To convert an app to use GCS for writable files, here are the primary things that you will typically need to do:

Another implication of the read-only file system is that if your app has a ‘plugin’ model, like WordPress, you can’t install or update plugins from your deployed app. Instead, you will need to install or update any plugins locally, then redeploy the app.

You can find lots more info on all of the following in the documentation for the PHP runtime.

Continue reading

App Engine WordPress plugin Version 1.2 released

We’re happy to announce that we’ve just released version 1.2 of the App Engine WordPress plugin. The new version includes the following changes

  • Fix for the bug “Uncaught exception ‘InvalidArgumentException’ with message ‘max_bytes_per_blob must be an integer’” (forum link)
  • Removes the need for PIL to be installed in the local development environment.
  • Removes the need for PyCrypto to be installed in the local development environment.
  • Better checking if the application has write access to the Google Cloud Storage bucket for uploads.

If you find any issues with the latest version of the plugin you can file them in the support forum.

We also gladly accept pull requests – you can find the plugin source on Github.

Generating Dynamic WordPress sitemaps on App Engine

Sitemaps are a valuable tool in helping search engines crawl your website. In this post I’ll show you how you can have a dynamically generated sitemap for a WordPress blog hosted on Google App Engine.

Because of the read-only nature of the file system on App Engine, we’ll use Google Cloud Storage to store the generated sitemap file. We’ll also add some handlers to serve the sitemap, and to update it as part of a scheduled cron job.

Continue reading

Getting started with the Cloud Datastore on PHP App Engine, Part II

Introduction

This is the second in a series of posts on using the Google Cloud Datastore on PHP App Engine.
The code for the examples in this post is here: https://github.com/amygdala/appengine_php_datastore_example.

The previous post walked through the process of setting up your PHP App Engine app to connect with the Datastore, using the Google API client libraries.
It demonstrated how to create a test Datastore entity, and showed how to set up a “Datastore service” instance, using a DatastoreService class, to make it easier to send requests.

However, using the API client libraries, there is a fair bit of overhead in composing requests to the Datastore and processing the responses, and mapping entities to instances of classes in your app. So, in this post, we’ll define some classes to make it easier to create, update, and fetch Datastore entities.
We’ll define a `Model` base class, then show an example of subclassing it to map to a specific Datastore Kind.

Continue reading

Getting Started with the Cloud Datastore on PHP App Engine

Introduction

In this post, we’ll show how to access the Google Cloud Datastore from a PHP App Engine app.

This is the first in a series of posts on using the Cloud Datastore on PHP App Engine.
The code for the examples in this post is here: https://github.com/amygdala/appengine_php_datastore_example. (Some of the files in this repo won’t be mentioned in this post, but will be referenced in the post that follows this one).

PHP on Google App Engine supports several alternatives as for a persistent store. One is the Cloud Datastore, a distributed, robust, fully managed, schemaless database, which supports transactions and scales automatically.
(If you have built App Engine apps for other runtimes, this is the same Datastore that you’ve used before; it now supports an HTTP interface as well).
This article assumes that you already have a basic familiarity with Datastore concepts.

There is not yet a native Datastore API for PHP on app engine. So, instead we’ll show how to use the Cloud Datastore API to connect to the Datastore from your PHP app.
First, we’ll show how to configure your app and associated Cloud Project so that your app will be able to connect to the Datastore.

Then, we’ll look at how to use the Google API client libraries as a basis for authenticating with the Datastore, sending requests, and receiving responses, and we’ll build a DatastoreService class to make connecting a bit easier.

Continue reading