G3: Migrating from G2 and G1

ptl

Joined: 2003-06-19
Posts: 54
Posted: Mon, 2011-09-12 10:40

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

 
tempg

Joined: 2005-12-17
Posts: 1857
Posted: Mon, 2011-09-12 15:44

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.)

 
ptl

Joined: 2003-06-19
Posts: 54
Posted: Wed, 2011-09-14 07:28

1) - 5) done, here is my G2 .htaccess:

Quote:
# PTL 09.10.2010
# Gallery3 install
#
# Migrating from Gallery 2
# Once your migration is complete, put this block at the top of your gallery2/.htaccess file
# and all Gallery 2 urls will be redirected to Gallery 3.
#
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteBase /gallery/ RewriteRule ^(.*)$ /gallery3/index.php/g2/map?path=$1 [QSA,L,R=301]
</IfModule>
#
# End of G3 redirect

# BEGIN Url Rewrite section
# (Automatically generated. Do not edit this section)
<IfModule mod_rewrite.c>
RewriteEngine On

RewriteBase /gallery/

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} gallery\_remote2\.php
RewriteCond %{REQUEST_URI} !/gallery/main\.php$
RewriteRule . - [L]

RewriteCond %{THE_REQUEST} /gallery/d/([0-9]+)\-([0-9]+)/([^/?]+)(\?.|\ .)
RewriteCond %{REQUEST_URI} !/gallery/main\.php$
RewriteRule . /gallery/main.php?g2_view=core.DownloadItem&g2_itemId=%1&g2_serialNumber=%2&g2_fileName=%3 [QSA,L]
RewriteCond %{THE_REQUEST} /gallery/v/([^?]+)(\?.|\ .)
RewriteCond %{REQUEST_URI} !/gallery/main\.php$
RewriteRule . /gallery/main.php?g2_path=%1 [QSA,L]
RewriteCond %{THE_REQUEST} /gallery/([^?]+)(\?.|\ .)
RewriteCond %{REQUEST_URI} !/gallery/main\.php$
RewriteRule . /gallery/main.php?g2_controller=migrate.Redirect&g2_path=%1 [QSA,L]
</IfModule>

# END Url Rewrite section

and I get a lot of this:

Quote:
[Wed Sep 14 10:24:36 2011] [alert] [client aaa.bbb.ccc.ddd] /path/gallery/.htaccess: RewriteBase takes one argument, the base URL of the per-directory context, referer: http://www.offroadoulu.com/smf_forum/index.php?topic=2661.0

Should I remove (comment out) the original G2 part of the .htaccess?

-Paavo

 
ptl

Joined: 2003-06-19
Posts: 54
Posted: Wed, 2011-09-14 10:45

Uh, silly me

Quote:
RewriteBase /gallery/ RewriteRule ^(.*)$ /gallery3/index.php/g2/map?path=$1 [QSA,L,R=301]

must be in separate lines

Quote:
RewriteBase /gallery/
RewriteRule ^(.*)$ /gallery3/index.php/g2/map?path=$1 [QSA,L,R=301]

Looks like it works!

-Paavo

 
ptl

Joined: 2003-06-19
Posts: 54
Posted: Wed, 2011-09-14 11:57

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:

Quote:
RedirectTemp /gallery3 http://HOST_NEW/gallery3
RedirectTemp /gallery/ http://HOST_NEW/gallery3/index.php/g2/map?path=
RedirectTemp /albums/ http://HOST_NEW/gallery3/index.php/g2/map?path=

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

 
ptl

Joined: 2003-06-19
Posts: 54
Posted: Wed, 2011-09-14 13:13

Hi,

this works, ie. G3 in HOST_NEW displays it:

Quote:
http://HOST_OLD/gallery/d/95201-2/PC045127.JPG

but these do not work, G3 in HOST_NEW displays error page:

Quote:
http://HOST_OLD/gallery/d/98574-1/20110526_006.jpg
http://HOST_OLD/albums/album63/IMG_0913.sized.jpg

All links worked from HOST_OLD, and no pictures have been deleted.

-Paavo

 
tempg

Joined: 2005-12-17
Posts: 1857
Posted: Wed, 2011-09-14 18:28

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

 
ptl

Joined: 2003-06-19
Posts: 54
Posted: Thu, 2011-09-15 07:09

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):

