Advanced search  

News:

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

Pages: [1]   Go Down

Author Topic: Gallery Merge Plugin for CPG 1.5.x  (Read 2526 times)

0 Members and 1 Guest are viewing this topic.

gmc

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 721
    • GMC Design Photo Gallery
Gallery Merge Plugin for CPG 1.5.x
« on: April 18, 2015, 04:26:12 am »

I can't call this a bouncing baby plugin... at over 6,000 lines of code... and I lost count of the hours...
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)
Logged
Thanks!
Greg
My Coppermine Gallery
Need a web hosting account? See my gallery for an offer for CPG Forum users.
Send me money

Phill Luckhurst

  • Administrator
  • Coppermine addict
  • *****
  • Country: gb
  • Offline Offline
  • Gender: Male
  • Posts: 4456
    • Windsurf.me
Re: Gallery Merge Plugin for CPG 1.5.x
« Reply #1 on: April 18, 2015, 11:06:22 pm »

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

cmfa

  • Contributor
  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 226
Re: Gallery Merge Plugin for CPG 1.5.x
« Reply #2 on: April 19, 2015, 12:41:43 pm »

hi greg

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

gmc

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 721
    • GMC Design Photo Gallery
Re: Gallery Merge Plugin for CPG 1.5.x
« Reply #3 on: April 19, 2015, 01:34:36 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:
Code: [Select]
  gallery_merge_compare_structure($table_constant, $source_table, $target_table, $obsolete_keys, &$skip_keys);
to:
Code: [Select]
  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
Logged
Thanks!
Greg
My Coppermine Gallery
Need a web hosting account? See my gallery for an offer for CPG Forum users.
Send me money
Pages: [1]   Go Up
 

Page created in 0.022 seconds with 21 queries.