Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion appengine/wordpress/src/Project.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public function runComposer()
$output, $ret);
$this->info = array_merge($this->info, $output);
if ($ret !== 0) {
$this->info[] = 'Failed to run composer update in ' . $dir
$this->info[] = 'Failed to run composer update in ' . $this->dir
. '. Please run it by yourself before running WordPress.';
}
}
Expand Down
64 changes: 35 additions & 29 deletions appengine/wordpress/src/WordPressSetup.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ class WordPressSetup extends Command
'https://downloads.wordpress.org/plugin/memcached.3.0.1.zip';
const LATEST_GAE_WP =
'https://downloads.wordpress.org/plugin/google-app-engine.1.6.zip';
const LATEST_GCS_PLUGIN =
'https://github.com/GoogleCloudPlatform/wordpress-plugins/releases/download/gcs-0.1/gcs-0.1.zip';

const FLEXIBLE_ENV = 'Flexible Environment';
const STANDARD_ENV = 'Standard Environment';
Expand Down Expand Up @@ -297,34 +299,6 @@ protected function execute(InputInterface $input, OutputInterface $output)
if (!$this->report($output, $project)) {
return self::DEFAULT_ERROR;
}
$output->writeln('Downloading the Batcache plugin...');
$project->downloadArchive(
'Batcache plugin', self::LATEST_BATCACHE,
'/wordpress/wp-content/plugins'
);
if (!$this->report($output, $project)) {
return self::DEFAULT_ERROR;
}

$output->writeln('Downloading the Memcached plugin...');
$project->downloadArchive(
'Memcached plugin', self::LATEST_MEMCACHED,
'/wordpress/wp-content/plugins'
);
if (!$this->report($output, $project)) {
return self::DEFAULT_ERROR;
}

$output->writeln('Copying drop-ins...');
$dir = $project->getDir();
copy(
$dir . '/wordpress/wp-content/plugins/batcache/advanced-cache.php',
$dir . '/wordpress/wp-content/advanced-cache.php'
);
copy(
$dir . '/wordpress/wp-content/plugins/memcached/object-cache.php',
$dir . '/wordpress/wp-content/object-cache.php'
);

