From 029002076404bef8eeed51d4746d8d374b874f3a Mon Sep 17 00:00:00 2001 From: Ian Dunn Date: Fri, 22 Dec 2023 08:05:00 -0800 Subject: [PATCH] Composer: Install full `wporg-mu-plugins` in local environments It's required as of 65b2f8de8088378ae6183e52f0f98dbc3f0f45e2 It was moved to the regular composer file, because having a 2nd one complicates things and doesn't seem necessary for this package. --- .docker/config/composer.json | 12 ------------ composer.json | 10 ++++++++-- .../mu-plugins/load-other-mu-plugins.php | 17 +++++++++++++++-- 3 files changed, 23 insertions(+), 16 deletions(-) diff --git a/.docker/config/composer.json b/.docker/config/composer.json index e8e6b41260..8633b97ac6 100644 --- a/.docker/config/composer.json +++ b/.docker/config/composer.json @@ -26,10 +26,6 @@ "type": "composer", "url": "https://wpackagist.org/" }, - { - "type": "vcs", - "url": "https://github.com/WordPress/wporg-mu-plugins.git" - }, { "type": "package", "package": [ @@ -124,7 +120,6 @@ "wpackagist-plugin/wp-cldr": "*", "wpackagist-plugin/wp-super-cache": "*", "wordpress-meta/wporg-profiles-wp-activity-notifier": "1.1", - "wporg/wporg-mu-plugins": "dev-build", "wpackagist-theme/p2": "*", "wpackagist-theme/twentyten": "*", "wpackagist-theme/twentyeleven": "*", @@ -139,12 +134,5 @@ "wpackagist-theme/twentytwentyone": "*", "wpackagist-theme/twentytwentytwo": "*", "wpackagist-theme/twentytwentythree": "*" - }, - "scripts": { - "post-update-cmd": [ - "mkdir -p public_html/wp-content/mu-plugins-private/wporg-mu-plugins/pub-sync", - "mv public_html/wp-content/mu-plugins/wporg-mu-plugins/mu-plugins/utilities public_html/wp-content/mu-plugins-private/wporg-mu-plugins/pub-sync", - "rm -rf public_html/wp-content/mu-plugins/wporg-mu-plugins" - ] } } diff --git a/composer.json b/composer.json index 10fe708441..ce4b16a985 100644 --- a/composer.json +++ b/composer.json @@ -20,13 +20,18 @@ }, "extra": { "installer-paths": { - "public_html/wp-content/themes/{$name}": ["wporg/wporg-parent-2021"] + "public_html/wp-content/themes/{$name}": ["wporg/wporg-parent-2021"], + "public_html/wp-content/mu-plugins-private/{$name}": ["wporg/wporg-mu-plugins"] } }, "repositories": [ { "type": "vcs", "url": "git@github.com:WordPress/wporg-parent-2021.git" + }, + { + "type": "vcs", + "url": "https://github.com/WordPress/wporg-mu-plugins.git" } ], "require": { @@ -41,7 +46,8 @@ "sirbrillig/phpcs-changed": "2.10.0", "spatie/phpunit-watcher": "^1.23", "yoast/phpunit-polyfills": "^1.0", - "composer/installers": "^2.2" + "composer/installers": "^2.2", + "wporg/wporg-mu-plugins": "dev-build" }, "scripts": { "format": "phpcbf -p", diff --git a/public_html/wp-content/mu-plugins/load-other-mu-plugins.php b/public_html/wp-content/mu-plugins/load-other-mu-plugins.php index 20123523f2..c33c1e0870 100644 --- a/public_html/wp-content/mu-plugins/load-other-mu-plugins.php +++ b/public_html/wp-content/mu-plugins/load-other-mu-plugins.php @@ -10,6 +10,8 @@ * Load mu-plugins that should run on all networks. */ function wcorg_include_common_plugins() { + // Include the private `wporg-mu-plugins` from `dotorg.svn`. These are different than the + // ones included in `wcorg_include_network_only_plugins()`. if ( file_exists( dirname( __DIR__ ) . '/mu-plugins-private/wporg-mu-plugins.php' ) ) { require_once dirname( __DIR__ ) . '/mu-plugins-private/wporg-mu-plugins.php'; } @@ -25,8 +27,19 @@ function wcorg_include_network_only_plugins() { if ( EVENTS_NETWORK_ID === SITE_ID_CURRENT_SITE ) { $network_folder = 'events'; - require_once dirname( __DIR__ ) . '/mu-plugins-private/wporg-mu-plugins/pub-sync/loader.php'; - + // Include the public `wporg-mu-plugins` that are synced from Git to SVN. These are different than the + // ones included in `wcorg_include_common_plugins()`. + // Production uses an `svn:external` to the sync directory, but the Docker environment can't install that + // because it's a private repository. It installs the open source repo, which has a slightly different + // path. + $wporg_mu_plugins_production_path = dirname( __DIR__ ) . '/mu-plugins-private/wporg-mu-plugins/pub-sync/loader.php'; + $wporg_mu_plugins_dev_path = dirname( __DIR__ ) . '/mu-plugins-private/wporg-mu-plugins/mu-plugins/loader.php'; + + if ( file_exists( $wporg_mu_plugins_production_path ) ) { + require_once $wporg_mu_plugins_production_path; + } else { + require_once $wporg_mu_plugins_dev_path; + } } else { $network_folder = 'wordcamp'; }