Gallery Merge Plugin for CPG 1.5.x Gallery Merge Plugin for CPG 1.5.x
 

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Main Menu

Gallery Merge Plugin for CPG 1.5.x

Started by gmc, April 18, 2015, 04:26:12 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

gmc

I can't call this a bouncing baby plugin... at over 6,000 lines of code... and I lost count of the hours...
Quote from: Joachim Müller on December 20, 2008, 11:32:16 AM
Actually merging the database records of different galleries into one falls into the category "nearly impossible", as the IDs that are supposed to be unique will exist in both galleries. This is the case for almost all key fields in all database tables - coming up with a converter that will merge two galleries into one has not been accomplished and is very far from trivial.
Merging galleries with only one admin uploader and FTP-upload plus batch-add will be comparatively easy. Merging galleries with a lot of user interaction will be hard to impossible.
...
Joachim
Well - I like a challenge... and I had a need - having merged a few sites each with their own gallery - and wanting to combine them...  I went far beyond what I needed to accomplish my merge in the hopes it will help others do the same... as I have seen a few requests over the years. The merge of both files (if local filesystem) and database (local or remote with proper credentials) is supported.

As stated in the quote above - this is far from trivial - please read the docs... and the messages from the plugin (there is a 'simulate' mode to see what will happen without making any changes that will give you warnings and errors to investigate.)
If you have questions please ask... preferably before you execute the merge.



Of course - PLEASE - backup the TARGET filesystem and database prior to running the actual merge! The SOURCE system is only read from - no changes will be made there. Yes - the script will backup the database tables being changed as well - and offers the ability to restore/backout the database changes - but ultimately the backup responsibility, and ability to recover your gallery remains YOURS.
The plugin makes no attempt to backup the target filesystem - again that responsibility is YOURS. The plugin should only update the albums directory - and based on config settings can add to plugins, languages, and themes directories. I recommend completing the merge on a test copy of your gallery first to verify expected results.



There is full mapping support to maintain relationships between usergroups, users, categories, albums, pictures... including support for userpics - creating the new folder names with correct values.
Favpics entries, picture hits, votes, keywords maintained (merged if duplicates between galleries.)

There is support that can be added ('plugins to the plugin') to accommodate 'plugin created tables' leveraging the mapping and capabilities used for core tables (example skeleton and coded script for minicms provided.)

A rather extensive readme file can be viewed at (2 documents also included in the zip file of course...):
http://greggallery.gmcdesign.com/plugins/gallery_merge/readme.php - base plugin
http://greggallery.gmcdesign.com/plugins/gallery_merge/readme_plugin_support.php - the 'plugins to the plugin'
(the readme pages are coded to be displayed in or out of coppermine...)

The results:
Old galleries:
http://greggallery2.gmcdesign.com (a copy pre-merge of the target gallery)
http://bkgallery.gmcdesign.com
http://skygallery.gmcdesign.com
New merged gallery:
http://greggallery.gmcdesign.com

The only manual tasks I did after the merge:

  •     Added 1 parent category to move the categories from skygallery under (since they are now part of a larger gallery)
  •     Moved two minicms content pages to category from main page they used to reside on...
  •     Changed content of minicms entries that had links to the old gallery names in the text.
  •     Moved 'BK gallery' category to top of list (below 'other gallery' links).
  •     Changed theme on target gallery - time for a facelift...
  •     Added link to new gallery I have (not related to merge)
And of course I have continued to add albums/pictures to the target gallery since completing the merge...

Restrictions:

  • Bridged galleries are not currently supported... Getting the information from the bridged application for users is possible - but adding new ids to the bridged application would make this 'forum merge'... and of course every bridged application is different. Supporting a bridge SOURCE to non-bridged TARGET may be doable... or if you merge the ids/groups on the forum side - we should be able to code to do the rest - if you have a need, let me know...

Disclaimers:

  • BACKUP your gallery before using 'execute' options... You alone are responsible for being able to recover your gallery.
  • There is an assumption of reasonable resources available on your site... From what I have seen on some free webhosts - that may not be a valid assumption.  There is checkpoint/quiesce/restart functionality - to set thresholds to stay within resource limits. Defaults are set to what worked for me with testing - but I have a much better than average webhost (for a shared hosting environment).
  • For file merge, I provide a method for specifying or obtaining and setting permissions that works on my Linux shared hosting environment. What permissions are right for you depends on your hosting environment. Windows is of course completely different, so allowing permissions to default may be all that works for you. See the doc for more information/options... but as in the CPG doc - file permissions are a bit beyond the scope. http://documentation.coppermine-gallery.net/en/install_permissions.htm
  • If you read the docs - you will see there is the ability to bypass warnings, errors, or entire processes. Be sure you understand what you are doing... It is enough rope to hang yourself... but of course you did take a backup first, right?
  • I will support the plugin via the forum (this thread...) to help you merge your galleries... Requests to 'merge these galleries for me' are not normal support. If you want to discuss this as a freelance request - as my time allows I will consider... and will vary on complexity.

Contributions welcome!
If you assess a plugin for impact to merge processing, let me know... (provide the array statements if you have them) I will include in the next release... (see the plugin readme above) I just couldn't review them all and release this anytime soon...
If you translate the language file, I would also be happy to include in next release. (Debug/diagnostic messages are in English so I can support you - all other informational/warning/error messages are in the language file and can be translated.)

Code is attached below.

Good luck, and let me know what you think...
Thanks!
Greg (gmc on the cpg forum)
Thanks!
Greg
My Coppermine Gallery
Need a web hosting account? See my gallery for an offer for CPG Forum users.
Send me money

phill104

Blimey Greg, that is a monster tool. Well done and great work as ever.
It is a mistake to think you can solve any major problems just with potatoes.

cmfa

hi greg

QuoteFatal error: Call-time pass-by-reference has been removed in /homepages/htdocs/home.eu/Coop/plugins/gallery_merge/functions.php on line 2170

gmc

Quote from: cmfa on April 19, 2015, 12:41:43 PM
Fatal error: Call-time pass-by-reference has been removed in /homepages/htdocs/home.eu/Coop/plugins/gallery_merge/functions.php on line 2170
That one snuck through... Pre PHP5.4 - it is an allowed, though not needed syntax... (and my test site is still at 5.3.x).
I obviously copied the function definition to the call - and didn't remove the & from the 'call by reference'.
in functions.php, change line 2170 from:

  gallery_merge_compare_structure($table_constant, $source_table, $target_table, $obsolete_keys, &$skip_keys);

to:

  gallery_merge_compare_structure($table_constant, $source_table, $target_table, $obsolete_keys, $skip_keys);

Amazingly in over 6,000 lines - appears this is the only one that slipped through... scanned for ', &', ',&' and '(&' and all remaining are function definition statements...

I'll include in V1.1.
Thanks for letting me know!
Greg
Thanks!
Greg
My Coppermine Gallery
Need a web hosting account? See my gallery for an offer for CPG Forum users.
Send me money