Skip to content

Commit

Permalink
Merge pull request #37 from mitchmac/main
Browse files Browse the repository at this point in the history
Sync main to master
  • Loading branch information
mitchmac authored Oct 7, 2023
2 parents 3a3e678 + dc7d1de commit 73a3e66
Show file tree
Hide file tree
Showing 291 changed files with 9,959 additions and 9,998 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: e2e Tests
on: [push, pull_request]
jobs:
jest:
name: e2e tests
runs-on: ubuntu-latest
steps:

- name: Checkout
uses: actions/checkout@v3

- run: ./run.sh
working-directory: ./test
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"description": "",
"license": "MIT",
"dependencies": {
"serverlesswp": "^0.1.1"
"serverlesswp": "^0.1.2"
}
}
17 changes: 17 additions & 0 deletions test/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM public.ecr.aws/lambda/nodejs:18

COPY package.json ${LAMBDA_TASK_ROOT}/
RUN npm install --omit=optional --omit=dev

COPY api/ ${LAMBDA_TASK_ROOT}/api/
COPY util/ ${LAMBDA_TASK_ROOT}/util/
COPY wp/ ${LAMBDA_TASK_ROOT}/wp/
COPY temp/sqlite-database-integration ${LAMBDA_TASK_ROOT}/wp/wp-content/plugins/sqlite-database-integration/
COPY /temp/sqlite-database-integration/db.copy ${LAMBDA_TASK_ROOT}/wp/wp-content/db.php
COPY test/installer.php ${LAMBDA_TASK_ROOT}/wp/

RUN sed -i 's#{SQLITE_IMPLEMENTATION_FOLDER_PATH}#/tmp/wp/wp-content/plugins/sqlite-database-integration#' ${LAMBDA_TASK_ROOT}/wp/wp-content/db.php

RUN echo "define('FQDBDIR', '/tmp/db' );" >> ${LAMBDA_TASK_ROOT}/wp/wp-config.php

CMD [ "api/index.handler" ]
9 changes: 9 additions & 0 deletions test/build-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

cd ..
mkdir temp
cd temp
git clone https://github.com/WordPress/sqlite-database-integration.git
cd ..
docker build -t serverlesswp-test -f test/Dockerfile .
rm -rf temp
22 changes: 22 additions & 0 deletions test/installer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

// Do not use this on a live site! For testing purposes only!

define('WP_INSTALLING', true);

require_once dirname(__DIR__) . '/wp/wp-load.php';
require_once ABSPATH . 'wp-admin/includes/upgrade.php';
require_once ABSPATH . 'wp-admin/includes/translation-install.php';
require_once ABSPATH . WPINC . '/class-wpdb.php';

if (!is_blog_installed()) {
$weblog_title = 'ServerlessWP Site';
$user_name = 'admin';
$admin_email = '[email protected]';
$public = TRUE;

$result = wp_install($weblog_title, $user_name, $admin_email, $public);
update_user_meta( 1, 'default_password_nag', false );
} else {
echo 'WordPress is already installed.';
}
12 changes: 12 additions & 0 deletions test/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

./build-test.sh

docker run -p 9000:8080 -d -e FQDBDIR='/tmp/db' --name serverlesswp-test serverlesswp-test

curl -s -o /dev/null -w "%{http_code}" -XPOST "http://localhost:9000/2015-03-31/functions/function/invocations" -d '{"path":"/installer.php"}'

curl -s -o /dev/null -w "%{http_code}" -XPOST "http://localhost:9000/2015-03-31/functions/function/invocations" -d '{"path":"/"}'