Quote:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !gallery_remote2.php
RewriteRule (.*)$ /gallery/main.php?g2_controller=migrate.Redirect&g2_path=$1 [QSA]
</IfModule>

This for gallery/.htaccess (as listed by G2 -> G3 migration instructions):

Quote:
<IfModule mod_rewrite.c>
# Options +FollowSymLinks # this is not allowed in HOST_NEW
RewriteEngine On
RewriteBase /gallery/
RewriteRule ^(.*)$ /gallery3/index.php/g2/map?path=$1 [QSA,L,R=301]
</IfModule>

Then I can just have these in HOST_OLD:

Quote:
RedirectTemp /gallery3 http://HOST_NEW/gallery3
RedirectTemp /gallery http://HOST_NEW/gallery
RedirectTemp /albums http://HOST_NEW/albums

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

 
ptl

Joined: 2003-06-19
Posts: 54
Posted: Thu, 2011-09-15 11:11

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

Quote:
# BEGIN Url Rewrite section
# (Automatically generated. Do not edit this section)
<IfModule mod_rewrite.c>
RewriteEngine On

RewriteBase /gallery/

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} gallery\_remote2\.php
RewriteCond %{REQUEST_URI} !/gallery/main\.php$
RewriteRule . - [L]

RewriteCond %{THE_REQUEST} /gallery/d/([0-9]+)\-([0-9]+)/([^/?]+)(\?.|\ .)
RewriteCond %{REQUEST_URI} !/gallery/main\.php$
RewriteRule . /gallery/main.php?g2_view=core.DownloadItem&g2_itemId=%1&g2_serialNumber=%2&g2_fileName=%3 [QSA,L]
RewriteCond %{THE_REQUEST} /gallery/v/([^?]+)(\?.|\ .)
RewriteCond %{REQUEST_URI} !/gallery/main\.php$
RewriteRule . /gallery/main.php?g2_path=%1 [QSA,L]
RewriteCond %{THE_REQUEST} /gallery/([^?]+)(\?.|\ .)
RewriteCond %{REQUEST_URI} !/gallery/main\.php$
RewriteRule . /gallery/main.php?g2_controller=migrate.Redirect&g2_path=%1 [QSA,L]
</IfModule>

# END Url Rewrite section

 
tempg

Joined: 2005-12-17
Posts: 1857
Posted: Fri, 2011-09-16 23:05

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?

 
roncar

Joined: 2011-09-16
Posts: 6
Posted: Sat, 2011-09-17 00:07

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.

 
tempg

Joined: 2005-12-17
Posts: 1857
Posted: Sat, 2011-09-17 15:27

@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.

 
ptl

Joined: 2003-06-19
Posts: 54
Posted: Mon, 2011-09-19 06:36

Hi,

The host is now insignificant, I have the same G1/G2 -> G3 migration problems in HOST_OLD and HOST_NEW.

Quote:
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)?

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.

Quote:
If not, where is the original fail? At the Gallery1 to Gallery2 migration or the Gallery2 to Gallery3 migration?

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.

Quote:
- 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.

Just forget about the host, it does not matter.

-Paavo

 
tempg

Joined: 2005-12-17
Posts: 1857
Posted: Mon, 2011-09-19 19:56

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.

 
roncar

Joined: 2011-09-16
Posts: 6
Posted: Mon, 2011-09-19 22:38

"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)

albums htaccess wrote:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !gallery_remote2.php
RewriteRule (.*)$ /gallery/main.php?g2_controller=migrate.Redirect&g2_path=$1 [QSA]
</IfModule>

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Tue, 2011-09-20 00:52

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

 
ptl

Joined: 2003-06-19
Posts: 54
Posted: Tue, 2011-09-20 07:48

Hi,

Quote:
There is no procedure to remap the url's of those gallery1 pics that were migrated to gallery2 and then further imported to gallery3.

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

 
tempg

Joined: 2005-12-17
Posts: 1857
Posted: Wed, 2011-09-21 15:29

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.

 
roncar

Joined: 2011-09-16
Posts: 6
Posted: Wed, 2011-09-21 20:47

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?

 
dziring

Joined: 2004-02-01
Posts: 10
Posted: Sat, 2011-09-24 14:50

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?

 
nivekiam
nivekiam's picture

