Code Monkey home page Code Monkey logo

vip-go-mu-plugins's Introduction

VIP Go mu-plugins

This is the development repo for mu-plugins on VIP Go.

Documentation

Enterprise Search

Please, visit our Enterprise Search documentation to learn more.

Development

Local Dev

We recommend using the VIP local development environment for local development: https://docs.wpvip.com/technical-references/vip-local-development-environment/

We also have to ensure that we have our dependencies installed - so first, run the following:

git submodule update --init --recursive
composer install
npm install

To use mu-plugins code in a "hot-reload" fashion you need to specify the local folder to which this repository is cloned. For example:

vip dev-env create --mu-plugins $(pwd)

You will be prompted to configure other options of the environment. When the environment is created you can start it with:

vip dev-env start

Tests

PHP Lint
npm run phplint
PHPCS

We use eslines to incrementally scan changed code. It will automatically run on pre-push (see .huskyrc.json).

This is also run on Circle CI for all PRs.

If you want to scan the entire codebase:

npm run phpcs
PHPUnit

If you don't have the Lando-based environment running (e.g. in a CI context), we have a script that runs unit tests in a self-contained Docker environment. To run these tests, execute the following from the project root:

./bin/test.sh

You can also filter by test name.

./bin/test.sh --filter test__rate_limit_ep_query_integration__clears_start_correctly

See ./bin/test.sh for more options.

CI

PHP Linting and PHPUnit tests are run by Circle CI as part of PRs and merges. See .circleci/config.yml for more.

Core tests

We run core tests as part of the CI pipeline. There are many failures when running with mu-plugins so we had to ignore several tests. To add another test there check bin/utils.sh.

To investigate failing test locally you can do following (buckle up as this is not so easy:()):

  1. While in your mu-plugins folder do MU_PLUGINS_DIR=$(pwd)

  2. Switch to where you want to checkout core code e.g. cd ~/svn/wp

  3. Checkout the core code (pick the latest version): svn co --quiet --ignore-externals https://develop.svn.wordpress.org/tags/5.5.3 .

  4. Create test config: cp wp-tests-config-sample.php wp-tests-config.php && sed -i 's/youremptytestdbnamehere/wordpress_test/; s/yourusernamehere/root/; s/yourpasswordhere//; s/localhost/127.0.0.1/' wp-tests-config.php

  5. Build core npm ci && npm run build

  6. Export env variable export WP_TESTS_DIR="$(pwd)/tests/phpunit"

  7. Start local DB: docker run -d -p 3306:3306 circleci/mariadb:10.2

  8. Create empty DB mysqladmin create wordpress_test --user="root" --password="" --host="127.0.0.1" --protocol=tcp

  9. Copy over MU-plugins cp -r $MU_PLUGINS_DIR build/wp-content/mu-plugins

  10. Run the test you want (in this case test_allowed_anon_comments) $MU_PLUGINS_DIR/vendor/bin/phpunit --filter test_allowed_anon_comments

Deployment

Release

A new release of the plugin consists of all those pull requests that have been merged since the last release and have been deployed to Staging (i.e. have the [Status] Deployed to staging label. Releases are named after the day they are released plus a minor version:

YYYYMMDD.x

e.g: 20210917.0

Releases are created using GitHub's releases and are effectively a tag in the GitHub repository. Previous releases can be found here.

To create a new production release:

  1. Create a new PR: https://github.com/Automattic/vip-go-mu-plugins/compare/production...staging
  2. Name it Production release: vYYYYMMDD.0.
  3. After carefully reviewing and making sure all test have passed, merge it.
  4. The changelog will be generated automatically, and a bot will ping you to proof-read the draft
  5. Any follow-up releases on the same day should increment the last number. E.g. Production release: vYYYYMMDD.0

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.)

https://github.com/Automattic/vip-go-mu-plugins/compare/staging...develop

Production

For Automattic Use: Instructions are in the FG :)

vip-go-mu-plugins-built

This is a repo primarily meant for local non-development use.

Every commit merged into develop is automatically pushed to the public copy at Automattic/vip-go-mu-plugins-built. This is handled via CI by the deploy action, which pushes a copy of this repo and expanded submodules.

Changelog

We use a script to generate changelog entries. This can be debuged by running:

php ci/changelog-summary.php  --debug --dry-run --force --merge-pr 4673 --github-project-username Automattic --github-project-reponame vip-go-mu-plugins