$keys = array(
'project_id' => '',
Expand All @@ -334,6 +308,34 @@ protected function execute(InputInterface $input, OutputInterface $output)
'db_password' => '',
);
if ($env === self::STANDARD_ENV) {
$output->writeln('Downloading the Batcache plugin...');
$project->downloadArchive(
'Batcache plugin', self::LATEST_BATCACHE,
'/wordpress/wp-content/plugins'
);
if (!$this->report($output, $project)) {
return self::DEFAULT_ERROR;
}

$output->writeln('Downloading the Memcached plugin...');
$project->downloadArchive(
'Memcached plugin', self::LATEST_MEMCACHED,
'/wordpress/wp-content/plugins'
);
if (!$this->report($output, $project)) {
return self::DEFAULT_ERROR;
}

$output->writeln('Copying drop-ins...');
$dir = $project->getDir();
copy(
$dir . '/wordpress/wp-content/plugins/batcache/advanced-cache.php',
$dir . '/wordpress/wp-content/advanced-cache.php'
);
copy(
$dir . '/wordpress/wp-content/plugins/memcached/object-cache.php',
$dir . '/wordpress/wp-content/object-cache.php'
);
$copyFiles = array(
'app.yaml' => '/',
'cron.yaml' => '/',
Expand All @@ -351,11 +353,15 @@ protected function execute(InputInterface $input, OutputInterface $output)
return self::DEFAULT_ERROR;
}
} else {
// Download gcs plugin
$project->downloadArchive(
'GCS plugin', self::LATEST_GCS_PLUGIN,
'/wordpress/wp-content/plugins'
);
$copyFiles = array(
'app.yaml' => '/',
'cron.yaml' => '/',
'composer.json' => '/',
'gcs-media.php' => '/wordpress/wp-content/plugins/',
'nginx-app.conf' => '/',
'php.ini' => '/',
'wp-config.php' => '/wordpress/',
Expand Down
2 changes: 1 addition & 1 deletion appengine/wordpress/src/files/flexible/app.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
runtime: php
vm: true
env: flex

beta_settings:
cloud_sql_instances: {{db_connection}}
Expand Down
4 changes: 2 additions & 2 deletions appengine/wordpress/src/files/flexible/composer.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"require": {
"google/appengine-php-sdk": "^1.9"
"google/cloud": "~0.21"
},
"require-dev": {
"wp-cli/wp-cli": "^0.24.1"
"wp-cli/wp-cli": "~1.1"
}
}
29 changes: 0 additions & 29 deletions appengine/wordpress/src/files/flexible/deploy_wrapper.sh

This file was deleted.

59 changes: 0 additions & 59 deletions appengine/wordpress/src/files/flexible/gcs-media.php

This file was deleted.

9 changes: 3 additions & 6 deletions appengine/wordpress/src/files/flexible/nginx-app.conf
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
location / {
try_files $uri $uri/ /index.php?q=$uri&$args;
try_files $uri /index.php?q=$uri&$args;
}

# Add trailing slash to */wp-admin requests.
rewrite /wp-admin$ https://$host$uri/ permanent;

location /_ah/health {
return 200 'ok';
location ~ ^/wp-admin {
try_files $uri $uri/index.php?$args;
}
1 change: 1 addition & 0 deletions appengine/wordpress/src/files/flexible/php.ini
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
extension=bcmath.so
extension=gd.so
zend_extension=opcache.so
34 changes: 5 additions & 29 deletions appengine/wordpress/src/files/flexible/wp-config.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,34 +19,13 @@
*/

// Register GCS stream wrapper
set_include_path(__DIR__ . '/../vendor/google/appengine-php-sdk');
require_once(__DIR__ . '/../vendor/autoload.php');
stream_wrapper_register(
'gs',
'\google\appengine\ext\cloud_storage_streams\CloudStorageStreamWrapper',
0);

// Bucket name for the media upload
define('GOOGLE_CLOUD_STORAGE_BUCKET', '{{project_id}}.appspot.com');
require_once(__DIR__ . '/../vendor/autoload.php');
$storageClient = new Google\Cloud\Storage\StorageClient();
$storageClient->registerStreamWrapper();

// $onGae is true on production.
$onGae = filter_var(getenv('GAE_VM'), FILTER_VALIDATE_BOOLEAN);

// Cache settings
define('WP_CACHE', $onGae);
$batcache = [
'seconds' => 0,
'max_age' => 30 * 60, // 30 minutes
'debug' => false
];
if ($onGae) {
$memcached_servers = array(
'default' => array(
getenv('MEMCACHE_PORT_11211_TCP_ADDR')
. ':' . getenv('MEMCACHE_PORT_11211_TCP_PORT')
)
);
}
$onGae = (getenv('GAE_VERSION') !== false);

// Disable pseudo cron behavior
define('DISABLE_WP_CRON', true);
Expand All @@ -57,16 +36,13 @@
} else {
define('HTTP_HOST', 'localhost');
}
// Use https on MVMs.
// Use https on production.
define('WP_HOME', $onGae ? 'https://' . HTTP_HOST : 'http://' . HTTP_HOST);
define('WP_SITEURL', $onGae ? 'https://' . HTTP_HOST : 'http://' . HTTP_HOST);

// Force SSL for admin pages
define('FORCE_SSL_ADMIN', $onGae);

// Get HTTPS value from the App Engine specific header.
$_SERVER['HTTPS'] = $onGae ? $_SERVER['HTTP_X_APPENGINE_HTTPS'] : false;

// ** MySQL settings - You can get this info from your web host ** //
if ($onGae) {
/** Production environment */
Expand Down
2 changes: 1 addition & 1 deletion appengine/wordpress/src/files/standard/composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"require-dev": {
"wp-cli/wp-cli": "^0.24.1"
"wp-cli/wp-cli": "~1.1"
}
}
18 changes: 0 additions & 18 deletions appengine/wordpress/test/DeployFlexTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,22 +128,4 @@ public function testIndex()
'I am very glad that you are testing WordPress instalation.',
$resp->getBody()->getContents());
}

public function testWpadmin()
{
// Access to '/wp-admin' and see if it's correctly redirected to
// /wp-admin/

// Suppresses following redirect here.
$resp = $this->client->request(
'GET', 'wp-admin', ['allow_redirects' => false]);
$this->assertEquals('301', $resp->getStatusCode(),
'wp-admin status code');
$url = sprintf('https://%s-dot-%s.appspot.com/',
self::getVersion(),
getenv(self::PROJECT_ENV));
$this->assertEquals(
$url . 'wp-admin/',
$resp->getHeaderLine('location'));
}
}