Joined: 2002-12-10
Posts: 16504
Posted: Sat, 2011-09-24 14:56
dziring wrote:
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?

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!

 
dziring

Joined: 2004-02-01
Posts: 10
Posted: Sat, 2011-09-24 15:02
nivekiam wrote:
dziring wrote:
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?

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!

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]

 
nivekiam
nivekiam's picture

Joined: 2002-12-10
Posts: 16504
Posted: Sat, 2011-09-24 15:23

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!

 
ptl

Joined: 2003-06-19
Posts: 54
Posted: Tue, 2011-09-27 10:42

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

 
ptl

Joined: 2003-06-19
Posts: 54
Posted: Tue, 2011-09-27 10:45

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.

Quote:
mysql> use Gallery2;
Database changed
mysql> describe g2tab_G1MigrateMap;
+---------------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------------+--------------+------+-----+---------+-------+
| g2col_itemId | int(11) | NO | PRI | NULL | |
| g2col_g1album | varchar(128) | NO | MUL | NULL | |
| g2col_g1item | varchar(128) | YES | | NULL | |
+---------------+--------------+------+-----+---------+-------+
3 rows in set (0.05 sec)

mysql> select * from g2tab_G1MigrateMap where g2col_g1album = "album63" and g2col_g1item = "IMG_0913";
+--------------+---------------+--------------+
| g2col_itemId | g2col_g1album | g2col_g1item |
+--------------+---------------+--------------+
| 65312 | album63 | IMG_0913 |
+--------------+---------------+--------------+
1 row in set (0.08 sec)

Quote:
mysql> use Gallery3;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> describe g3tab_g2_maps;
+---------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+---------------+--------------+------+-----+---------+----------------+
| id | int(9) | NO | PRI | NULL | auto_increment |
| g2_id | int(9) | NO | MUL | NULL | |
| g3_id | int(9) | NO | | NULL | |
| g2_url | varchar(255) | YES | MUL | NULL | |
| resource_type | varchar(64) | YES | | NULL | |
+---------------+--------------+------+-----+---------+----------------+
5 rows in set (0.00 sec)

mysql> select * from g3tab_g2_maps where g2_id = "65312";
+-------+-------+-------+-------------------------------------------------+---------------+
| id | g2_id | g3_id | g2_url | resource_type |
+-------+-------+-------+-------------------------------------------------+---------------+
| 82392 | 65312 | 21371 | v/oro/safarit/album60/album63/IMG_0913.jpg.html | item |
| 82393 | 65312 | 21371 | d/65312-2/IMG_0913.jpg | file |
+-------+-------+-------+-------------------------------------------------+---------------+
2 rows in set (0.10 sec)

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

 
ptl

Joined: 2003-06-19
Posts: 54
Posted: Tue, 2011-09-27 10:34

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:

Quote:
mysql> use Gallery3;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> describe g3tab_g2_maps;
+---------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+---------------+--------------+------+-----+---------+----------------+
| id | int(9) | NO | PRI | NULL | auto_increment |
| g2_id | int(9) | NO | MUL | NULL | |
| g3_id | int(9) | NO | | NULL | |
| g2_url | varchar(255) | YES | MUL | NULL | |
| resource_type | varchar(64) | YES | | NULL | |
+---------------+--------------+------+-----+---------+----------------+
5 rows in set (0.01 sec)

mysql> select * from g3tab_g2_maps where g2_id = "98574";
+--------+-------+-------+----------------------------+---------------+
| id | g2_id | g3_id | g2_url | resource_type |
+--------+-------+-------+----------------------------+---------------+
| 120822 | 98574 | 31101 | d/98574-2/20110526_006.jpg | resize |
+--------+-------+-------+----------------------------+---------------+
1 row in set (0.10 sec)

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

 
tempg

Joined: 2005-12-17
Posts: 1857
Posted: Fri, 2011-09-30 23:57

@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?

 
roncar

Joined: 2011-09-16
Posts: 6
Posted: Sat, 2011-10-01 12:52

@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.

 
tempg

Joined: 2005-12-17
Posts: 1857
Posted: Sat, 2011-10-01 16:22

@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.

 
tempg

Joined: 2005-12-17
Posts: 1857
Posted: Sat, 2011-10-01 17:08
ptl wrote:
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)?

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?

 
roncar

Joined: 2011-09-16
Posts: 6
Posted: Sat, 2011-10-01 18:44

