Skip to content

Commit 2260228

Browse files
authored
Merge branch 'develop' into move/VIP_FILESYSTEM_USE_STREAM_WRAPPER
2 parents 3daa544 + 7d63ad8 commit 2260228

File tree

61 files changed

+3531
-1717
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+3531
-1717
lines changed

.dockerignore

-4
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,6 @@ wpcom-helper.php
113113
/jetpack*/vendor/automattic/jetpack-password-checker/vendor/symfony/polyfill-php73/Resources/stubs/JsonException.php
114114
/jetpack*/vendor/automattic/jetpack-password-checker/vendor/sebastian/resource-operations/build/generate.php
115115

116-
# Files in VIP-Block-Data-API that are giving linting errors due to incompatible PHP versions
117-
**/vip-block-data-api*/vendor/symfony/polyfill-ctype/bootstrap80.php
118-
**/vip-block-data-api*/vendor/symfony/polyfill-mbstring/bootstrap80.php
119-
120116
# Search Dev Tools
121117
/search/search-dev-tools/src/
122118
/search/search-dev-tools/*.config.js

.github/workflows/changelog-summary-prod.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ on:
44
push:
55
branches:
66
- production
7+
workflow_dispatch:
78

89
permissions:
910
contents: read
11+
pull-requests: write
1012

1113
jobs:
1214
tag-release:
@@ -62,7 +64,7 @@ jobs:
6264
uses: actions/[email protected]
6365

6466
- name: Setup PHP
65-
uses: shivammathur/setup-php@v2.25.4
67+
uses: shivammathur/setup-php@2.25.4
6668
with:
6769
php-version: '7.4'
6870

.github/workflows/changelog-summary-staging.yml

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ on:
44
push:
55
branches:
66
- staging
7+
workflow_dispatch:
78

89
permissions:
910
contents: read

.github/workflows/core-tests.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ jobs:
6161
echo "GITHUB_EVENT_NAME=pull_request" >> "wordpress/.env"
6262
6363
- name: Install NodeJS
64-
uses: actions/setup-node@v3.6.0
64+
uses: actions/setup-node@v3.7.0
6565
with:
6666
node-version-file: 'wordpress/.nvmrc'
6767
cache: npm

.github/workflows/e2e.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ jobs:
5454
ghcr.io:443
5555
github.com:443
5656
nodejs.org:443
57+
objects.githubusercontent.com:443
5758
pkg-containers.githubusercontent.com:443
5859
planet.wordpress.org:443
5960
playwright.azureedge.net:443
@@ -75,7 +76,7 @@ jobs:
7576
uses: ./.github/actions/prepare-source
7677

7778
- name: Setup Node
78-
uses: actions/setup-node@v3.6.0
79+
uses: actions/setup-node@v3.7.0
7980
with:
8081
node-version: 'lts/*'
8182
cache: npm

.github/workflows/lint.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
fail-fast: 'true'
3737

3838
- name: Setup Node
39-
uses: actions/setup-node@v3.6.0
39+
uses: actions/setup-node@v3.7.0
4040
with:
4141
node-version: 'lts/*'
4242
cache: npm
@@ -55,7 +55,7 @@ jobs:
5555
uses: actions/[email protected]
5656

5757
- name: Setup Node
58-
uses: actions/setup-node@v3.6.0
58+
uses: actions/setup-node@v3.7.0
5959
with:
6060
node-version: 'lts/*'
6161
cache: npm

.github/workflows/search-dev-tools.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
token: ${{ secrets.WPCOM_VIP_BOT_TOKEN }}
2828

2929
- name: Setup Node
30-
uses: actions/setup-node@v3.6.0
30+
uses: actions/setup-node@v3.7.0
3131
with:
3232
node-version: 'lts/*'
3333
cache: npm

.github/workflows/search-e2e.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
uses: ./.github/actions/prepare-source
3939

4040
- name: "Install node v${{ env.NODE_VERSION }}"
41-
uses: actions/setup-node@v3.6.0
41+
uses: actions/setup-node@v3.7.0
4242
with:
4343
node-version: ${{ env.NODE_VERSION }}
4444
cache: npm

000-vip-init.php

+4
Original file line numberDiff line numberDiff line change
@@ -335,5 +335,9 @@
335335
define_db_constants( $GLOBALS['wpdb'] );
336336
}
337337

338+
if ( ! isset( $_SERVER['HTTP_HOST'] ) ) {
339+
$_SERVER['HTTP_HOST'] = null;
340+
}
341+
338342
do_action( 'vip_loaded' );
339343
// @codeCoverageIgnoreEnd

001-core.php

+13-3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99

1010
require_once __DIR__ . '/001-core/privacy.php';
1111

12+
if ( file_exists( __DIR__ . '/001-core/options-api.php' ) ) {
13+
require_once __DIR__ . '/001-core/options-api.php';
14+
}
15+
1216
/**
1317
* Disable current theme validation
1418
*
@@ -49,9 +53,15 @@ function wpcom_vip_disable_core_update_cap( $caps, $cap ) {
4953
function vip_disable_unnecessary_site_health_tests( $tests ) {
5054
// Disable "Background Updates" test.
5155
// WordPress updates are managed by the VIP team.
52-
if ( isset( $tests['async'] ) && isset( $tests['async']['background_updates'] ) ) {
53-
unset( $tests['async']['background_updates'] );
54-
}
56+
unset( $tests['async']['background_updates'] );
57+
58+
// Disable "WP-Content Writable" test.
59+
// Code updates are managed in GitHub.
60+
unset( $tests['direct']['update_temp_backup_writable'] );
61+
62+
// Disable "Available disk space" test.
63+
// We manage the disk space, test gives bogus results.
64+
unset( $tests['direct']['available_updates_disk_space'] );
5565

5666
return $tests;
5767
}

001-core/options-api.php

+79
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
<?php
2+
3+
// phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery
4+
5+
namespace Automattic\VIP\Core\OptionsAPI;
6+
7+
/**
8+
* Add additional protections around the alloptions functionality.
9+
*
10+
* Note that there is one (unavoidable) core call to get_option() before this filter is registered (in wp_plugin_directory_constants()),
11+
* So by the time this starts filtering, there's already been one occurrence of wp_load_alloptions().
12+
*
13+
* Here we re-implement most of what core does in wp_load_alloptions(), with some notable adjustments:
14+
* - 1) Prevent spamming memcached & the DB if memcached is unable to add() the key to cache.
15+
* - 2) Kill the request if options cannot be retrieved from the database (or cache).
16+
*/
17+
add_filter( 'pre_wp_load_alloptions', __NAMESPACE__ . '\pre_wp_load_alloptions_protections', 2, 999 );
18+
function pre_wp_load_alloptions_protections( $pre_loaded_alloptions, $force_cache ) {
19+
global $wpdb;
20+
static $fallback_cache = [];
21+
22+
// Allow other filters the chance to early return (before priority 999).
23+
// And abort from this special handling during installations.
24+
if ( is_array( $pre_loaded_alloptions ) || wp_installing() ) {
25+
return $pre_loaded_alloptions;
26+
}
27+
28+
// 1) If successfully fetched from cache, return right away.
29+
$alloptions_from_cache = wp_cache_get( 'alloptions', 'options', $force_cache );
30+
if ( ! empty( $alloptions_from_cache ) && is_array( $alloptions_from_cache ) ) {
31+
return apply_filters( 'alloptions', $alloptions_from_cache );
32+
}
33+
34+
// 2) Return from the local fallback cache if available, helping prevent excess queries in cases where memcached is unable to save the results.
35+
$blog_id = get_current_blog_id();
36+
if ( ! $force_cache && isset( $fallback_cache[ $blog_id ] ) ) {
37+
return apply_filters( 'alloptions', $fallback_cache[ $blog_id ] );
38+
}
39+
40+
// 3) Otherwise query the DB for fresh results.
41+
$suppress = $wpdb->suppress_errors();
42+
$alloptions_db = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options WHERE autoload = 'yes'" );
43+
$wpdb->suppress_errors( $suppress );
44+
45+
$alloptions = [];
46+
foreach ( (array) $alloptions_db as $o ) {
47+
$alloptions[ $o->option_name ] = $o->option_value;
48+
}
49+
50+
if ( empty( $alloptions ) ) {
51+
trigger_error( 'VIP: Unable to query alloptions from database.', E_USER_WARNING );
52+
53+
if ( defined( '_VIP_DIE_ON_ALLOPTIONS_FAILURE' ) && true === constant( '_VIP_DIE_ON_ALLOPTIONS_FAILURE' ) ) {
54+
http_response_code( 503 );
55+
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- no need to escape the premade HTML file
56+
echo file_get_contents( dirname( __DIR__ ) . '/errors/alloptions-limit.html' );
57+
exit;
58+
}
59+
60+
return apply_filters( 'alloptions', apply_filters( 'pre_cache_alloptions', $alloptions ) );
61+
}
62+
63+
$alloptions = apply_filters( 'pre_cache_alloptions', $alloptions );
64+
$add_result = wp_cache_add( 'alloptions', $alloptions, 'options' );
65+
66+
if ( false === $add_result && false === wp_cache_get( 'alloptions', 'options', true ) ) {
67+
// Prevent memory issues in case something is looping over thousands of subsites.
68+
if ( count( $fallback_cache ) > 10 ) {
69+
$fallback_cache = [];
70+
}
71+
72+
// Start using the fallback cache if this request both failed to add() to cache, and there is
73+
// nothing currently there - indicating there is likely something wrong with the ability to cache alloptions.
74+
// Note that this is already the second time the request would have tried.
75+
$fallback_cache[ $blog_id ] = $alloptions;
76+
}
77+
78+
return apply_filters( 'alloptions', $alloptions );
79+
}

