Feature #3189
closedFeature #3177: Upgrade bbPress to 2.x
Migrate forum attachments to bbPress 2.x / GD attachments
0%
Description
Our current bbPress (1.x) implementation uses the following homegrown plugin to store forum post attachments: http://wordpress.org/plugins/forum-attachments-for-buddypress/ As part of the migration to bbPress 2.x, we'll need to migrate this content. Brief outline of the approach:
- Reverse engineer how the GD plugin stores attachments
- Ensure that our bbPress 1.x-2.x migration keeps track of old post IDs, so we have the necessary data to do the migration (Ray, maybe you know off the top of your head whether this is the case)?
- Write a script to do the necessary migration. This will involve both moving the files themselves (from the current bb-attachments directory), as well as recording the attachment metadata. Hopefully the GD plugin has good API-level functions we can use
- Ideally, we'll maintain backward compatibility with permalinks. Old attachment URLs look like this: commons.gc.cuny.edu/wp-content/plugins/forum-attachments-for-buddypress/download.php?filenum=2948. Probably the simplest idea is to rewrite that download.php script so that it looks up old file attachment 2948 and then redirects to the proper URL. To make it a bit prettier and more portable, I could couple it with a .htaccess rewrite rule that would direct these download.php requests to a handler that doesn't depend on the old plugin file being there, and then do the redirect. Note that this technique will require keeping track somewhere (postmeta?) of the old "filenum" data.
Updated by Raymond Hoh over 10 years ago
- Ensure that our bbPress 1.x-2.x migration keeps track of old post IDs, so we have the necessary data to do the migration (Ray, maybe you know off the top of your head whether this is the case)?
bbPress 2 is smart enough during conversion to record a new post meta entry called '_bbp_post_id'
for forum replies and '_bbp_old_topic_id'
for forum topics, which references bbPress 1's post IDs. These can then be used by a migration script to do their thang.
You might want to take a look at a similar plugin I wrote to migrate attachments from u BP Forum Attachments to bbPress 2. I didn't copy the attachments over to WordPress or a bbPress forum attachment plugin because at the time, we didn't decide whether GD was good enough.
In particular, the migration and admin tool code should be handy to look at.
Updated by Boone Gorges about 10 years ago
Thanks for linking to your repo, Ray - it was a helpful data point.
https://github.com/castiron/cac/commit/e59be24140493a9700c2b4511530dd0b8f4280f9 contains the following:
- the GD bbPress Attachments plugin
- my cac-bbpress-attachments-bridge plugin, which contains a migrator as well as a backward compatibility fix for old URLs
- a change to .htaccess that allows us to remove forum-attachments-for-buddypress
I'll deploy to cdev for testing as soon as it's back up.
Updated by Boone Gorges almost 10 years ago
I've run the migration on cdev, and it's gone fine. See eg http://cdev.gc.cuny.edu/groups/cac-community-team-project-planning/forum/topic/commonsinabox-org-homepage/ (never mind the dupe on the top post - I messed up the migration the first time I ran it)
I've realized in testing that there's no access protection in place. See http://cdev.gc.cuny.edu/files/CBOX-Homepage-v2.1.png. I'll probably do something fairly quick and dirty for this rev - maybe direct all requests to http://cdev.gc.cuny.edu/files/* in .htaccess and send them to a ms-files.php-type handler that does permissions checks. Ugh
Updated by Boone Gorges almost 10 years ago
- Status changed from Assigned to Resolved
In https://github.com/cuny-academic-commons/cac/commit/75c9456f620093f455d97fa6fd4e32498a48e48d https://github.com/cuny-academic-commons/cac/commit/d19ae9f59defc287079b97785b4e2b44c88465a0, I divert file uploads through our own cac-files.php. I've tried to be as conservative as possible in terms of file routing: only disable SHORTINIT if looking at the "top-level" site (no subdomains); only protect files that are in private groups. But as you can see from the changeset, getting from a file attachment name to a definitive statement on permissions takes many steps.
I'm going to mark this as resolved, and we'll make sure to include some notes on the subject when we do team testing before release.
Updated by Boone Gorges almost 10 years ago
- Status changed from Resolved to Assigned
- Assignee changed from Boone Gorges to Raymond Hoh
Ray - One last note about this. GD was being kinda greedy about when it displayed its content, and was putting it into the bbp-live-preview AJAX request. I fixed it like this https://github.com/cuny-academic-commons/cac/commit/8c6bb7f1439f8a6e40d791064b367b07ca4f5e9a. I think it would probably be harmless to put this into the bbp-live-preview plugin (this is a fairly popular add-on, I think), but if not, maybe you could put a do_action() right there, so I can avoid touching the GD plugin. Let me know what you think, and I'll reclose this ticket.
Updated by Raymond Hoh almost 10 years ago
Thanks Boone! I've added your GD bbPress Attachment changes into the bbp-live-preview plugin.
Updated by Boone Gorges almost 10 years ago
- Status changed from Assigned to Resolved
Cool! Marking resolved.