@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.

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 27300
Posted: Sun, 2011-10-02 02:25

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

 
ptl

Joined: 2003-06-19
Posts: 54
Posted: Sun, 2011-10-02 08:14

@tempg:

Quote:
Can you open up the site so that I can see the original Gallery1 structure?

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:

Quote:
there was no nesting of albums in the file system on G1, the UI yes, but not the file system

Me thinks the same.

-Paavo

 
tempg

Joined: 2005-12-17
Posts: 1857
Posted: Sun, 2011-10-02 14:33
floridave wrote:
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.

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.)

roncar wrote:
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.

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.

ptl wrote:
This means what? ssh access? just let me know, stiletti is all mine, and I can arrange anything you need.

Nevermind that for now. I thought I'd read that you were still running Gallery1 parallel to Gallery2. We can look at that later.

 
ptl

Joined: 2003-06-19
Posts: 54
Posted: Thu, 2011-10-20 10:07
 
tempg

Joined: 2005-12-17
Posts: 1857
Posted: Fri, 2011-10-21 18:44
ptl wrote:
(replace -1 with -2 and it works fine)

Is that true for the all photos?

 
ptl

Joined: 2003-06-19
Posts: 54
Posted: Mon, 2011-10-24 05:58
tempg wrote:
ptl wrote:
(replace -1 with -2 and it works fine)

Is that true for the all photos?

G2 must have had a logic for this, but based on my data it looks like a "yes".

-Paavo

 
ptl

Joined: 2003-06-19
Posts: 54
Posted: Mon, 2011-10-24 06:18

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:

Quote:
mysql> describe g3tab_g2_maps;
+---------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+---------------+--------------+------+-----+---------+----------------+
| id | int(9) | NO | PRI | NULL | auto_increment |
| g2_id | int(9) | NO | MUL | NULL | |
| g3_id | int(9) | NO | | NULL | |
| g2_url | varchar(255) | YES | MUL | NULL | |
| resource_type | varchar(64) | YES | | NULL | |
+---------------+--------------+------+-----+---------+----------------+
5 rows in set (0.00 sec)

Quote:
mysql> select * from g3tab_g2_maps;
<...>
| 122118 | 99768 | 31431 | v/range-misc/Syksy_2011/ | album |
| 122119 | 99769 | 31432 | v/range-misc/Syksy_2011/20110831_002.jpg.html | item |
| 122120 | 99769 | 31432 | d/99769-1/20110831_002.jpg | file |
| 122121 | 99770 | 31432 | d/99770-2/20110831_002.jpg | thumbnail |
| 122122 | 99771 | 31432 | d/99771-2/20110831_002.jpg | resize |
| 122123 | 99773 | 31433 | v/range-misc/Syksy_2011/20110909_001.jpg.html | item |
| 122124 | 99773 | 31433 | d/99773-1/20110909_001.jpg | file |
| 122125 | 99774 | 31433 | d/99774-2/20110909_001.jpg | thumbnail |
| 122126 | 99775 | 31433 | d/99775-2/20110909_001.jpg | resize |
| 122127 | 99776 | 31434 | v/range-misc/Syksy_2011/20110909_002.jpg.html | item |
| 122128 | 99776 | 31434 | d/99776-1/20110909_002.jpg | file |
| 122129 | 99777 | 31434 | d/99777-2/20110909_002.jpg | thumbnail |
| 122130 | 99778 | 31434 | d/99778-2/20110909_002.jpg | resize |
| 122131 | 99779 | 31435 | v/range-misc/Syksy_2011/20110909_003.jpg.html | item |
| 122132 | 99779 | 31435 | d/99779-1/20110909_003.jpg | file |
| 122133 | 99780 | 31435 | d/99780-2/20110909_003.jpg | thumbnail |
| 122134 | 99781 | 31435 | d/99781-2/20110909_003.jpg | resize |
+--------+-------+-------+-----------------------------------------------+---------------+
122134 rows in set (0.11 sec)

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:

