Skip to content

Commit b9918e3

Browse files
committed
Move release constants to release/
I don't want anything defined in root constants.php because I have rector doing some aggressive dead code elimination based on those constants. - Move wp-org/constants.php to release/wp-org/... - Move constants.php to release/github/... and leave root constants.php with no defs. - Update flake.nix to use these new paths This lets the GitHub build do dead code elimination to remove unneeded WP functions.
1 parent 92752b0 commit b9918e3

File tree

4 files changed

+22
-13
lines changed

4 files changed

+22
-13
lines changed

constants.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,3 @@
77
* in order to remove code entirely at build-time if
88
* a feature is disabled.
99
*/
10-
11-
// Disable the use of functions that wordpress.org requires
12-
// but we would not use when we aren't forced to.
13-
// e.g. using wp_rand instead of mt_rand in a context
14-
// where a CSPRNG adds no value.
15-
// This is just to enable useless functions, not WP
16-
// functions that do serve some purpose.
17-
define( 'STATIC_DEPLOY_WP_ORG_MODE', false );

flake.nix

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@
4646
&& pkgs.lib.hasSuffix ".php" base || base == "composer.json" || base
4747
== "composer.lock" || base == "phpcs.xml" || base == "phpunit.xml";
4848
};
49-
wpOrgExtras = pkgs.lib.cleanSourceWith {
49+
releaseExtras = pkgs.lib.cleanSourceWith {
5050
src = self;
5151
filter = path: type:
5252
let base = baseNameOf path;
53-
in type == "directory" && base == "wp-org"
54-
|| pkgs.lib.hasInfix "/wp-org/" path;
53+
in type == "directory" && base == "release"
54+
|| pkgs.lib.hasInfix "/release/" path;
5555
};
5656
buildStaticDeploySrc = constantsFile:
5757
runCommand "static-deploy-source" {
@@ -74,9 +74,9 @@
7474
cp -r composer.json src static-deploy.php uninstall.php vendor views "$out"
7575
'';
7676
staticDeployWpOrgSrc =
77-
buildStaticDeploySrc "${wpOrgExtras}/wp-org/constants.php";
77+
buildStaticDeploySrc "${releaseExtras}/release/wp-org/constants.php";
7878
staticDeployGitHubSrc =
79-
buildStaticDeploySrc "${staticDeploySrc}/constants.php";
79+
buildStaticDeploySrc "${releaseExtras}/release/github/constants.php";
8080
pluginZip = source:
8181
runCommand name { } ''
8282
mkdir "$TMPDIR/${name}"

release/github/constants.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
/**
3+
* This file can be added to in order to force
4+
* rector to use certain values for constants.
5+
* This is mainly used in statements like
6+
* if ( FEATURE_ENABLED ) { ... }
7+
* in order to remove code entirely at build-time if
8+
* a feature is disabled.
9+
*/
10+
11+
// Disable the use of functions that wordpress.org requires
12+
// but we would not use when we aren't forced to.
13+
// e.g. using wp_rand instead of mt_rand in a context
14+
// where a CSPRNG adds no value.
15+
// This is just to enable useless functions, not WP
16+
// functions that do serve some purpose.
17+
define( 'STATIC_DEPLOY_WP_ORG_MODE', false );
File renamed without changes.

0 commit comments

Comments
 (0)