docker stop serverlesswp-test
docker rm serverlesswp-test
5 changes: 3 additions & 2 deletions util/install.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
exports.validate = function(response) {
if (
!process.env['DATABASE'] ||
!process.env['FQDBDIR'] &&
(!process.env['DATABASE'] ||
!process.env['USERNAME'] ||
!process.env['PASSWORD'] ||
!process.env['HOST']
!process.env['HOST'])
) {

if (process.env['SITE_NAME']) {
Expand Down
31 changes: 31 additions & 0 deletions wp/wp-admin/about.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,37 @@
<a href="privacy.php" class="nav-tab"><?php _e( 'Privacy' ); ?></a>
<a href="contribute.php" class="nav-tab"><?php _e( 'Get Involved' ); ?></a>
</nav>

<div class="about__section changelog has-subtle-background-color">
<div class="column">
<h2><?php _e( 'Maintenance Release' ); ?></h2>
<p>
<?php
printf(
/* translators: 1: WordPress version number, 2: Plural number of bugs. */
_n(
'<strong>Version %1$s</strong> addressed %2$s bug.',
'<strong>Version %1$s</strong> addressed %2$s bugs.',
10
),
'6.3.1',
'10'
);
?>
<?php
printf(
/* translators: %s: HelpHub URL. */
__( 'For more information, see <a href="%s">the release notes</a>.' ),
sprintf(
/* translators: %s: WordPress version. */
esc_url( __( 'https://wordpress.org/support/wordpress-version/version-%s/' ) ),
sanitize_title( '6.3.1' )
)
);
?>
</p>
</div>
</div>

<div class="about__section aligncenter">
<div class="column">
Expand Down
18 changes: 5 additions & 13 deletions wp/wp-admin/includes/class-wp-site-health.php
Original file line number Diff line number Diff line change
Expand Up @@ -1943,10 +1943,6 @@ public function get_test_plugin_theme_auto_updates() {
public function get_test_available_updates_disk_space() {
$available_space = function_exists( 'disk_free_space' ) ? @disk_free_space( WP_CONTENT_DIR . '/upgrade/' ) : false;

$available_space = false !== $available_space
? (int) $available_space
: 0;

$result = array(
'label' => __( 'Disk space available to safely perform updates' ),
'status' => 'good',
Expand All @@ -1963,18 +1959,14 @@ public function get_test_available_updates_disk_space() {
'test' => 'available_updates_disk_space',
);

if ( $available_space < 100 * MB_IN_BYTES ) {
$result['description'] = __( 'Available disk space is low, less than 100 MB available.' );
if ( false === $available_space ) {
$result['description'] = __( 'Could not determine available disk space for updates.' );
$result['status'] = 'recommended';
}

if ( $available_space < 20 * MB_IN_BYTES ) {
} elseif ( $available_space < 20 * MB_IN_BYTES ) {
$result['description'] = __( 'Available disk space is critically low, less than 20 MB available. Proceed with caution, updates may fail.' );
$result['status'] = 'critical';
}

if ( ! $available_space ) {
$result['description'] = __( 'Could not determine available disk space for updates.' );
} elseif ( $available_space < 100 * MB_IN_BYTES ) {
$result['description'] = __( 'Available disk space is low, less than 100 MB available.' );
$result['status'] = 'recommended';
}

Expand Down
8 changes: 6 additions & 2 deletions wp/wp-admin/includes/update-core.php
Original file line number Diff line number Diff line change
Expand Up @@ -1431,9 +1431,13 @@ function update_core( $from, $to ) {
} else {
$lang_dir = WP_CONTENT_DIR . '/languages';
}

/*
* Note: str_starts_with() is not used here, as this file is included
* when updating from older WordPress versions, in which case
* the polyfills from wp-includes/compat.php may not be available.
*/
// Check if the language directory exists first.
if ( ! @is_dir( $lang_dir ) && str_starts_with( $lang_dir, ABSPATH ) ) {
if ( ! @is_dir( $lang_dir ) && 0 === strpos( $lang_dir, ABSPATH ) ) {
// If it's within the ABSPATH we can handle it here, otherwise they're out of luck.
$wp_filesystem->mkdir( $to . str_replace( ABSPATH, '', $lang_dir ), FS_CHMOD_DIR );
clearstatcache(); // For FTP, need to clear the stat cache.
Expand Down
16 changes: 12 additions & 4 deletions wp/wp-config.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,24 @@

// ** Database settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define( 'DB_NAME', $_ENV['DATABASE'] );
if (isset($_ENV['DATABASE'])) {
define( 'DB_NAME', $_ENV['DATABASE'] );
}

/** Database username */
define( 'DB_USER', $_ENV['USERNAME'] );
if (isset($_ENV['USERNAME'])) {
define( 'DB_USER', $_ENV['USERNAME'] );
}

/** Database password */
define( 'DB_PASSWORD', $_ENV['PASSWORD'] );
if (isset($_ENV['PASSWORD'])) {
define( 'DB_PASSWORD', $_ENV['PASSWORD'] );
}

/** Database hostname */
define( 'DB_HOST', $_ENV['HOST'] );
if (isset($_ENV['HOST'])) {
define( 'DB_HOST', $_ENV['HOST'] );
}

/** Database charset to use in creating database tables. */
define( 'DB_CHARSET', 'utf8' );
Expand Down
42 changes: 40 additions & 2 deletions wp/wp-content/mu-plugins/serverlesswp.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,45 @@
Plugin URI: https://github.com/mitchmac/serverlesswp
Description: Plugin that makes sure your site runs smoothly on Vercel or Netlify.
Author: Mitch MacKenzie
Version: 1.0.0
Version: 1.0.1
*/

add_filter( 'got_url_rewrite', '__return_true' );
// WordPress doesn't know that serverlesswp-node emulates typical mod_rewrite behaviour.
add_filter( 'got_url_rewrite', '__return_true' );


// A notice to let people know they can't directly install themes.
function serverlesswp_theme_install_notice() {
global $pagenow;
$pages = ['themes.php'];
if (is_admin() && in_array($pagenow, $pages)) {
?>
<div class="notice notice-info">
<h2><?php _e( 'Want to add a theme?', 'serverlesswp' ); ?></h2>
<p><?php _e( 'Direct theme installation is not currently possible with serverless functions. You can still add themes to your site though!', 'serverlesswp' ); ?></p>
<p><?php _e( '<a href="https://github.com/mitchmac/ServerlessWP/discussions/35">Learn how to add themes to your site\'s git repository.</a>', 'serverlesswp' ); ?></p>
</div>
<?php
}
}

// Register the notice action.
add_action('admin_notices', 'serverlesswp_theme_install_notice');

// A notice to let people know they can't directly install themes.
function serverlesswp_plugin_install_notice() {
global $pagenow;
$pages = ['plugin-install.php', 'plugins.php'];
if (is_admin() && in_array($pagenow, $pages)) {
?>
<div class="notice notice-info">
<h2><?php _e( 'Want to add a plugin?', 'serverlesswp' ); ?></h2>
<p><?php _e( 'Direct plugin installation is not currently possible with serverless functions. You can still add plugins to your site though!', 'serverlesswp' ); ?></p>
<p><?php _e( '<a href="https://github.com/mitchmac/ServerlessWP/discussions/35">Learn how to add plugins to your site\'s git repository.</a>', 'serverlesswp' ); ?></p>
</div>
<?php
}
}

// Register the notice action.
add_action('admin_notices', 'serverlesswp_plugin_install_notice');
14 changes: 12 additions & 2 deletions wp/wp-content/plugins/amazon-s3-and-cloudfront/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
**Contributors:** wpengine, deliciousbrains, ianmjones, eriktorsner, kevinwhoffman, tysonreeder, dalewilliams, lewisia32, mattshaw, aaemnnosttv, a5hleyrich, polevaultweb, bradt, joetan \
**Tags:** uploads, amazon, s3, amazon s3, digitalocean, digitalocean spaces, google cloud storage, gcs, mirror, admin, media, cdn, cloudfront \
**Requires at least:** 5.5 \
**Tested up to:** 6.2 \
**Tested up to:** 6.3 \
**Requires PHP:** 7.2 \
**Stable tag:** 3.2.4 \
**Stable tag:** 3.2.5 \
**License:** GPLv3

Copies files to Amazon S3, DigitalOcean Spaces or Google Cloud Storage as they are uploaded to the Media Library. Optionally configure Amazon CloudFront or another CDN for faster delivery.
Expand Down Expand Up @@ -103,6 +103,16 @@ This version requires PHP 5.3.3+ and the Amazon Web Services plugin

## Changelog

### WP Offload Media Lite 3.2.5 - 2023-08-24

* New: WordPress 6.3 compatible
* New: PHP 8.2 compatible
* New: AWS PHP SDK has been updated to v3.279.0
* New: Google Cloud Storage SDK has been updated to v1.33.0 (requires PHP 7.4+)
* New: Links to plugin documentation, support, feedback, and changelog are now available in the footer of WP Admin
* Bug fix: Delivery settings check no longer logs false message about not being able to remove test object from bucket
* Bug fix: Delivery settings check no longer logs a "Could not get Block All Public Access status" message when using DigitalOcean Spaces

### WP Offload Media Lite 3.2.4 - 2023-06-26

* Bug fix: Newly added rotated images no longer fail to automatically offload
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 73a3e66

Please sign in to comment.