001-cron.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ function wpcom_vip_cron_control_event_object_to_string( $event ) {
106106
/**
107107
* Should Cron Control load
108108
*/
109-
if ( ! wpcom_vip_use_core_cron() ) {
109+
if ( ! wpcom_vip_use_core_cron() && is_blog_installed() ) {
110110
/**
111111
* Prevent plugins/themes from blocking access to our routes
112112
*/

README.md

+18-5
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,18 @@ e.g: 20210917.0
113113

114114
Releases are created using GitHub's releases and are effectively a tag in the GitHub repository. Previous releases can be found [here](https://github.com/Automattic/vip-go-mu-plugins/releases/).
115115

116-
To create a new release, please use the `create-release` script. The script requires the [GitHub CLI](https://github.com/cli/cli) to be installed in the computer. It will create the new release, properly tagged and with the expected description.
116+
To create a new production release:
117117

118-
```
119-
cd vip-go-mu-plugins
118+
1. Create a new PR: https://github.com/Automattic/vip-go-mu-plugins/compare/production...staging
119+
2. Name it `Production release: vYYYYMMDD.0`.
120+
3. After carefully reviewing and making sure all test have passed, merge it.
121+
4. The changelog will be generated automatically, and a bot will ping you to proof-read the draft
122+
5. Any follow-up releases on the same day should increment the last number. E.g. `Production release: vYYYYMMDD.0`
123+
124+
To create a new staging release, follow the same steps but name the release `Staging release: vYYYYMMDD.1` (assuming production release has been tagged already.)
125+
126+
https://github.com/Automattic/vip-go-mu-plugins/compare/staging...develop
120127

121-
bin/create-release.sh
122-
```
123128

124129
### Production
125130

@@ -130,3 +135,11 @@ bin/create-release.sh
130135
This is a repo primarily meant for local non-development use.
131136

132137
Every commit merged into `develop` is automatically pushed to the public copy at [Automattic/vip-go-mu-plugins-built](https://github.com/Automattic/vip-go-mu-plugins-built/). This is handled via CI by the [`deploy` action](https://github.com/Automattic/vip-go-mu-plugins/blob/develop/.github/workflows/deploy.yml), which pushes a copy of this repo and expanded submodules.
138+
139+
## Changelog
140+
141+
We use a [script](./ci/changelog-summary.php) to generate changelog entries. This can be debuged by running:
142+
143+
```
144+
php ci/changelog-summary.php --debug --dry-run --force --merge-pr 4673 --github-project-username Automattic --github-project-reponame vip-go-mu-plugins
145+
```

0 commit comments

Comments
 (0)