Hi,
I have been running Gallery for a long time. First G1, then G2 and now G3.
G2 supported migrating from G1, and G3 support migratiog from G3. But does
G3 support migrating from a G2, that was supporting migrating from G1?
I have been running G2 and G3 in parallel, G2 because I want all old picture
links to work, but I'd like to go fully into G3 and retire old G2 install.
But this requires that also the G1-era links continue to work perfectly.
Any help will be greatly appreciated, I have 39GB/32000pcs pictures, and
keeping all thsi duplicated is not something I want to continue forever.
-Paavo
Posts: 1857
I don't see why it wouldn't work (as long as you don't overwrite whatever htaccess rewrites/redirects are handling your Gallery1 to Gallery2 migration).
My suggestion:
1) Back up everything.
2) Make sure you've backed up EVERYTHING.
3) Install Gallery3.
4) Do the Gallery2 to Gallery3 migration.
5) See what happens.
You may have to cut/paste sections of the htaccess file that you already have into the new htaccess file that's created; not sure.
If it doesn't work, you can go back--assuming you backed up everything (including the database) BEFORE you start this.
(Also, looking at the number of photos and size of your install, you may want to create a new, smaller test site using Gallery1, upgrade it to Gallery2, then try to upgrade that to Gallery3. It's an extra step, but it will save a lot of time vs. upgrading and trying to troubleshoot a much larger install.)
Posts: 54
1) - 5) done, here is my G2 .htaccess:
and I get a lot of this:
Should I remove (comment out) the original G2 part of the .htaccess?
-Paavo
Posts: 54
Uh, silly me
must be in separate lines
Looks like it works!
-Paavo
Posts: 54
Hi,
I have been running G1 and G2 for a long time in HOST_OLD, which
is disappearing soon. I installed G3 in it, but I soon copied G3
to a new host, HOST_NEW.
I want to migrate G1/G2/G3 from HOST_OLD to G3 in HOST_NEW.
Should this do the trick? Part of HOST_OLD apache configuration:
Directories albums, gallery and gallery3 in HOST_OLD have been
renamed to something else, if all works fine I'll nuke those later.
Comments please, I'm not an expert with apache redirects, just got
rewrite to work within one host...
-Paavo
Posts: 54
Hi,
this works, ie. G3 in HOST_NEW displays it:
but these do not work, G3 in HOST_NEW displays error page:
All links worked from HOST_OLD, and no pictures have been deleted.
-Paavo
Posts: 1857
I don't understand the last two posts.
Are you changing domain names, or just moving to a new host?
If changing to a new host, you shouldn't need any of that.
If changing domain names, you have to still have access to the old domain name, and just one redirect (in the root folder of the old domain) would do it:
Redirect 301 /gallery3 http://new-domain-name/gallery3
Posts: 54
Hi,
I'm changing domain names.
HOST_OLD will disappear completely, so whatever is in it will be only used for a few weeks max,
but even for that short period of time, I'd like to have G1/G2/G3 from HOST_OLD to be redirected
to HOST_NEW (in very diffrerent domain) as completely as possible.
One thought:
if I create albums and gallery directories in HOST_NEW (gallery3 exists already), and put appropriate .htaccess in those (otherwise the albums and gallery directories are completely empty).
This for albums/.htaccess (copied from HOST_OLD albums/.htaccess without changes):
This for gallery/.htaccess (as listed by G2 -> G3 migration instructions):
Then I can just have these in HOST_OLD:
Right?
And then all "zillion" links to the old pictures in HOST_OLD gallery could be
fixed to point to the HOST_NEW gallegy just by changing the host name part
of the link, and HOST_NEW set-up would take care of G1/G2 migration to G3?
-Paavo
Posts: 54
Done changes in the above post.
These still don't work (just examples, these are not the only ones):
- http://HOST_OLD/gallery/d/98574-1/20110526_006.jpg -> http://HOST_NEW/gallery3/index.php/g2/map?path=d/98574-1/20110526_006.jpg results an error page.
- http://HOST_OLD/albums/album63/IMG_0913.sized.jpg -> http://HOST_NEW/gallery3/index.php/g2/map?path=album63/IMG_0913.sized.jpg results an error page.
So now I'm good with redirecting to the new host/domain, and this is again a generic G1/G2 to G3 migrating topic.
Any help will be GREATLY appreciated, I have a lot of pics in my gallery, and I'd very much like also the old ones to display properly also with G3.
Should I somehow have also the old G2 .htaccess onboard?
-Paavo
Copy of my old G2 .htaccess
Posts: 1857
Honestly, there's just too much here for me to narrow down what's going on using the generalizations. (That's just the way I think.)
Forget about the new host for a minute.
On the old host, does the everything do what it's supposed to do (when you use only the htaccess that ships with Gallery and the htaccess that the migrations produced)?
If not, where is the original fail? At the Gallery1 to Gallery2 migration or the Gallery2 to Gallery3 migration?
Posts: 6
I have been lurking and watching for this since December, as I have the same problem G2, with G1 migrated to it, then imported to G3. From my observations, and I'm no expert, but:
1. G1, G2, and G3 appear to be totally different programs
2. G1-->G2, G2-->G3, and G1-->G3 all make Rewrite commands in the .htaccess and create and use tables in the database to link the 'old' gallery locations to the 'new' gallery location.
3. The G1-->G3 module may do this, if the G1 files are still available, but that would (?) re-import the G1 albums into G3 duplicating the pics already imported to G2 from G1 and then to G3.
4. IMHO, the 'g2_G1MigrateMap' table in G2, has to be read in conjunction with the 'g2_maps' table in G3 to create a new table (g1_maps like the G1-->G3 module?) in G3 to remap the G1 addresses to G3. Does that make any sense? Could the G1-->G3 module be modified to read the database tables to do this? Will the G1-->G2 migration module be needed (rewritten?) to make this work?
My head hurts.
Posts: 1857
@roncar: You might want to bring that to the attention of the module's developer: http://gallery.menalto.com/node/102190
I haven't actually used the module, so I'm not sure how everything gets done; I was just going to try to help @ptl rework the htaccess file.
Posts: 54
Hi,
The host is now insignificant, I have the same G1/G2 -> G3 migration problems in HOST_OLD and HOST_NEW.
G1 -> G2 migration worked OK, but G1/G2 -> G3 migration is not working properly.
This is the reason why I have been running G2 and G3 in parallel in the HOST_OLD (duplicating all pics), but I don't have enough disc space in HOST_NEW to do so, and have to be able to use G3 only.
G1/G2 to G3 migration is the problem.
I can provide non-generalised details if needed, but I think these two examples should provide a good starting point.
Just forget about the host, it does not matter.
-Paavo
Posts: 1857
How/why is the old gallery2 in two directories ("gallery" and "albums")?
If the"albums" directory only contains albums, and the directory structure is the same in both your Gallery2 and your Gallery3, just add this (instead of any other Gallery2 album rewrites) in the root of the Gallery2 host acount:
Redirect 301 /albums/ http://NEW-HOST/gallery3/index.php/
That won't help your individual photos, but I can't mess with that in the abstract.
Posts: 6
"Albums" is the directory gallery1 stored the pictures in. Using gallery2's "g1-Migration module" the "Albums" folder must remain in place with only an ".htaccess" to redirect gallery1 url's to the gallery2 folder. Then gallery2's g1-migration module can do it's magic and map the url's to the current pic location in gallery2.
When this setup is further imported to gallery3, gallery1 url's fail. There is no procedure to remap the url's of those gallery1 pics that were migrated to gallery2 and then further imported to gallery3. Some examples at my test site.(Gallery 3 not active at this time, but I saved the url's)
Gallery1 url: http://64.131.78.133/albums/album356/Picture_094.jpg
Gallery2 url: http://64.131.78.133/gallery/d/44136-2/Picture_094.jpg
gallery3 url: http://64.131.78.133/gallery3/var/resizes/wingmans/album356/Picture_094.jpg?m=1293195269
gallery 1 to gallery 2 redirected url: http://64.131.78.133/gallery/main.php?g2_view=core.DownloadItem&g2_itemId=44136
gallery 2 to gallery 3 redirected url: http://64.131.78.133/gallery3/var/albums/wingmans/album356/Picture_094.jpg?m=1293195268
gallery 1 to gallery 3 url: http://64.131.78.133/gallery3/g2/map?path=main.php&g2_view=core.DownloadItem&g2_itemId=44136 (don't work)
Posts: 27300
I'm not following closely but just an observation that "albums" is a reserved name in G3. There is a open ticket for it so you might have some issues with that.
Glad you got the rewrite expert helping with this voodoo.
Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team
Posts: 54
Hi,
If this is really true, this is a major problem for me, and also for everybody else who started with G1 and continued with G2 and are considering G3.
Can this be solved with mod_rewrite, or is something like database-remapping-table needed?
Not sure if my skills are good enough to start any implementation, but I certainly want to help getting this done.
WHAT IS NEEDED, AND HOW CAN I HELP? (sorry for yelling, but this really important for me)
I still have all G2 files/directories in good backups, and G2 database is also available. And lots of test material, just google for "stiletti.wipsl.com/albums/" or "stiletti.wipsl.com/gallery/" and you get some hundreds of hits. Which I'd very very much like to work properly with G3 (in ptl.kapsi.fi host).
-Paavo
Posts: 1857
First, I'm not sure that this is really a huge issue. If you dump the original Gallery1 urls (meaning that anyone attempting to access a Gallery1 url will 404), then it's a matter of just migrating Gallery2 to Gallery3. I know that we're all super protective of our own sites, but in reality, Gallery2's been around for a super long time. That said, it's highly unlikely that you're getting that much traffic based on the old Gallery1 urls. The exception being if you only recently migrated Gallery1 to Gallery2, in which case it'll be easiest to do a straight Gallery1 to Gallery3 migration and redirect the few new Gallery2 albums. Having said that, I'm still willing to try to help if you feel there's a legitimate need.
@roncar: Based only on what you posted in the last post, the issue is that the Gallery1 to Gallery2 URL isn't resolving before it applies the Gallery2 to Gallery3 rewrite. IF that's the issue, it can probably be solved by combining all of the rewrites into a single section (in your site root's htaccess, instead of spreading them out in all of these different directories). I can try to help with that, but I'd need the full contents of all of your htaccess files (maybe just the one in the site root and the ones in the gallery folders will do). If you want to try that, you can post them here or pm them to me--but only do it if you're providing the WHOLE file (no pieces, because one part affects the other and can change the way the rules are interpreted).
@floridave: I'd forgotten that. I'm thinking it may not be a factor here because he's not getting any errors with his G3--even with the htaccess file that he already has in the albums folder--but I've been wrong before so...
@ptl: This thread is the first time I've seen this issue (but I was away for about 2 weeks, so maybe I missed another?). Your best bet is to back up everything (including the database), install Gallery3, migrate, and see what happens. If you have a smaller Gallery, you could likely do the htaccess by hand without much trouble (that's what I did, because I wanted to completely change my directory structures, not because I had problems with migration). Even in the worst of circumstances, you should be able to restore everything if there's a major fail. As an aside, if you still have that many Gallery1 links in the search engines, it suggests that your Gallery1 to Gallery2 rewrites/redirects weren't seen as permanent; otherwise, they should eventually all have fallen out and been replaced by the new Gallery2 urls.
Posts: 6
My problem is Gallery is used heavily within the forum on the same site. I just did a search of the posts table in the forum database and there are 6961 G1 url's posted, and there are over 2500 G2 url's posted.
I've been active in the maintenance of the website for 2 and a half years, and as I understand, Gallery1 was operational on the site for five years before we upgraded to Gallery2 in Sept 2009.
I'm not a programmer, but it seems to me the line "RewriteRule (.*)$ /gallery/main.php?g2_controller=migrate.Redirect&g2_path=$1 [QSA]" is calling something in G2 to access the G2 database table "g2_G1MigrateMap" and find out what the new G2 url equivalent is. When G2 is deleted and G3 up and running, G1 url's CAN'T work due to the G2 software and database being gone. How can a redirect be done if it don't know which picture to redirect to?[img]http://www.ngwclub.com/gallery/d/139739-1/g1_g2_g3.png[/img]
Can this be done in .htaccess with with a Rewrite? Or am I correct in assuming a database table and directions to look up the data are required?
Posts: 10
I had a catastrophic server failure a while back and all I have from my G2 installation is the albums folders and files. Is there a way to take that structure and import it into G3?
Posts: 16504
Nice, completely unrelated thread jack....
http://codex.gallery2.org/Gallery3:Modules:serveradd
If that doesn't get you going, don't reply here, start a new thread please.
____________________________________________
Like Gallery? Like the support? Donate now!
Posts: 10
I thought I'd found the closest thread I could to my issue, but obviously I've violated some rule of etiquette, so I'll take it elsewhere.
[edit] Sorry, that sounded rude too. Thank you for the link. I"ll get out of the thread now.[/edit]
Posts: 16504
If you need more help, just start a new thread and we'll be glad to help you.
____________________________________________
Like Gallery? Like the support? Donate now!
Posts: 54
Hi,
tempg> I'm not sure that this is really a huge issue
To me and the users of the gallery I'm running, this is a huge issue. A lot of G1/G2 links are dead.
roncar> My problem is Gallery is used heavily within the forum on the same site
Very similar case here, except that the forums are not on the same site, and there are a couple of forums that are heavily using pictures from this gallery, and a few other forums with somewhat less traffic.
My G1MigrateMap has 27399 rows, so quite a few pictures were added when G1 was running.
G3 dashboard says it now has 30782 pictures, everything after G1 were added using G2 so far.
I have some doubts believing me and roncar are the only ones that have been using both G1 and G2 and have upgraded (or are considering to upgrade) to G3.
-Paavo
Posts: 54
OK,
case study, lets pick this link:
It has been used e.g. here http://forums.offipalsta.com/showthread.php?t=1634 (1st link to a picture, in 4st post).
Again, stiletti.wipsl.com is the old host, the address will disappear soon. This host was originally running G1, and was upgraded to G2. G3 was installed, and everything from G2 were imported. G3 was then copied to new host, ptl.kapsi.fi, which is running just G3.
OK, lets see... using stiletti.wipsl.com, which still has G2 and G3 installed.
Using "hand re-writing" (and new host) http://stiletti.wipsl.com/albums/album63/IMG_0913.sized.jpg becomes
http://ptl.kapsi.fi/gallery3/index.php/g2/map?path=d/65312-2/IMG_0913.jpg which displays the picture OK.
So G3 seems to have all the information how to display old G1 links!!!
I just don't know how this can be done using apache rewrites, IMHO database access is needed.
But since the information is available, could G3 index.php be enhanced so that every old G1/G2 link would display correctly (with the help of some rewrites)?
-Paavo
Posts: 54
Another case study;
why does http://stiletti.wipsl.com/gallery/d/98574-1/20110526_006.jpg not work? Existing re-writes (see http://gallery.menalto.com/node/103597#comment-381034 - I'm still running this set-up, no changes) turn this into http://ptl.kapsi.fi/gallery3/index.php/g2/map?path=d/98574-1/20110526_006.jpg which does not display correctly.
However:
98574-1 does not exist? 98574-2 does exist, and http://ptl.kapsi.fi/gallery3/index.php/g2/map?path=d/98574-2/20110526_006.jpg displays OK (as http://ptl.kapsi.fi/gallery3/var/resizes/range-misc/Sekalaista_2011_kevat/20110526_006.jpg?m=1306654338).
-Paavo
Posts: 1857
@roncar: I'm looking back at your post above ( http://gallery.menalto.com/node/103597#comment-381211 ). This should be too difficult to solve. The only issue is the "wingman" part; is that the same for all photos? If not, how many different directories are there?
Posts: 6
@tempg: There are 6 directories in the gallery root, wingman is one of them. As I see the database, that information is stored in the gallery3 'items' table as 'relative url' so shouldn't be an issue?
My current thought is to use g2_G1MigrateMap, run an update to populate a new field for G3 item numbers based on the g2_maps table. Rename the table and fields to match the g1_maps table of the g1 import module, (id=g3 item, album=g1 album, item=g1 item, haven't figured out what to do with resource_type) and use the g1 import module and rewrites. Don't know if both g1_import and g2_import modules will run concurrently though.
Posts: 1857
@roncar: Yeah, I'm skipping the database stuff. Keeping it simple. My thought is to just do manual htaccess rewrites/redirects for the 6 directories (Gallery1 to Gallery3) and to do a migration to cover the Gallery2 to Gallery3 rewrites/redirects.
You'll need 2 rewrites to cover the Gallery1 to Gallery3 stuff (maybe a couple more if you've done something complicated--like rename a bunch of files--that hasn't been mentioned yet).
The migration tool should get the Gallery2 to Gallery3 stuff squared away for you.
The one concern is that your Gallery3 urls have a folder that wasn't in the Gallery1 urls.
Gallery1 url: http://64.131.78.133/albums/album356/Picture_094.jpg
Gallery3 url: http://64.131.78.133/gallery3/var/resizes/wingmans/album356/Picture_094.jpg?m=1293195269
If all of the Gallery1 albums ended up in the same Gallery3 folder, that'll be easy.
Else, if there weren't many Gallery1 albums and you know where they all are now, that'll take a few more rewrites, but is totally doable.
Otherwise, if there were a lot of Gallery1 albums are now all over the place in Gallery3, that's doable but likely to be aggravating.
Let me know and I'll give you some code to try.
Posts: 1857
I'm not totally sure, but I wouldn't think that index.php is the real issue.
The rewrite rules in the htaccess that you posted ( http://gallery.menalto.com/node/103597#comment-381035 ) would have to be changed, or the queries/controllers that they use would have to be redone/rewritten.
@ptl: It's still a bit difficult for me to sort this out.
The database case studies don't really help me at this point (although they could help someone else, maybe).
I only see 2 methods of solving this: 1. Redoing the way the database is used to spit out the urls. 2. htaccess only
For me, the second method is easier (but the 1st is likely to help more people in the future).
If you're interested in the htaccess method, I'll try to help, but I need to see the full htaccess--all of it. In this case, that means whatever's in the root directory, the G1 directory, the G2 directory, and the new G3 directory. All of them work together to get your user from a Gallery1 url to a Gallery3 url and if you leave anything out, it's at least as likely as not that we'd be wasting time running in circles.
EDIT: SCRATCH ALL OF THAT. I can't get to your old url (because you have it redirecting), but the new one only has 8 albums in the root folder. Assuming that you didn't move a lot of albums around and that you kept the same album slugs, it would be a WHOLE lot simpler to just handcode the Gallery1 to Gallery3 redirects--similar to what i told @roncar above. Can you open up the site so that I can see the original Gallery1 structure?
Posts: 6
@tempg: From what I remember, when using gallery1 (I don't have an operational copy running) moving around inside the gallery there were folders, sub-folders, sub-sub-folders, etc. However when physically stored on the drive, ALL the folders are in the root folder 'albums.' To figure which are which would be a monumental task.
ie gallery1 /albums/album277/70fl78.jpg
in gallery 3 becomes /gallery3/var/resizes/wingmans/roncarGL/misc-pics/album277/70fl78.jpg
Looking at my backup of gallery1, there are 877 folders and 46,189 files in the albums folder.
Posts: 27300
If I remember right there was no nesting of albums in the file system on G1, the UI yes, but not the file system. All albums had to have different names.
In G2 and G3 we fixed that issue so that you could have albums with the same name but albums on the same level can't have the same name.
Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team
Posts: 54
@tempg:
This means what? ssh access? just let me know, stiletti is all mine, and I can arrange anything you need.
I don't have G1 any more, all of it was thrown away when G2 was taken into use.
@floridave:
Me thinks the same.
-Paavo
Posts: 1857
Based on that (and @roncar's comment), there were subalbums in Gallery1, but that wasn't reflected in the file structure? So I go to a subalbum and Gallery1, somewhere on the backend, figured out where the file really was (in the root) via some htaccess rewrite or database lookup? If that's right, a htaccess solution for this thread is still possible; the actual location of the album doesn't really matter for that, just need the url that the user is inputting. In other words, if the album url is http://gallery.com/album/subalbum5, that could still be used for an htaccess solution--even if the actual file is located at /public_html/subalbum5. (Hope that makes sense.)
Well, isn't this getting interesting. We're quickly leaving my zone of programming comfort. (There's no htaccess solution without either manual redirections--the monumental task--or some logic that can figure out where each album was moved to.) Plus, I have zero experience with Gallery1, and I didn't do a Gallery2 to Gallery3 migration using the module.
Having said that, I'm thinking the need is to combine the two databases (the ones from each migration). You can likely do it with a query and foreach loop, but I'm not sure how that works with calling an album (instead of items within an album). I'm short on time now, but the controller already being used may help. Totally not sure. Maybe skip the original url lookup altogether; have the G1 URL look for the G2 id of the item (from the G1-G2 table) and use that to access the new G3 url (using the G2-G3 table).
I'll wait a few days to see if anyone else has ideas (and know how) to get this done. If not, I may take a stab at it when time frees a bit, but that could be a few weeks.
Nevermind that for now. I thought I'd read that you were still running Gallery1 parallel to Gallery2. We can look at that later.
Posts: 54
Hi,
any progesss on this?
Another example what's broken:
This http://www.offroadoulu.com/smf_forum/index.php?topic=53.msg14005#msg14005 post has two links
http://stiletti.wipsl.com/gallery/d/99687-1/20110805_012.jpg (1st link)
http://ptl.kapsi.fi/gallery3/index.php/g2/map?path=d/99687-1/20110805_012.jpg (redirected to G3 in new host, broken)
http://ptl.kapsi.fi/gallery3/index.php/g2/map?path=d/99687-2/20110805_012.jpg (replace -1 with -2 and it works fine)
http://ptl.kapsi.fi/gallery3/var/resizes/range-misc/summer_2011/20110805_012.jpg?m=1312826526 (picture shows OK)
http://stiletti.wipsl.com/gallery/d/99690-1/20110805_013.jpg (2nd link)
http://ptl.kapsi.fi/gallery3/index.php/g2/map?path=d/99690-1/20110805_013.jpg (redirected to G3 in new host, broken)
http://ptl.kapsi.fi/gallery3/index.php/g2/map?path=d/99690-2/20110805_013.jpg (replace -1 with -2 and it works fine)
http://ptl.kapsi.fi/gallery3/var/resizes/range-misc/summer_2011/20110805_013.jpg?m=1312826527 (picture shows OK)
Here host in insignificant, functionality would be thw same in one host only.
Posts: 1857
Is that true for the all photos?
Posts: 54
G2 must have had a logic for this, but based on my data it looks like a "yes".
-Paavo
Posts: 54
A bit more info; e.g. this http://ptl.kapsi.fi/gallery3/index.php/range-misc/Syksy_2011 album has 4 pictures in it, and g3tab_g2_maps table looks like this:
So -1 for original (full size) picture, -2 for resized picture and thumbnail.
But, -2 is not the universal truth. I could easuly spot -5's:
These two (resized) pictures are here:
http://ptl.kapsi.fi/gallery3/index.php/range-misc/summer_2011/20110806_005
http://ptl.kapsi.fi/gallery3/index.php/range-misc/summer_2011/20110806_006
So it looks like -2 for nonrotated/landscape resizes, and -5 for rotated/portrait resizes.
or something like that, there must be a logic in G2.
BUT, THERE IS ONLY ONE OF EACH ITEM, so choosing "-?" should be safe.
-Paavo
Posts: 1857
@ptl: I don't fully get some of what you're saying, but try using this in Gallery's htaccess (make sure you put it in the right place):
<IfModule mod_rewrite.c> Options +FollowSymLinks RewriteEngine On RewriteBase /gallery3/ RewriteRule (.*)=d/([0-9]+)-1/(.*).jpg$ $1=d/$2-2/$3.jpg [L,R=301] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d ...
Some server configs require the full path in the rewrite, so you may have to change the line to
RewriteRule (.*)=d/([0-9]+)-1/(.*).jpg$ http://ptl.kapsi.fi/gallery3/$1=d/$2-2/$3.jpg [L,R=301]
One each of what?
Posts: 54
Hi,
and sorry for slow reply, there seems to be too many things to do.
Unfortunatelly this straight-forward re-write does not work, some resizes are -2 and some others are -5. Maybe there are some others than -2 and -5, did not check.
There is only one resize for each picture, and it's url has -N where N can be (at least) 2 or 5.
One of my earlier posts had a practical example:
Original url: gallery/d/98574-1/20110526_006.jpg
Gets re-written to: gallery3/index.php/g2/map?path=d/98574-1/20110526_006.jpg which does not display.
If that is "hand-rewritten" to: gallery3/index.php/g2/map?path=d/98574-2/20110526_006.jpg it displays OK.
I do not know why 98574-1 was changed to 98574-2 in G2 -> G3 update, but everything worked fine in G2.
-Paavo
Posts: 54
Just to make it a tangible fix proposal, could index.php/g2/map be modified like this:
for ( $i = 0; $i < 10; $i++ ) // is 0-9 exactly the right range? 1-9? 1-something? 0-something? { $fixed_url=check_url("gallery3/index.php/g2/map?path=d/98574-".$i."/20110526_006.jpg") and break; }
check_url(STRING) returns true if STRING is OK, false if it's not.
Of course, "gallery3/index.php/g2/map?path=d/98574-" and "/20110526_006.jpg" would need to be exploded to variables or something, but I hope this gives and idea. Maybe the first part should be "d/98574-" only, because then it's very easy to check what is the value for g2_url for that particular g2_id from g3tab_g2_maps table.
Hmm...
Maybe it's better that I stop "coding" and let somebody who knows G3 (and PHP!) implement this.
-Paavo
Posts: 1857
Did you try this? If so, did it work for at least some of the files?
I didn't bother trying to find a broader "fix" because I don't even know if that part does any good. If it works for some of the files, you'd just add a few more lines to get the others working, something like:
<IfModule mod_rewrite.c> Options +FollowSymLinks RewriteEngine On RewriteBase /gallery3/ RewriteRule (.*)=d/([0-9]+)-1/(.*).jpg$ $1=d/$2-2/$3.jpg [L,R=301] RewriteCond %{REQUEST_URI} (.*)=d/([0-9]+)-2/(.*).jpg$ RewriteCond $0 !-f RewriteRule (.*)=d/([0-9]+)-2/(.*).jpg$ $1=d/$2-5/$3.jpg [L,R=301] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d ...
I'm not looking at getting the database to do anything different than it's already doing. That (to me) is more complicated than just working around it. (And I don't think I've seen anyone else with the problem you're having.)
Posts: 54
OK,
I'll try that. Just feels a bit silly to write a lot of stuff to .htaccess instead of one simple database query, but if I'm alone with this problem then .htaccess is easier for me that hack&branch core G3 php code (also because kohana is as clear a black magic to me).
Will this work? Wrong resize-url will non return 404, but the G3 oops-page, so will apache know -2 did not display properly?
I was not able to use RewriteLog and RewriteLogLevel in the "production" server, so I need to set up a test system. Firsts tests with the real G3 server failed, since
did not rewrite http://ptl.kapsi.fi/gallery3/index.php/g2/map?path=d/98574-1/20110526_006.jpg. I also tried
And several other variants, but nothing (except RewriteRule ^ http://example.com/) worked... Debugging rewrite-rules is not one of my stongerst areas.
-Paavo
Posts: 1857
Dude, I'm totally confused now. I have no idea what you've tried and what you haven't tried.
Your last comment starts with "I'll try that," then asks "Will this work," then that you need to "set up a test system" in order to test, and then says something didn't work. I'm not sure that I'm following at all; I'm not sure what parts you tried, what you're about to try, and what you're just thinking about. (Please don't explain.)
If you haven't already, try exactly what I typed above. If it doesn't work, I'll need to know (1) What URL you tried, (2) What URL it SHOULD HAVE redirected to, and (3) What URL it actually ended up at. Don't throw in any additional information (especially not hypotheticals about what could/may happen if you try something); my mind can't handle it. Nothing personal, just not the way I work; it may be useful for someone else who's able to assist.
EDIT: When/if you test it, try a "-2" url and a "-5" url.
Posts: 54
Hi,
I could not get RewriteRule (.*)=d/([0-9]+)-1/(.*).jpg$ $1=d/$2-2/$3.jpg [L,R=301] to match http://ptl.kapsi.fi/gallery3/index.php/g2/map?path=d/98574-1/20110526_006.jpg. Frustrated, also because I felt stupid, rewrite rules debugging is not my game. Also because rewrite rules are the "wrong" medicine (IMHO).
Took another path, and studied G3 php a bit. Found modules/g2_import/controllers/g2.php.
After
I have something like this
And then we need something like this:
and then need to replace this
with something like this:
I.e. add 3rd element to the list ($tmp4).
And yes, this is very quick and dirty, the variable names and all that is horrible, please ignore the code quality, this just demos the principle.
Need a bit help (had not time to find all answers bu myself, and now I need to go for the weekend) with the database query, and conformation that "where g2_url IN <LIST>" LIST can have more than two candidates.
-Paavo
Posts: 1857
Okay @ptl, I'm giving up on this. You're still not giving me the information I'm asking for to get a quick htaccess solution. Good look with the database/controller/etc method.
Posts: 54
Hi,
just came back to modern world. I'm still going the php path, just did not have time to implement it yet.
But since this thread has so heavily been about rewrites, here are the answers if somebody else could benefit from rewrite approach.
Lets make this real simple, and use just one URL.
(1) http://ptl.kapsi.fi/gallery/d/98574-1/20110526_006.jpg
(2) http://ptl.kapsi.fi/gallery3/index.php/g2/map?path=d/98574-2/20110526_006.jpg
(3) http://ptl.kapsi.fi/gallery3/index.php/g2/map?path=d/98574-1/20110526_006.jpg
gallery/.htaccess is standard:
gallery3/.htaccess is modified:
My service provider does not allow FollowSymLinks, but FollowSymLinksIfOwnerMatch is on by default. Every single file and directory in the www directory (where gallery and gallery3 live) is owned by my userid.
Directory gallery is totally empty except the .htaccess file.
I also tried http://martinmelin.se/rewrite-rule-tester/ but could not get the rewrite rule to match. I used URL "gallery3/index.php/g2/map?path=d/98574-1/20110526_006.jpg" and rewrite rule "RewriteRule (.*)=d/([0-9]+)-1/(.*).jpg$ $1=d/$2-2/$3.jpg [L,R=301]".
Are there other/better rewrite-rule testing sites?
-Paavo
Posts: 54
Works for me for gallery/d/98574-1/20110526_006.jpg type things.
Now I need to fix albums/album63/IMG_0913.sized.jpg and albums/album65/DSC00304.jpg type stuff.
-Paavo
Posts: 54
Initial testing indicates this might work, now need to start looking for more test cases.
This is still 100% trial-and-error method based, I don't have a glue how G3/kohana internals work (e.g. $path/$input->get("g2_path") for $tmp6), so I might have broken something.
One needs to export g2tab_G1MigrateMap table from G2 database, I imported it to the same database with the rest of G3 tables, and renamed it to 'g3tab_g1_maps' as can be seen from the code (G3/kohana auto-inserts the table prefix, g3tab_ in my case).
But even if this is pre-beta, I thought I'll post this, if everybody in the G3 developer community is not upset by this super-long thread, somebody might find some problems in this code, or even make some use of it.
I still think G3 support for G1 and G2 could be better, hopefully this is a small bit to improve it.
-Paavo
PS. I copied /gallery/.htaccess to /albums/.htaccess, just changed the RewriteBase, I was not sure if rewrites after rewrites work or are efficient. Original /albums/.htaccess rule was "RewriteRule (.*)$ /gallery/main.php?g2_controller=migrate.Redirect&g2_path=$1 [QSA]". Also /albums is completely empty, except the .htaccess file.
Posts: 54
http://stiletti.wipsl.com/gallery/album05 does not work, but looks like raw data is there, just need to use it.
Long thread getting longer, hopefully this is not against forum rules or something.
Posts: 54
Done. Think this case might be impossible with rewrite, at least with my rewrite "skills".
I still don't like how the code looks like, but it works with all the test cases I've found so far.
-Paavo