Quote:
| 122092 | 99703 | 31425 | v/range-misc/summer_2011/20110806_005.jpg.html | item |
| 122093 | 99703 | 31425 | d/99703-1/20110806_005.jpg | file |
| 122094 | 99704 | 31425 | d/99704-5/20110806_005.jpg | thumbnail |
| 122095 | 99705 | 31425 | d/99705-5/20110806_005.jpg | resize |
| 122096 | 99725 | 31425 | d/99725-2/20110806_005.jpg | full |
| 122097 | 99706 | 31426 | v/range-misc/summer_2011/20110806_006.jpg.html | item |
| 122098 | 99706 | 31426 | d/99706-1/20110806_006.jpg | file |
| 122099 | 99707 | 31426 | d/99707-5/20110806_006.jpg | thumbnail |
| 122100 | 99708 | 31426 | d/99708-5/20110806_006.jpg | resize |
| 122101 | 99726 | 31426 | d/99726-2/20110806_006.jpg | full |

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

 
tempg

Joined: 2005-12-17
Posts: 1857
Posted: Mon, 2011-10-24 16:46

@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]

ptl wrote:
BUT, THERE IS ONLY ONE OF EACH ITEM, so choosing "-?" should be safe.

One each of what?

 
ptl

Joined: 2003-06-19
Posts: 54
Posted: Mon, 2011-11-21 09:55

Hi,

and sorry for slow reply, there seems to be too many things to do.

tempg wrote:
@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]

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.

Quote:
ptl wrote:
BUT, THERE IS ONLY ONE OF EACH ITEM, so choosing "-?" should be safe.

One each of what?

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:

Quote:
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:

Quote:
mysql> use Gallery3;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> describe g3tab_g2_maps;
+---------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+---------------+--------------+------+-----+---------+----------------+
| id | int(9) | NO | PRI | NULL | auto_increment |
| g2_id | int(9) | NO | MUL | NULL | |
| g3_id | int(9) | NO | | NULL | |
| g2_url | varchar(255) | YES | MUL | NULL | |
| resource_type | varchar(64) | YES | | NULL | |
+---------------+--------------+------+-----+---------+----------------+
5 rows in set (0.01 sec)

mysql> select * from g3tab_g2_maps where g2_id = "98574";
+--------+-------+-------+----------------------------+---------------+
| id | g2_id | g3_id | g2_url | resource_type |
+--------+-------+-------+----------------------------+---------------+
| 120822 | 98574 | 31101 | d/98574-2/20110526_006.jpg | resize |
+--------+-------+-------+----------------------------+---------------+
1 row in set (0.10 sec)

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

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

 
ptl

Joined: 2003-06-19
Posts: 54
Posted: Mon, 2011-11-21 10:23

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...


$fixed_url="gallery3/index.php/g2/map?path=".get_g2_url_from_g3tab_g2_maps_table($g2_id);


Maybe it's better that I stop "coding" and let somebody who knows G3 (and PHP!) implement this.

-Paavo

 
tempg

Joined: 2005-12-17
Posts: 1857
Posted: Mon, 2011-11-21 22:53
ptl wrote:
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.

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.)

 
ptl

Joined: 2003-06-19
Posts: 54
Posted: Tue, 2011-11-22 19:15

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).

RewriteCond $0 !-f

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

RewriteRule (.*)=d/([0-9]+)-1/(.*).jpg$ $1=d/$2-2/$3.jpg [L,R=301]

did not rewrite http://ptl.kapsi.fi/gallery3/index.php/g2/map?path=d/98574-1/20110526_006.jpg. I also tried

  RewriteRule ^(.*)=d/([0-9]+)-1/(.*)\.jpg$ $1=d/$2-2/$3.jpg [L,R=301]

  RewriteCond %{QUERY_STRING} ^(.*)=d/([0-9]+)-1/(.*)\.jpg$
  RewriteRule $1=d/$2-2/$3.jpg

  RewriteCond %{REQUEST_URI} ^(.*)=d/([0-9]+)-1/(.*).jpg$
  RewriteRule $1=d/$2-2/$3.jpg [L,R=301]

  RewriteRule (.*)=d/([0-9]+)-1/(.*).jpg$ $1=d/$2-2/$3.jpg

  RewriteRule (.*)-1/(.*) $1-2/$2

