8000 Hacking cache generation for heroku · desyncr/heroku-buildpack-php@4aa7d13 · GitHub
[go: up one dir, main page]

Skip to content

Commit 4aa7d13

Browse files
author
DC*
committed
Hacking cache generation for heroku
[hack] Hacking jms serialization for heroku [hack] Hacking symfony cache due to symfony/symfony#12893 / see symfony/symfony#12784
1 parent 1e5b263 commit 4aa7d13

File tree

2 files changed

+38
-4
lines changed

2 files changed

+38
-4
lines changed

bin/compile

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -281,13 +281,26 @@ unset COMPOSER_GITHUB_OAUTH_TOKEN
281281
# install dependencies
282282
composer install --no-dev --prefer-dist --optimize-autoloader --no-interaction | indent
283283

284+
# hack cache for all envs
285+
status "Hacking symfony's cache"
284286
BUILD_DIR=$1
285287
APP_DIR='/app'
288+
BUILDPACK_DIRS=$(find /tmp/buildpack* -maxdepth 0 -type d)
289+
# in the case of multipack
290+
for pack in $BUILDPACK_DIRS; do
291+
if [ -f "$pack/bin/fix-metadata-paths" ]; then
292+
buildpack=$pack
293+
fi
294+
done
295+
296+
for CACHE_ENV in dev prod; do
297+
for metadata_file in $(find $BUILD_DIR/app/cache/$CACHE_ENV/jms_* -type f -name *.cache.php -not -name EnhancedProxy*); do
298+
php $buildpack/bin/fix-metadata-paths $BUILD_DIR $APP_DIR $metadata_file
299+
done
300+
301+
find $BUILD_DIR/app/cache/$CACHE_ENV -type f -not -name *.cache.php -exec sed -i "s@$BUILD_DIR@$APP_DIR@g" {} \; | indent
302+
done
286303

287-
# hack cache for all envs
288-
#for CACHE_ENV in prod dev 'test'; do
289-
# rm $BUILD_DIR/app/cache/$CACHE_ENV/jms_diextra/ -rf
290-
#done
291304
composer show --installed heroku/heroku-buildpack-php &> /dev/null && error "Your composer.json requires package 'heroku/heroku-buildpack-php'.
292305
This package may only be used as a dev dependency (in 'require-dev')!"
293306

bin/fix-metadata-paths

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
$buildDir = $argv[1];
3+
$appDir = $argv[2];
4+
$metadataFile = $argv[3];
5+
6+
require $buildDir . '/vendor/autoload.php';
7+
$instance = require $metadataFile;
8+
if (!is_object($instance)) {
9+
echo 'Could not instance serialized data from : ' . $metadataFile . PHP_EOL;
10+
11+
} else {
12+
$fileResources = $instance->fileResources;
13+
14+
foreach ($fileResources as $i => $fileResource) {
15+
$fileResources[$i] = str_replace($buildDir, $appDir, $fileResource);
16+
}
17+
$instance->fileResources = $fileResources;
18+
19+
$serialized = $instance->serialize();
20+
file_put_contents($metadataFile, $serialized);
21+
}

0 commit comments

Comments
 (0)
0