vip-go-mu-plugins's People

Contributors

acicovic avatar brettshumaker avatar chrean avatar david-binda avatar dchymko avatar dependabot[bot] avatar emrikol avatar ethitter avatar garyjones avatar gudmdharalds avatar hanifn avatar jblz avatar jesse-greathouse avatar joshbetz avatar luiztiago avatar mjangda avatar nickdaugherty avatar pauarge avatar pschoffer avatar rebeccahum avatar renovate-bot avatar rinatkhaziev avatar saroshaga avatar sboisvert avatar scottsweb avatar simonwheatley avatar sjinks avatar trepmal avatar vaurdan avatar wpprodigy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vip-go-mu-plugins's Issues

Objects to objects plugin needs autoloader for UI

On wpcom, we're auto loading wpcom-helper.php, which itself sets up an autoloader to include some UI code (such as Post_Selection_UI).

This is required to prevent fatals.

Depending on what direction we take with Shared Plugins, this may be a moot point...but should be addressed if we continue to provide the plugin.

Email wording to first user

The email wording to the first user includes:

Username: blahblahblah
Password: The password you chose during the install.

We should change this to tell the user to use the forgotten password routine, or perhaps trigger a forgotten password email instead of this email, so they can directly set their password.

Use i{0|1|2}.wp.com Photon urls in development, use VIP Go Photon urls in production

We should use the Jetpack Photon module everywhere, but in production, we should use the VIP Go instance of Photon, for some performance and caching benefits.