And several other variants, but nothing (except RewriteRule ^ http://example.com/) worked... Debugging rewrite-rules is not one of my stongerst areas.

-Paavo

 
tempg

Joined: 2005-12-17
Posts: 1857
Posted: Tue, 2011-11-22 20:03

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.

 
ptl

Joined: 2003-06-19
Posts: 54
Posted: Fri, 2011-11-25 16:02

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

} else if ($path) {

I have something like this

$tmp1=explode("/", $path);
// should check 1st that this request is in the form of
// path=d/98574-1/20110526_006.jpg
// $tmp1[0] must be "d"
$tmp2=explode("-", $tmp1[1]);
$tmp_id=$tmp2[0];

And then we need something like this:

$tmp3=$database->query("select g2_url from g3tab_g2_maps where g2_id=".$tmp_id);
$tmp4=$database->last_query();

and then need to replace this

$where = array(array("g2_url", "IN", array($path, str_replace(" ", "+", $path))));

with something like this:


$where = array(array("g2_url", "IN", array($path, str_replace(" ", "+", $path), $tmp4)));


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

 
tempg

Joined: 2005-12-17
Posts: 1857
Posted: Sat, 2011-11-26 14:23

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.

 
ptl

Joined: 2003-06-19
Posts: 54
Posted: Mon, 2011-11-28 11:24

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.

tempg wrote:
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.

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:

gallery $ cat .htaccess
<IfModule mod_rewrite.c>
  # Options +FollowSymLinks
  RewriteEngine On
  RewriteBase /gallery/
  RewriteRule ^(.*)$ /gallery3/index.php/g2/map?path=$1 [QSA,L,R=301]
</IfModule>

gallery3/.htaccess is modified:

gallery3 $ diff .htaccess .htaccess.orig
18,26d17
< # see http://gallery.menalto.com/node/103597
< #
< <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]
< </IfModule>
<

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

 
ptl

Joined: 2003-06-19
Posts: 54
Posted: Mon, 2011-11-28 14:59

Works for me for gallery/d/98574-1/20110526_006.jpg type things.

$ diff g2.php g2.php.orig
51,62d50
<         $tmp1=explode("/", $path);
<         if($tmp1[0] == "d")
<         {
<           $tmp2=explode("-", $tmp1[1]);
<           if(ctype_digit($tmp2[0]))
<           {
<             $tmp3=DB::select()->from('g2_maps')->where('g2_id', '=', $tmp2[0]);
<             $tmp4=$tmp3->execute(); $tmp5=$tmp4->as_array();
<             if((count($tmp5) == 1) && (isset($tmp5[0]['g2_url'])))
<               $where[0][2][]=$tmp5[0]['g2_url'];
<           }
<         }

Now I need to fix albums/album63/IMG_0913.sized.jpg and albums/album65/DSC00304.jpg type stuff.

-Paavo

 
ptl

Joined: 2003-06-19
Posts: 54
Posted: Mon, 2011-11-28 17:09
ptl wrote:
Now I need to fix albums/album63/IMG_0913.sized.jpg and albums/album65/DSC00304.jpg type stuff.

Initial testing indicates this might work, now need to start looking for more test cases.

$ diff g2.php g2.php.orig
51,80d50
<         $tmp1=explode("/", $path);
<         if($tmp1[0] == "d") {
<           $tmp2=explode("-", $tmp1[1]);
<           if(ctype_digit($tmp2[0])) {
<             $tmp3=DB::select()->from('g2_maps')->where('g2_id', '=', $tmp2[0]);
<             $tmp4=$tmp3->execute(); $tmp5=$tmp4->as_array();
<             if((count($tmp5) == 1) && (isset($tmp5[0]['g2_url'])))
<               $where[0][2][]=$tmp5[0]['g2_url'];
<           }
<         } else {
<           if($path == "main.php") $tmp6=$input->get("g2_path"); else $tmp6=$path;
<           $tmp7=explode("/", $tmp6);
<           if(count($tmp7) == 2) {
<             $tmp8=explode(".", $tmp7[1]);
<             $tmp9=DB::select()->from('g1_maps')->where('g2col_g1album', '=', $tmp7[0])
<             ->and_where('g2col_g1item', '=', $tmp8[0]);
<             $tmpa=$tmp9->execute(); $tmpb=$tmpa->as_array();
<             if((count($tmpb) == 1) && (isset($tmpb[0]['g2col_itemId']))
<               && (ctype_digit($tmpb[0]['g2col_itemId']))) {
<               $tmpc=$tmpb[0]['g2col_itemId'];
<               $tmpd=DB::select()->from('g2_maps')->where('g2_id', '=', $tmpc)
<                 ->and_where('resource_type', '=', 'file');
<               $tmpe=$tmpd->execute(); $tmpf=$tmpe->as_array();
<               if((count($tmpf) == 1) && (isset($tmpf[0]['g2_url'])))
<                 $tmpg=$tmpf[0]['g2_url'];
<                 $where[0][2][0]=$tmpg;
<                 $where[0][2][1]=str_replace(" ", "+", $tmpg);
<             }
<           }
<         }

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.

 
ptl

