File tree Expand file tree Collapse file tree 3 files changed +44
-1
lines changed
Expand file tree Collapse file tree 3 files changed +44
-1
lines changed Original file line number Diff line number Diff line change 6060 " library/README.md" ,
6161 " LICENSE" ,
6262 " README.md"
63- ]
63+ ],
64+ "replace" : {
65+ "library/Requests.php" : " Requests.php"
66+ }
6467 },
6568 "simplepie/simplepie" : {
6669 "target" : " src/wp-includes/SimplePie" ,
Original file line number Diff line number Diff line change 1+ <?php
2+ /**
3+ * Loads the old Requests class file when the autoloader
4+ * references the original PSR-0 Requests class.
5+ *
6+ * @deprecated 6.2.0
7+ * @package WordPress
8+ * @subpackage Requests
9+ * @since 6.2.0
10+ */
11+
12+ include_once ABSPATH . WPINC . '/class-requests.php ' ;
Original file line number Diff line number Diff line change @@ -110,9 +110,37 @@ private function modifyPaths( PackageInterface $package ): void {
110110 $ installPath = $ this ->getInstallPath ( $ package );
111111
112112 $ this ->applySourceSubdirectory ( $ package , $ installPath );
113+ $ this ->applyReplacements ( $ package , $ installPath );
113114 $ this ->applyIgnorePatterns ( $ package , $ installPath );
114115 }
115116
117+ /**
118+ * Apply file replacements from custom replacement files.
119+ *
120+ * @param PackageInterface $package The package.
121+ * @param string $installPath The installation path.
122+ */
123+ private function applyReplacements ( PackageInterface $ package , string $ installPath ): void {
124+ $ packageName = $ package ->getName ();
125+
126+ if ( ! isset ( $ this ->installerPaths [ $ packageName ]['replace ' ] ) ) {
127+ return ;
128+ }
129+
130+ $ filesystem = new Filesystem ();
131+ $ replacementsDir = realpath ( getcwd () ) . '/tools/composer/replacements ' ;
132+
133+ foreach ( $ this ->installerPaths [ $ packageName ]['replace ' ] as $ target => $ source ) {
134+ $ sourcePath = $ replacementsDir . '/ ' . $ source ;
135+
136+ if ( ! file_exists ( $ sourcePath ) ) {
137+ throw new \RuntimeException ( "Replacement file 'tools/composer/replacements/ {$ source }' does not exist for package ' {$ packageName }'. " );
138+ }
139+
140+ $ filesystem ->copy ( $ sourcePath , $ installPath . '/ ' . $ target );
141+ }
142+ }
143+
116144 /**
117145 * Apply ignore patterns to remove unwanted files after installation.
118146 *
You can’t perform that action at this time.
0 commit comments