This means we should filter jetpack_photon_url in production to use the VIP Go urls (which look like regular files urls, with <domain>/wp-content/uploads/...?<params> instead of 'regular' Photon urls.

Jetpack staging sites

We should use the Jetpack filters to identify all sites which aren't on VIP Go production infrastructure as staging sites.

This should help when a developer takes a verbatim backup of the data, imports it locally, and causes a Jetpack identity crisis.

Sending mail does not work on VIPv2

Trying to send mail from the Lost Password flow results in:

The e-mail could not be sent.
Possible reason: your host may have disabled the mail() function.

Trying to send a verification email from the support plugin silently fails, and the mail never arrives.

Support the BuddyPress mailer

I have tested and BuddyPress emails currently aren't being delivered. Regular WordPress core emails are.

In the upcoming BP 2.5 release, we totally re-implemented how emails are sent. We do not use wp_mail(). We still use phpMailer, but not the global $phpmailer instance of it that WordPress sets.

I see VIP Go uses a helper plugin to configure the phpMailer instance: https://github.com/Automattic/vip-mu-plugins-public/blob/master/vip-mail.php hooked to action phpmailer_init. BP 2.5 has a very similar action that works in the same way: bp_phpmailer_init.

See https://github.com/wpcomvip/buddypress-core-test/issues/5

Don't cache requests when the Query Monitor cookie is set

Query Monitor optionally sets a cookie which allows viewing Query Monitor information on requests where the user is not logged in. We should set no-cache headers on these requests, so the responses (with QM information) don't get caught in caches like Varnish.

johnbillion/query-monitor#170

We should initially patch this here, then also send a PR against the Query Monitor repo issue above.

Enable debug bar for all admins

We don't need to be the gatekeepers of that data, as long as we are careful of what we expose there (absolute paths, other sensitive info).

That would take finding slow queries out of the VIP realm and into client-land.

Unspoofably identify A11n users

Currently we identify A11n users by having them verify their A8c email address. This is ๐Ÿ‘

Then we store the fact they've verified their email in meta, where any developer or person with CLI access could add spoofed data. This is ๐Ÿ‘Ž

We should have a way to determine if someone is an A11n, probably by looking at whether they are proxied or not.

Add a CLI command to purge the site cache

It would be useful for us to be able to purge the Varnish cache for pages and/or files from a CLI command.

Some args that would be useful for this:

  • local (i.e. sandbox) vs global (i.e. "production) caches
  • full cache vs specific URL

gzuncompress

PHP Warning:  gzuncompress(): data error in /var/www/wp-content/mu-plugins/http-concat/ngx-http-concat.php on line 96

Disable theme install UI

Since everything is in version control, there should never be a UI to upload or browse themes to install.

theme-browser

add-theme-button

/wp-admin/theme-install.php

Disable NR client-side monitoring when rendering an AMP page

NR will inject the client side JS to the page by default, but that breaks the idea of AMP (and AMP validation), so we should disable it automatically on AMP pages.

Props to @mjangda for this code snippet:

add_action( 'pre_amp_render_post', function() {  newrelic_disable_autorum(); } );

We probably also want to expose this functionality as a wpcom_vip_ helper function that clients can use anywhere. h/t @david-binda and @sboisvert

Query Monitor not loading / enabling

MU Plugins got deployed today, but QM doesn't seem to be spinning up.

I tried forcing wpcom_vip_qm_enable to true on for test-03.go-vip.co but still no-go.

Tests are failing as they aren't version specific

Error:

phpunit
Installing...
Running as single site... To run multisite, use -c tests/phpunit/multisite.xml
PHP Fatal error:  Class 'WP_REST_Server' not found in /tmp/wordpress-tests-lib/includes/spy-rest-server.php on line 3
PHP Stack trace:
PHP   1. {main}() /home/travis/.phpenv/versions/5.5.21/bin/phpunit:0
PHP   2. PHPUnit_TextUI_Command::main() /home/travis/.phpenv/versions/5.5.21/bin/phpunit:722
PHP   3. PHPUnit_TextUI_Command->run() phar:///home/travis/.phpenv/versions/5.5.21/bin/phpunit/phpunit/TextUI/Command.php:104
PHP   4. PHPUnit_TextUI_Command->handleArguments() phar:///home/travis/.phpenv/versions/5.5.21/bin/phpunit/phpunit/TextUI/Command.php:114
PHP   5. PHPUnit_TextUI_Command->handleBootstrap() phar:///home/travis/.phpenv/versions/5.5.21/bin/phpunit/phpunit/TextUI/Command.php:622
PHP   6. PHPUnit_Util_Fileloader::checkAndLoad() phar:///home/travis/.phpenv/versions/5.5.21/bin/phpunit/phpunit/TextUI/Command.php:792
PHP   7. PHPUnit_Util_Fileloader::load() phar:///home/travis/.phpenv/versions/5.5.21/bin/phpunit/phpunit/Util/Fileloader.php:42
PHP   8. include_once() phar:///home/travis/.phpenv/versions/5.5.21/bin/phpunit/phpunit/Util/Fileloader.php:58
PHP   9. require() /home/travis/build/Automattic/vipv2-mu-plugins/tests/bootstrap.php:15
PHP  10. require() /tmp/wordpress-tests-lib/includes/bootstrap.php:101

See Automattic/Co-Authors-Plus@7f70994 for a possible solution

Support Query Monitor

Query Monitor has been asked for a few times now, but we've traditionally limited access to these tools because they disclose too much information about our systems (full server paths, namely).

Fortunately, Query monitor uses relative paths throughout its output, and allows panels to be removed via remove_filter() calls, so we can suppress the environment panel, at the least.

Merge the two plugins tables on the VIP Plugins page

/wp-admin/admin.php?page=vip-plugins shows 2 plugins tables, one for plugins from wp-content/plugins, the second from non-FPP shared plugins.

This is confusing, and the first table is the Core plugins table, which doesn't respect loading plugins via code, which is another issue.

Support non-standard filepaths for shared plugins in wpcom_vip_load_plugin()

Not all plugins follow the $plugin/$plugin.php convention, including shared plugins.

By requiring that rigid filepath, we prevent submoduling some shared plugins (like WP-API), as we can't add our own bootstrap file there.

We're using get_plugins() internally to get valid plugins, so we should support loading any plugin that it returns, regardless of path to plugin file.

Fatal error when including non-shared plugins via wpcom_vip_load_plugin()

Fatal error: Call to undefined function get_plugins() in wp-content/mu-plugins/vip-helpers/vip-utils.php on line 970

This happens because get_plugins() hasn't been included on the frontend, as it's defined in wp-admin/includes/plugin.php.

get_plugins() is used to properly load plugins that don't have a 1:1 folder name -> php file correlation; i.e, it finds the right plugin file to load.

Adding require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); to vip-helpers/vip-utils.php works - thoughts?

wpcom_vip_load_plugin: Show context

We should really be triggering a fatal error when wpcom_vip_load_plugin bails. This will print a backtrace in dev environments, which makes it much easier to debug.

Make it easier to verify SSL certificates

Many SSL issuers allow you to use domain validation for an SSL, typically by having your website at the domain respond with a particular string at a particular path.

We should make it easy to define the path and string, so we can efficiently validate sites on our platform for SSL.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.