Joined: 2003-06-19
Posts: 54
Posted: Mon, 2011-11-28 17:27

http://stiletti.wipsl.com/gallery/album05 does not work, but looks like raw data is there, just need to use it.

mysql> select * from g3tab_g1_maps where g2col_g1album = "album05" and g2col_g1item is NULL;
+--------------+---------------+--------------+
| g2col_itemId | g2col_g1album | g2col_g1item |
+--------------+---------------+--------------+
|        60264 | album05       | NULL         |
+--------------+---------------+--------------+
1 row in set (0.00 sec)

mysql> select * from g3tab_g2_maps where g2_id = "60264";
+-----+-------+-------+------------------------+---------------+
| id  | g2_id | g3_id | g2_url                 | resource_type |
+-----+-------+-------+------------------------+---------------+
| 242 | 60264 |   228 | v/oro/safarit/album05/ | album         |
+-----+-------+-------+------------------------+---------------+
1 row in set (0.00 sec)

Long thread getting longer, hopefully this is not against forum rules or something.

 
ptl

Joined: 2003-06-19
Posts: 54
Posted: Mon, 2011-11-28 21:01
ptl wrote:
http://stiletti.wipsl.com/gallery/album05 does not work, but looks like raw data is there, just need to use it.

Done. Think this case might be impossible with rewrite, at least with my rewrite "skills".

$ diff g2.php g2.php.orig
51,85d50
<         $tmp1=explode("/", $path);
<         if($tmp1[0] == "d") {
<           $tmp2=explode("-", $tmp1[1]);
<           if(ctype_digit($tmp2[0])) {
<             $tmp3=DB::select()->from('g2_maps')->where('g2_id', '=', $tmp2[0]);
<             $tmp4=$tmp3->execute(); $tmp5=$tmp4->as_array();
<             if((count($tmp5) == 1) && (isset($tmp5[0]['g2_url']))) {
<               $where[0][2][0]=$tmp5[0]['g2_url'];
<               $where[0][2][1]=str_replace(" ", "+", $tmp5[0]['g2_url']);
<             }
<           }
<         } else {
<           if($path == "main.php") $tmp6=$input->get("g2_path"); else $tmp6=$path;
<           $tmp7=explode("/", $tmp6);
<           if(count($tmp7) == 1) {
<             $tmp9=DB::select()->from('g1_maps')->where('g2col_g1album', '=', $tmp7[0])
<               ->and_where('g2col_g1item', 'is', NULL);
<           } elseif(count($tmp7) == 2) {
<             $tmp8=explode(".", $tmp7[1]);
<             $tmp9=DB::select()->from('g1_maps')->where('g2col_g1album', '=', $tmp7[0])
<             ->and_where('g2col_g1item', '=', $tmp8[0]);
<           }
<           $tmpa=$tmp9->execute(); $tmpb=$tmpa->as_array();
<           if((count($tmpb) == 1) && (isset($tmpb[0]['g2col_itemId']))
<             && (ctype_digit($tmpb[0]['g2col_itemId']))) {
<             $tmpc=DB::select()->from('g2_maps')->where('g2_id', '=', $tmpb[0]['g2col_itemId']);
<             if(count($tmp7) == 1) $tmpc->and_where('resource_type', '=', 'album');
<             elseif(count($tmp7) == 2) $tmpc->and_where('resource_type', '=', 'file');
<             $tmpd=$tmpc->execute(); $tmpe=$tmpd->as_array();
<             if((count($tmpe) == 1) && (isset($tmpe[0]['g2_url']))) {
<               $where[0][2][0]=$tmpe[0]['g2_url'];
<               $where[0][2][1]=str_replace(" ", "+", $tmpe[0]['g2_url']);
<             }
<           }
<         }

I still don't like how the code looks like, but it works with all the test cases I've found so far.

-Paavo