Create symlink after Capistrano deploy

I am fairly new to using Capistrano so I apologize for a noob question.

I had to make a change to a Buddypress core file. I figured that I could move the modified file into the shared directory and use linked_files. The problem is that the symlinks are created after Composer update thus removing my symlink.

How can I re-run the symlink task?

Little confused between Capistrano and Composer here. Do you mean that Buddypress is loaded via Composer? And composer install is run AFTER Capistrano’s symlinking so the file isn’t there yet?

Sorry for the lack of detail. Here’s more information.

I am using Bedrock for the site. Amazing tool. Saving me and my team a TON of time. The site uses Buddypress. The plugin is installed via Composer. The site is being deployed into staging and production via capistrano. All is well and good.

The client wants to change the way that BB group avatars are cropped. The default is a square - we want a rectangle. The crop tool is using WP’s instance of JCrop. I had to change two core files (bp-core-avatars.php and bp-core-cssjs.php) to get the functionality that we wanted.

These files will be overwritten when composer update runs on the server. So, I figured that I could put the modified core files into a separate directory and then copy them into the correct location as part of the deploy.

To test, I put the files in the appropriate location within the shared folder on the server. The symlinks tasks runs before the composer update. So they are setup correctly and then overwritten. I added the following to the deploy.rb file:

after 'deploy:publishing' , 'deploy:symlink:linked_files'

And it works - the linked_files tasks is run. But the script checks to see if the links are there and doesn’t re-run if files (symlinks or real) are present. I have been running down the rabbit hole trying to get the capistrano script to dance like I need it.

Now I’m questioning if I’m going about this correctly. I’m looking into if/how I can override the BP function.

Does that help?

Yep, all makes sense now.

Yeah ideally there’s a better way to override that cropping option either in BuddyPress or in JS. But there’s definitely another easier option you can do.

You could just create a fork of Buddypress with those 2 modified files. Then point your composer.json to your modified fork (on GitHub, or a zip somewhere, doesn’t matter).

Sorry for the delay. That worked perfectly. I was over engineering the solution. Thanks for showing me the light!