G3 beta 1 - Installation Error

WibbleWobble

Joined: 2009-06-10
Posts: 4
Posted: Wed, 2009-06-10 08:47

I downloaded and unpacked G3b1, and went to the installer URL. I filled out the database details, hit continue and got presented by a blank page.

A little investigation leads me to believe that things stop here in installer.php:
return @mysql_connect($config["host"], $config["user"], $config["password"]);

The problem being that I don't have the mysql module installed (only mysqli), and according to the PHP documentation, that is the standard situation for PHP 5+ (and PHP5 is a pre-req for gallery?). I can also see that the installer checks whether the mysqli module is available in web.php:

"type" => function_exists("mysqli_set_charset") ? "mysqli" : "mysql");

So.. it checks for its availability, and then just attempts to use the other one, which isn't available at all. All a little strange :o)

 
bharat
bharat's picture

Joined: 2002-05-21
Posts: 7994
Posted: Fri, 2009-06-12 08:46

Try changing that line to mysqli_connect -- does that work? I filed this ticket: http://sourceforge.net/apps/trac/gallery/ticket/393

---
Problems? Check gallery3/var/logs before you post! and file bugs here!
Latest zip: http://github.com/gallery/gallery3/zipball/master
Latest git: http://codex.gallery2.org/Gallery:Using_Git

 
WibbleWobble

Joined: 2009-06-10
Posts: 4
Posted: Fri, 2009-06-12 09:41

It's a bit more deeply ingrained - the installer runs through a whole list of checks/actions (can connect, can select DB, DB empty, creates tables, populates data), and in each case it's using the mysql_ version, so I'd need to replace about 15 occurences in this file (and there's one in web.php too - mysql_error()).

I could probably bodge it to run for myself, but in the longer term what it really needs is some abstraction (like that which the Kohana framework you're using provides - although I don't know much about that particular framework).

 
bharat
bharat's picture

Joined: 2002-05-21
Posts: 7994
Posted: Sat, 2009-06-13 01:30

Yes, I'm fairly familiar with the installer :-) Most of the mysql_xxx commands should readily translate to mysqli, but I was unclear if the mysqli_connect() command was going to work without some nontrivial. We're avoiding excessive abstraction in the installer, the simpler it is the less can go wrong. I filed a ticket for this: http://sourceforge.net/apps/trac/gallery/ticket/397

---
Problems? Check gallery3/var/logs before you post! and file bugs here!
Latest zip: http://github.com/gallery/gallery3/zipball/master
Latest git: http://codex.gallery2.org/Gallery:Using_Git

 
WibbleWobble

Joined: 2009-06-10
Posts: 4
Posted: Sat, 2009-06-13 12:14

I've uploaded a patch on trac which may or may not be helpful (I added it to the #393 ticket - which seems to describe the same problem as the #397 one).

I fought with the fact that installer was a static class, because I needed to save some state (I didn't want to add switch statements everywhere testing whether we were using mysql or mysqli which would be rather messy and inefficient - rather I wanted to test once, and just provide a different class in each case). So... my connect() function returns either a light wrapper around the mysql or mysqli functions or false. That then gets put into $config (not ideal, but I had nowhere else to save it), and then all of the other functions have just been changes from e.g. mysql_query() -> $config['dbo']->query()

Anyway - it does work with a mysqli-only install. Use it as you will - I'd probably avoid the horrible $config['dbo'] thing by making installer an instance so it can keep state, but at a certain level this all becomes a matter of taste, so it's yours :P

 
bharat
bharat's picture

Joined: 2002-05-21
Posts: 7994
Posted: Sun, 2009-06-14 00:08

Awesome, thanks! I've fixed this.. can you verify it in the latest code for me?

PS: static classes actually can have variables.. take a look at my version of the code to see how I did it.
---
Problems? Check gallery3/var/logs before you post! and file bugs here!
Latest code/upgrading: http://codex.gallery2.org/Gallery3:Upgrading
Latest git: http://codex.gallery2.org/Gallery:Using_Git

 
WibbleWobble

Joined: 2009-06-10
Posts: 4
Posted: Sun, 2009-06-14 11:11

Static variable huh? Guess you won't be running more than one installer concurrently so that works :o)

Overwriting the mysql_() functions is sneaky. I've tested it, and it works with mysqli-only.

I also tried turning on the old mysql.so module and that worked too.

I was actually expecting to get a "#1251 - mysql_connect(): Client does not support authentication protocol requested by server; consider upgrading MySQL client" error from the latter, since your code prefers the old mysql_ functions, but I guess the mysql module has been patched at some point to fix this - no errors and smooth sailing :o)