just to be clear:
- after installing g2 and before re-running the installer and hitting save in step 5, do not drop the database or any tables. just right after installing, enter the installer again...
and if hitting save in step 5 (db step) just works, that is, is accepted by the installer without further notice, then something is wrong.
we rely on adodb's function MetaTables to return a list of tables in the current database.
it works in adodb's mysql, pg and oracle drivers.
if that MetaTables call just returns an empty array, then we don't detect the existing installation.
but we also check g2data/versions.dat
don't you have a versions.dat file in your g2data directory?
you'll have to debug install/steps/DatabaseSetupStep.class
Larry Menard
Joined: 2005-10-01
Posts: 757
Posted: Fri, 2005-12-02 18:41
> do not drop the database or any tables
Naturally. ;-)
> if hitting save in step 5 (db step) just works, that is, is accepted by the installer without further notice, then something is wrong
That's what I was afraid of.
> don't you have a versions.dat file in your g2data directory?
Yes, but I haven't a clue what it's for.
I started debugging databaseSetupStep, and find that $dbVersion and $datVersion are both empty, which is why it's being treated like a clean fresh install. Then I started working backwards to see where they're set, and it seems I'm dying with no message during _captureStart().
if (empty($templateData['errors']) && empty($templateData['error'])) {
printf("<br>I get here,\n");
$this->_captureStart();
printf("<br>but not here.\n");
$result = $this->_db->MetaTables();
if ($result === false) {
$templateData['errors'][] =
_('The database you specified does not exist. Please create it.');
$dbVersion = '';
} else {
I see that _captureStart is just a wrapper around ob_start(), but I can't find the code for ob_start().
valiant
Joined: 2003-01-04
Posts: 32509
Posted: Fri, 2005-12-02 19:36
your versions.dat file, is it empty or what does it contain?
basically, getVersion() should check versions.dat, getDbVersion should check the row
module core _version
from g2_PluginParameterMap
Regarding the _captureStart(), I found that it's not actually dying, I can once again see printf()s after it runs _captureStop(). So I'll presume that's normal (perhaps "capture" = "capture output"?)... correct me if I'm wrong.
valiant
Joined: 2003-01-04
Posts: 32509
Posted: Fri, 2005-12-02 20:22
well, that it doesn't get the db stuff is one thing, but that $versions has a zero length string for installed is weird.
you'll have to debug
modules/core/module.inc function getInstalledVersions()
aarg, weird stuff. sorry for that.
just to be sure:
- when rerunning the instaler, you're not choosing another g2data dir, right? leave all fields in the installer unchanged...
Larry Menard
Joined: 2005-10-01
Posts: 757
Posted: Fri, 2005-12-02 20:39
> when rerunning the instaler, you're not choosing another g2data dir, right? leave all fields in the installer unchanged...
That's correct.
> you'll have to debug modules/core/module.inc function getInstalledVersions()
is returning "C:\g2dataversions.dat". I added a backslash before 'versions.dat' and it now returns a valid value for "installed".
However, I now get a big red error:
Quote:
The G2 storage directory has a versions.dat file of an old install. But the Gallery database tables don't exist. Select a clean install to erase all data in the Gallery storage directory and advance to the next step.
And I now have a link that says "Erase data for a clean install". Is that the link that you said I should be seeing to invoke cleanStore()?
Larry Menard
Joined: 2005-10-01
Posts: 757
Posted: Sun, 2005-12-04 14:21
Ah-haa, now I found another problem regarding versions. In db2DatabaseStorage::getVersion(), function "odbc_version()" is not found. Nor do I find anything about it in the PHP ODBC manual "http://www.php.net/manual/en".
What shall we do about this?
valiant
Joined: 2003-01-04
Posts: 32509
Posted: Sun, 2005-12-04 22:51
@In getInstalledVersions():
yeah, that was a bug. fixed in cvs, thanks. usually, we add the trailing slash in GalleryInitFirstPass (init.inc), but if there are no database tables, this function isn't called in the installer.
yes, this "erase data for a clean install" is what i meant.
Quote:
Ah-haa, now I found another problem regarding versions. In db2DatabaseStorage::getVersion(), function "odbc_version()" is not found. Nor do I find anything about it in the PHP ODBC manual "http://www.php.net/manual/en".
What shall we do about this?
that's unrelated. Db2DatabaseStorage.class function getVersion should return the version of the db2 server.
what we're asking for in the DatabaseSetupStep.class of the installer is the installed G2 version.
thus, we're first asking the database for all a list of all g2 tables in the g2 database.
then we're checking if g2_Schema (of course we use the user defined prefix) and g2_PluginParameterMap exist.
then we check the row module core _version in g2_PluginParameterMap to get the installed g2 version.
but the function MetaTables for adodb-db2.inc.php seems to return an empty list, right? can't help you there. that's abug with this db2/odbc thing.
Larry Menard
Joined: 2005-10-01
Posts: 757
Posted: Mon, 2005-12-05 03:01
> but the function MetaTables for adodb-db2.inc.php seems to return an empty list, right?
The reason I'm getting the error "The G2 storage directory has a versions.dat file of an old install. But the Gallery database tables don't exist" is because $dbVersion is null. The reason $dbVersion is null is because there's no odbc_version() function. So it seems to me that the lack of an odbc_version() function is very much related.
AFAIK (As Far As I Know) the only way to determine the version of the DB2 server is to issue the "db2level" command. It will return something like:
Quote:
DB21085I Instance "DB2" uses "32" bits and DB2 code release "SQL08022" with
level identifier "03030106".
Informational tokens are "DB2 v8.1.9.700", "s050422", "WR21350", and FixPak
"9".
Product is installed at "C:\PROGRA~1\IBM\SQLLIB".
Then we'd have to parse the version string out of it.
Does that sound acceptable?
valiant
Joined: 2003-01-04
Posts: 32509
Posted: Mon, 2005-12-05 10:05
ah, no. the problem is that ODBC / DB2 returns a capitalized list of tables.
pg/mysql/oracle return "g2_PluginParameterMap, g2_PhotoItem, ..."
on windows, mysql returns "g2_pluginparametermap, g2_photoitem, ..." (all lower case)
and db2 seems to return all capital case on windows.
please replace your install/steps/DatabaseSetupStep.class with this file (rename .class.txt to .class again):
The reason $dbVersion is null is because there's no odbc_version() function.
no, either i'm having a really bad day and i'm not understanding you or it's exactly what i described in my last post and in this post. odbc_version is totally unrelated to the row
pluginType = module, pluginId = core, parameterName = _version parameterValue = 1.0.10 in your g2_PluginParameterMap.
the odbc_version / db2 version isn't needed here. yes, we call Db2DatabaseStorage::getVersion just to have some debugging information, but it's not related to the string
""The G2 storage directory has a versions.dat file of an old install. But the Gallery database tables don't exist" ".
believe me, i wrote that stuff
and yes, db2level sounds acceptable for Db2DatabaseStorage.class function getVersion(). It's not that important what it returns. maybe just return the whole db2level output.
Larry Menard
Joined: 2005-10-01
Posts: 757
Posted: Mon, 2005-12-05 15:43
I think I see where I'm confused. I interpreted $dbVersion to mean "version of the database server", but now I gather it means something more like "version of the database schema".
The new class file does work, but now when I choose the option to clean and recreate the store, I get error:
Quote:
Could not execute the required API to drop the Gallery database tables. Please clean the Gallery database manually.
We received the following database related errors:
--------------------------------------------------------------------------------
For odbc Connect(), gallery2 is not used. Place dsn in 1st parameter.
--------------------------------------------------------------------------------
(db2): SELECT g_name, g_major, g_minor FROM g2_Schema
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
(db2): DROP TABLE g2_Schema
--------------------------------------------------------------------------------
Warning: odbc_exec() [function.odbc-exec]: SQL error: [IBM][CLI Driver][DB2/NT] SQL0950N The table or index cannot be dropped because it is currently in use. SQLSTATE=55006 , SQL state 55006 in SQLExecDirect in C:\My Server\gallery2\lib\adodb\drivers\adodb-odbc.inc.php on line 530
55006: [IBM][CLI Driver][DB2/NT] SQL0950N The table or index cannot be dropped because it is currently in use. SQLSTATE=55006
I wonder if this is another instance of the problem where default cursors in ODBC are FOR UPDATE. If that's the case, we might be able to avoid this by adding FOR READ ONLY to the SELECT statement before the DROP statement?
Unfortunately the porting of an ADOdb driver for 'ibm_db2' is still a long way away. I'm relying on Dan to help address problem I hit, and he doesn't seem to have the time lately to do so.
feel free to edit that page (you just need to register an account on codex.gallery2.org).
i'll commit the capitalized string issue of adodb/odbc/windows today.
Larry Menard
Joined: 2005-10-01
Posts: 757
Posted: Mon, 2005-12-05 19:17
Thanks, I've also updated the page a little.
FYI, I suspect that the tables will all be uppercased in Linux/UNIX as well. I'm pretty sure it's a DB2 thing, not an OS thing. (In DB2's catalog tables they are all uppercase, and I'm prety sure that's where the metadata is taken from.)
Larry Menard
Joined: 2005-10-01
Posts: 757
Posted: Sun, 2005-12-11 19:39
Hey, Valiant.
I'm trying to add the admin functionality I haven't added yet ("Optimize database", "Delete database cache" and "System information").
1) "Optimize database"
Looks like what we want to do here is call DB2's "REORGCHK_TB_STATS" stored procedure. However:
- It needs to pass the schema id (the g2 database user account, in my case, 'G2USER'). Is there a variable I can reference to get this?
- It won't work on 'single-user' Windows platforms (95|8, ME, XP). However, I doubt anybody will be doing any serious photo sharing on XP. Would you say that's an acceptable trade-off?
(The reason it won't work on XP etc. is that it requires an authority level SYSCTRL, which is granted to GROUPs, not individual accounts. Since XP does not have the concept of GROUPs, the only way to do it is to make the G2 account a Windows system administrator. I doubt people would be happy to do that.)
2) "Delete database cache"
Already works.
3) "System Information"
I added the following:
function getVersion() {
$levelcmd = 'db2level';
list ($success, $outputArray) = $platform->exec(array($levelcmd));
return $outputArray;
}
But it doesn't work. I just get a blank browser screen (which typically happens when there's a PHP syntax error). When I comment out the exec line the browser output comes back, so I know the problem is with that line, but it looks fine to me. Any idea what's wrong with it?
Thanks.
valiant
Joined: 2003-01-04
Posts: 32509
Posted: Sun, 2005-12-11 22:03
1) optimize database
$this->_ds->_username
and if there's nothing better than this stored procedure, sure, it's ok. just make sure the the machine doesn't explode when it's not supported. just return the error.
2) delete database cache
k
3) system information
$platform->exec(array(array($levelcmd))); and not $platform->exec(array($levelcmd));
Larry Menard
Joined: 2005-10-01
Posts: 757
Posted: Sun, 2005-12-11 22:32
3) Still doesn't work. I still just get a blank browser. Did I miss something?
function getVersion() {
$levelcmd = 'db2level';
list ($success, $outputArray) = $platform->exec(array(array($levelcmd)));
return implode("\n", $outputArray);
}
Larry Menard
Joined: 2005-10-01
Posts: 757
Posted: Sun, 2005-12-11 22:50
I figured it out. There's no $platform at that point. I had to add:
global $gallery;
$platform = $gallery->getPlatform();
Thanks. Now I just have to figure out a way to distinguish between single- and multi-user Windows. Then I'll forward my change to you.
Larry Menard
Joined: 2005-10-01
Posts: 757
Posted: Sun, 2005-12-11 23:08
Umm, actually, "$this->_ds->_username" doesn't work either. Apparently "_ds" doesn't exist.
Quote:
Notice: Undefined property: Db2DatabaseStorage::$_ds in C:\MyServer\Gallery2\modules\core\classes\GalleryStorage\DatabaseStorage\Db2DatabaseStorage.class on line 323
Notice: Trying to get property of non-object in C:\MyServer\Gallery2\modules\core\classes\GalleryStorage\DatabaseStorage\Db2DatabaseStorage.class on line 323
Larry Menard
Joined: 2005-10-01
Posts: 757
Posted: Sun, 2005-12-11 23:10
OK, I just removed the "_ds->" and now it works.
Larry Menard
Joined: 2005-10-01
Posts: 757
Posted: Mon, 2005-12-12 00:35
Distinguishing single-user from multi-user Windows in PHP:
I don't know of a definitive way to tell the difference between (for example,) XP and W2K via PHP. On my XP systems, php_uname() returns "Windows NT" and PHP_OS is "WINNT". So it doesn't look like PHP natively distinguishes between them.
Since the ultimate requirement is to determine whether the current platform supports Groups, one method that I thought of was to use getmygid(). On my XP system it returns "0", which sounds reasonable. On systems that do support Groups, I don't know how likely it would be to return "0". As I don't have a W2K system to test it on, I have no idea how foolproof this is (or isn't).
why not just try to run the command and if it fails, it fails, just forward the error and the poor win 98 souls have to deal with it....
@getmygid: never used it. it's php 4.1.0+ so it's ok to use it in g2, but i just don't know the function...
Larry Menard
Joined: 2005-10-01
Posts: 757
Posted: Mon, 2005-12-12 15:52
Can you point me to an example of g2 code where a non-fatal warning is reported?
This particular error is rather misleading ("User doesn't have authorization to create a tablespace"). I'd rather compose my own more explicit message rather than just forwarding that one.
valiant
Joined: 2003-01-04
Posts: 32509
Posted: Mon, 2005-12-12 16:14
hmm, just looked at the code etc. and maybe it would be good if you actually returned an empty string if you already know that it won't work.
so please do what you originally planned to do, that's fine.
please add the code that needs to be added on the codex page such that we don't forget. currently we can't commit it to CVS since we're in a deep CVS BRANCH and we'll merge back around new year.
Larry Menard
Joined: 2005-10-01
Posts: 757
Posted: Mon, 2005-12-12 16:24
OK, will do. Thanks.
Larry Menard
Joined: 2005-10-01
Posts: 757
Posted: Sat, 2005-12-17 02:54
Quick status update...
I've been working on the ADOdb driver for 'ibm_db2', and have it working in very simple connect/select scenarios.
The good news is that it does in fact fix the CLI0005W warnings (SELECTs from JOINs). So I should be able to get a much better run of the unit tests when it is ready.
The bad news is that it does not fix the 'SQLJ.INSTALL_JAR()' problem. Not really that big a deal.
valiant
Joined: 2003-01-04
Posts: 32509
Posted: Sat, 2005-12-17 03:08
good to know that you're making progress!
good to have a basic working driver, now you can gradually add features. and don't forget to backup working code!
Larry Menard
Joined: 2005-10-01
Posts: 757
Posted: Sat, 2005-12-17 03:33
I just realized that maybe you can answer a question for me.
Does the ADOdb package have a platform-independent set of verification tests? I see a "tests" directory in the package, but they all seem to use a MS Access 'northwind' database. Same thing for the 'tutorial' examples in the package documentation. Do they not have a platform-independent set of verification tests?
valiant
Joined: 2003-01-04
Posts: 32509
Posted: Sat, 2005-12-17 03:40
don't know, sorry. i'm sure the adodb author can answer this question.
Larry Menard
Joined: 2005-10-01
Posts: 757
Posted: Sat, 2005-12-17 18:04
I posted a question to the ADOdb support tracking page. We'll see what happens.
In the meantime, I decided to bite the bullet and try the Installer using my ADOdb/ibm_db2 driver.
Step 5 (database setup) works fine, which is encouraging, but it subsequently fails in step 8 (install the core).
In the install.log (attached) the only errors I see (other than the expected '"G2USER.G2_PLUGINPARAMETERMAP" is an undefined name') are:
Quote:
[IBM][CLI Driver][DB2/NT] SQL0408N A value is not compatible with the data type of its assignment target. Target name is "<some column>". SQLSTATE=42821
The exact instances of it that I see are:
1) Target name is "G_PARAMETERVALUE":
INSERT INTO g2_PluginParameterMap (g_pluginType, g_pluginId, g_itemId, g_parameterName, g_parameterValue) VALUES ('module','core',0,'session.lifetime',788400000)
Since G_PARAMETERVALUE is defined as LONG VARCHAR:
C:\MyServer>db2 describe table g2_PluginParameterMap
Column Type Type
name schema name Length Scale Nulls
------------------------------ --------- ------------------ -------- ----- ------
G_PLUGINTYPE SYSIBM VARCHAR 32 0 No
G_PLUGINID SYSIBM VARCHAR 32 0 No
G_ITEMID SYSIBM INTEGER 4 0 No
G_PARAMETERNAME SYSIBM VARCHAR 128 0 No
G_PARAMETERVALUE SYSIBM LONG VARCHAR 32700 0 No
5 record(s) selected.
I suspect the value inserted should be in single quotes.
There already are a number of valid values in that table, so there must be correct codepaths somewhere.
So again, the value being inserted should be in single quotes.
And in this case there are no currently-existing values in the table.
C:\MyServer>db2 select G_ORDERWEIGHT from g2_factorymap
G_ORDERWEIGHT
-------------------------------------------------------------------------------------
0 record(s) selected.
Larry Menard
Joined: 2005-10-01
Posts: 757
Posted: Sat, 2005-12-17 18:55
Hmmm, never mind about this. I checked the install.log from my running installation (which uses odbc) and those values are in single quotes.
So never mind, it must be something in the ibm_db2 driver. I'll look into it.
Larry Menard
Joined: 2005-10-01
Posts: 757
Posted: Sat, 2005-12-17 19:25
Hmmm... I notice that the order of the last two fields of the $data array ('orderweight' and 'hints') are not in the same order as the columns in the SQL:
After further investigation, I don't think the order is significant... I went back to ODBC and dumped the vars and the order is the same as with 'ibm_db2'.
Notice that the type of $data['orderweight'] is now 'String(1)'. With 'ibm_db2' it is 'int'.
Any suggestions as to where this type is being determined?
Thanks.
valiant
Joined: 2003-01-04
Posts: 32509
Posted: Sat, 2005-12-17 20:29
where exactly do you dump the debug output (query/data)?
Larry Menard
Joined: 2005-10-01
Posts: 757
Posted: Sat, 2005-12-17 20:59
I was dumping them in addMapEntry() in "DatabaseStorageExtras.class".
Now I'm working my way back through the stack trace and dumping "$orderWeight" at each step. I found that in registerImplementation() in "GalleryFactoryHelper_medium.class", "$orderWeight" is type int.
The next step back in the stack trace is performFactoryRegistrations() in "CoreModuleExtra.inc", but it's a bit over my head.
Larry Menard
Joined: 2005-10-01
Posts: 757
Posted: Sun, 2005-12-18 04:12
Ok, I think I found this problem (correct me if I'm wrong).
In performFactoryRegistrations() in "CoreModulesExtra.inc" I changed line 1934 from:
(Instead of casting $entry[4], I could have quoted or casted all of the 5th values as they are pushed onto the $entry array. Casting $entry[4] is perhaps less obvious, but it's fewer keystrokes. )
Fatal error: Call to undefined method GalleryUser::failWithStatus() in C:\MyServer\Gallery2\modules\core\classes\helpers\GalleryUserGroupHelper_medium.class on line 53
But at least I think there are no more type mismatches.
Let me know what you think about that.
valiant
Joined: 2003-01-04
Posts: 32509
Posted: Sun, 2005-12-18 18:43
i think the above changes are reasonable, since we shouldn't try to insert unquoted numeric values into string columns. right now, we were relying on the adodb driver and the database to handle it correctly.
@fatal error:
you get an error there,
change the failwithstatus line to:
return $ret->wrap(__FILE__, __LINE__);
this was a weird bug, probably very old code.
i'll fix this and change the (string) castings and commit it to cvs HEAD.
Larry Menard
Joined: 2005-10-01
Posts: 757
Posted: Sun, 2005-12-18 19:42
Fantastic, thanks.
I'll proceed with the next problem. ;-)
This must be your turn to stump me... what's "HEAD"?
valiant
Joined: 2003-01-04
Posts: 32509
Posted: Sun, 2005-12-18 21:54
we're using CVS as a repository for the sourcecode of gallery. (cvs.sourceforge.net).
cvs can manage multiple releases/branches of the sourcecode. e.g. if i commit some code to the release/branch HEAD, then i only changed the HEAD version of gallery.
HEAD is the main branch in cvs. if not stated otherwize, everything happens in HEAD, also if you use cvs to get the gallery sourcecode, you're getting the code from the HEAD release.
even if the version in cvs is not intended for production since we always commit our development changes to it, we keep HEAD as clean as possible and you should be able to use HEAD for a production website at anytime.
currently, we have a second active release, BRANCH_API_DEV because we're changing too much to still guarantee a 100% working g2 (well, even BRANCH_API_DEV is usable, but we find a few development bugs from time to time).
around new year, we'll merge the changes of BRANCH_API_DEV into HEAD and we'll stop using BRANCH_API_DEV and develop further directly on HEAD.
FYI, I'm now at a point in which the Gallery core installs successfully, but I get an ERROR_STORAGE_FAILURE error when I go to Step 10. I'll keep hacking at it tomorrow or the day after. I've been going continuously full-throttle on this for about 36 hours now... need a breather. And a few beer.
valiant
Joined: 2003-01-04
Posts: 32509
Posted: Mon, 2005-12-19 03:00
36h, lol. extreme
thanks for reporting.
as with the previous changes, i fixed it on a lower level, if possible. (but not in the map interfaces, since that code changes in BRANCH_API_DEV anyway).
Larry Menard
Joined: 2005-10-01
Posts: 757
Posted: Wed, 2005-12-21 16:24
Valiant,
I now have the Installer completing successfully, but I happened to notice that I still get the following error in the install.log:
2005-12-21 11:30:32 [] getParameter id.allUserGroup for core plugin
2005-12-21 11:30:32 [] db2 error: [42818: [IBM][CLI Driver][DB2/NT] SQL0401N The data types of the operands for the operation "=" are not compatible. SQLSTATE=42818
SQLCODE=-401] in EXECUTE("DELETE FROM g2_UserGroupMap WHERE g_userId=5 AND g_groupId='2'")
But I don't get a stack trace with it (presumably because it's considered non-fatal), so I don't know where to start tracking this.
Any suggestions?
Larry Menard
Joined: 2005-10-01
Posts: 757
Posted: Wed, 2005-12-21 16:31
Ah, never mind, I found the stack trace in the log file.
Larry Menard
Joined: 2005-10-01
Posts: 757
Posted: Wed, 2005-12-21 16:39
Hmm, the stack trrace doesn't seem to take me back far enough.
To fix this at the lowest level I need to find where the '$data' is set that is being passed into removeMapEntry().
valiant
Joined: 2003-01-04
Posts: 32509
Posted: Wed, 2005-12-21 17:56
modules/core/classes/helpers/GalleryUserGroupHelper_*.class
it's a little strange that remove user from group or something like that is called during install though.
Larry Menard
Joined: 2005-10-01
Posts: 757
Posted: Wed, 2005-12-21 18:43
Thanks.
OK, I have the install completely working now, and the main.php runs without error.
However, even after I login with the admin id I am not given the option to create an album.
Any suggestions where to start looking, or should I just start with main.php and work my way through the code?
valiant
Joined: 2003-01-04
Posts: 32509
Posted: Thu, 2005-12-22 00:14
if you don't see "add items" in the left side item actions menu,
then you're not logged in. in a default installation (matrix theme,
no removed/added blocks), you should see "logout" in the upper right
corner (login changes to logout upon successful login) and you should
see the add items, add album, ... options in the left side menu.
Larry Menard
Joined: 2005-10-01
Posts: 757
Posted: Thu, 2005-12-22 05:52
Trust me, I'm already very familiar with the process of logging in, and the resultant change of fields in the browser. In the last few months I've done so more times than I care to count. Like I said, "even after logging in...". My login does complete successfully, the indicators in the bottom-right corner do reflect my logged-in "lmenard" account, and I do have the "Site Admin" and "Logout" links in the top-right corner. So the login does seem to have worked according to those indicators, but I don't have the actions available in the left-hand side.
So what I'm asking is "Since you are much more intimately familiar with the flow of the application logic than I am (and given the symptoms described above), do you have any suggestions as to where in the code I should start to look?". Or should I just start in "main.php" and start tracing the hell out of it?
valiant
Joined: 2003-01-04
Posts: 32509
Posted: Thu, 2005-12-22 12:45
then it looks like that the matrix theme default blocks have not been properly added to the pluginParameterMap table during installation.
or they are there, but the select isn't working correctly.
check g2_PluginParameterMap pluginId = matrix for its parameters.
sidebarBlocks, albumBlocks, photoBlocks
they are set during installation, CoreModuleExtras.inc -> matrix theme installation + activation. they are set during activation.
modules/core/classes/GalleryTheme.class function activate calls $this->getSettings() which in turn calls $this->getStandardSettings() which was set by the constructor of themes/matrix/theme.inc .
the returned $settings are an array of key => value pairs and the sidebarBlocks value should be a serialized array = a string.
works all fine on mysql and pg etc. i just checked it and in activate -> setParameter, the values for the sidebarBlock is indeed a string (serialized array), so it should be fine.
-> check in g2_PluginParameterMap if g_pluginId = 'matrix', g_parameterName = 'sidebarBlocks' is present and if its value is a string.
Posts: 32509
just to be clear:
- after installing g2 and before re-running the installer and hitting save in step 5, do not drop the database or any tables. just right after installing, enter the installer again...
and if hitting save in step 5 (db step) just works, that is, is accepted by the installer without further notice, then something is wrong.
we rely on adodb's function MetaTables to return a list of tables in the current database.
it works in adodb's mysql, pg and oracle drivers.
if that MetaTables call just returns an empty array, then we don't detect the existing installation.
but we also check g2data/versions.dat
don't you have a versions.dat file in your g2data directory?
you'll have to debug install/steps/DatabaseSetupStep.class
Posts: 757
> do not drop the database or any tables
Naturally. ;-)
> if hitting save in step 5 (db step) just works, that is, is accepted by the installer without further notice, then something is wrong
That's what I was afraid of.
> don't you have a versions.dat file in your g2data directory?
Yes, but I haven't a clue what it's for.
I started debugging databaseSetupStep, and find that $dbVersion and $datVersion are both empty, which is why it's being treated like a clean fresh install. Then I started working backwards to see where they're set, and it seems I'm dying with no message during _captureStart().
I see that _captureStart is just a wrapper around ob_start(), but I can't find the code for ob_start().
Posts: 32509
your versions.dat file, is it empty or what does it contain?
basically, getVersion() should check versions.dat, getDbVersion should check the row
module core _version
from g2_PluginParameterMap
Posts: 757
My versions.dat contains:
When I var_dump $versions, I get:
Regarding the _captureStart(), I found that it's not actually dying, I can once again see printf()s after it runs _captureStop(). So I'll presume that's normal (perhaps "capture" = "capture output"?)... correct me if I'm wrong.
Posts: 32509
well, that it doesn't get the db stuff is one thing, but that $versions has a zero length string for installed is weird.
you'll have to debug
modules/core/module.inc function getInstalledVersions()
aarg, weird stuff. sorry for that.
just to be sure:
- when rerunning the instaler, you're not choosing another g2data dir, right? leave all fields in the installer unchanged...
Posts: 757
> when rerunning the instaler, you're not choosing another g2data dir, right? leave all fields in the installer unchanged...
That's correct.
> you'll have to debug modules/core/module.inc function getInstalledVersions()
OK, will do.
Thanks.
Posts: 757
OK, here's one problem.
In getInstalledVersions(),
is returning "C:\g2dataversions.dat". I added a backslash before 'versions.dat' and it now returns a valid value for "installed".
However, I now get a big red error:
And I now have a link that says "Erase data for a clean install". Is that the link that you said I should be seeing to invoke cleanStore()?
Posts: 757
Ah-haa, now I found another problem regarding versions. In db2DatabaseStorage::getVersion(), function "odbc_version()" is not found. Nor do I find anything about it in the PHP ODBC manual "http://www.php.net/manual/en".
What shall we do about this?
Posts: 32509
@In getInstalledVersions():
yeah, that was a bug. fixed in cvs, thanks. usually, we add the trailing slash in GalleryInitFirstPass (init.inc), but if there are no database tables, this function isn't called in the installer.
yes, this "erase data for a clean install" is what i meant.
that's unrelated. Db2DatabaseStorage.class function getVersion should return the version of the db2 server.
what we're asking for in the DatabaseSetupStep.class of the installer is the installed G2 version.
thus, we're first asking the database for all a list of all g2 tables in the g2 database.
then we're checking if g2_Schema (of course we use the user defined prefix) and g2_PluginParameterMap exist.
then we check the row module core _version in g2_PluginParameterMap to get the installed g2 version.
but the function MetaTables for adodb-db2.inc.php seems to return an empty list, right? can't help you there. that's abug with this db2/odbc thing.
Posts: 757
> but the function MetaTables for adodb-db2.inc.php seems to return an empty list, right?
I disagree.
The reason I'm getting the error "The G2 storage directory has a versions.dat file of an old install. But the Gallery database tables don't exist" is because $dbVersion is null. The reason $dbVersion is null is because there's no odbc_version() function. So it seems to me that the lack of an odbc_version() function is very much related.
AFAIK (As Far As I Know) the only way to determine the version of the DB2 server is to issue the "db2level" command. It will return something like:
Then we'd have to parse the version string out of it.
Does that sound acceptable?
Posts: 32509
ah, no. the problem is that ODBC / DB2 returns a capitalized list of tables.
pg/mysql/oracle return "g2_PluginParameterMap, g2_PhotoItem, ..."
on windows, mysql returns "g2_pluginparametermap, g2_photoitem, ..." (all lower case)
and db2 seems to return all capital case on windows.
please replace your install/steps/DatabaseSetupStep.class with this file (rename .class.txt to .class again):
http://dev.nei.ch/DatabaseSetupStep.class.txt
no, either i'm having a really bad day and i'm not understanding you or it's exactly what i described in my last post and in this post. odbc_version is totally unrelated to the row
pluginType = module, pluginId = core, parameterName = _version parameterValue = 1.0.10 in your g2_PluginParameterMap.
the odbc_version / db2 version isn't needed here. yes, we call Db2DatabaseStorage::getVersion just to have some debugging information, but it's not related to the string
""The G2 storage directory has a versions.dat file of an old install. But the Gallery database tables don't exist" ".
believe me, i wrote that stuff
and yes, db2level sounds acceptable for Db2DatabaseStorage.class function getVersion(). It's not that important what it returns. maybe just return the whole db2level output.
Posts: 757
I think I see where I'm confused. I interpreted $dbVersion to mean "version of the database server", but now I gather it means something more like "version of the database schema".
The new class file does work, but now when I choose the option to clean and recreate the store, I get error:
I wonder if this is another instance of the problem where default cursors in ODBC are FOR UPDATE. If that's the case, we might be able to avoid this by adding FOR READ ONLY to the SELECT statement before the DROP statement?
Unfortunately the porting of an ADOdb driver for 'ibm_db2' is still a long way away. I'm relying on Dan to help address problem I hit, and he doesn't seem to have the time lately to do so.
Posts: 32509
ok, i've updated http://codex.gallery2.org/index.php/Gallery2:DB2
feel free to edit that page (you just need to register an account on codex.gallery2.org).
i'll commit the capitalized string issue of adodb/odbc/windows today.
Posts: 757
Thanks, I've also updated the page a little.
FYI, I suspect that the tables will all be uppercased in Linux/UNIX as well. I'm pretty sure it's a DB2 thing, not an OS thing. (In DB2's catalog tables they are all uppercase, and I'm prety sure that's where the metadata is taken from.)
Posts: 757
Hey, Valiant.
I'm trying to add the admin functionality I haven't added yet ("Optimize database", "Delete database cache" and "System information").
1) "Optimize database"
Looks like what we want to do here is call DB2's "REORGCHK_TB_STATS" stored procedure. However:
- It needs to pass the schema id (the g2 database user account, in my case, 'G2USER'). Is there a variable I can reference to get this?
- It won't work on 'single-user' Windows platforms (95|8, ME, XP). However, I doubt anybody will be doing any serious photo sharing on XP. Would you say that's an acceptable trade-off?
(The reason it won't work on XP etc. is that it requires an authority level SYSCTRL, which is granted to GROUPs, not individual accounts. Since XP does not have the concept of GROUPs, the only way to do it is to make the G2 account a Windows system administrator. I doubt people would be happy to do that.)
2) "Delete database cache"
Already works.
3) "System Information"
I added the following:
But it doesn't work. I just get a blank browser screen (which typically happens when there's a PHP syntax error). When I comment out the exec line the browser output comes back, so I know the problem is with that line, but it looks fine to me. Any idea what's wrong with it?
Thanks.
Posts: 32509
1) optimize database
$this->_ds->_username
and if there's nothing better than this stored procedure, sure, it's ok. just make sure the the machine doesn't explode when it's not supported. just return the error.
2) delete database cache
k
3) system information
$platform->exec(array(array($levelcmd))); and not $platform->exec(array($levelcmd));
Posts: 757
3) Still doesn't work. I still just get a blank browser. Did I miss something?
Posts: 757
I figured it out. There's no $platform at that point. I had to add:
global $gallery;
$platform = $gallery->getPlatform();
Thanks. Now I just have to figure out a way to distinguish between single- and multi-user Windows. Then I'll forward my change to you.
Posts: 757
Umm, actually, "$this->_ds->_username" doesn't work either. Apparently "_ds" doesn't exist.
Posts: 757
OK, I just removed the "_ds->" and now it works.
Posts: 757
Distinguishing single-user from multi-user Windows in PHP:
I don't know of a definitive way to tell the difference between (for example,) XP and W2K via PHP. On my XP systems, php_uname() returns "Windows NT" and PHP_OS is "WINNT". So it doesn't look like PHP natively distinguishes between them.
Since the ultimate requirement is to determine whether the current platform supports Groups, one method that I thought of was to use getmygid(). On my XP system it returns "0", which sounds reasonable. On systems that do support Groups, I don't know how likely it would be to return "0". As I don't have a W2K system to test it on, I have no idea how foolproof this is (or isn't).
What do you think?
Posts: 32509
why not just try to run the command and if it fails, it fails, just forward the error and the poor win 98 souls have to deal with it....
@getmygid: never used it. it's php 4.1.0+ so it's ok to use it in g2, but i just don't know the function...
Posts: 757
Can you point me to an example of g2 code where a non-fatal warning is reported?
This particular error is rather misleading ("User doesn't have authorization to create a tablespace"). I'd rather compose my own more explicit message rather than just forwarding that one.
Posts: 32509
hmm, just looked at the code etc. and maybe it would be good if you actually returned an empty string if you already know that it won't work.
so please do what you originally planned to do, that's fine.
please add the code that needs to be added on the codex page such that we don't forget. currently we can't commit it to CVS since we're in a deep CVS BRANCH and we'll merge back around new year.
Posts: 757
OK, will do. Thanks.
Posts: 757
Quick status update...
I've been working on the ADOdb driver for 'ibm_db2', and have it working in very simple connect/select scenarios.
The good news is that it does in fact fix the CLI0005W warnings (SELECTs from JOINs). So I should be able to get a much better run of the unit tests when it is ready.
The bad news is that it does not fix the 'SQLJ.INSTALL_JAR()' problem. Not really that big a deal.
Posts: 32509
good to know that you're making progress!
good to have a basic working driver, now you can gradually add features. and don't forget to backup working code!
Posts: 757
I just realized that maybe you can answer a question for me.
Does the ADOdb package have a platform-independent set of verification tests? I see a "tests" directory in the package, but they all seem to use a MS Access 'northwind' database. Same thing for the 'tutorial' examples in the package documentation. Do they not have a platform-independent set of verification tests?
Posts: 32509
don't know, sorry. i'm sure the adodb author can answer this question.
Posts: 757
I posted a question to the ADOdb support tracking page. We'll see what happens.
In the meantime, I decided to bite the bullet and try the Installer using my ADOdb/ibm_db2 driver.
Step 5 (database setup) works fine, which is encouraging, but it subsequently fails in step 8 (install the core).
In the install.log (attached) the only errors I see (other than the expected '"G2USER.G2_PLUGINPARAMETERMAP" is an undefined name') are:
The exact instances of it that I see are:
1) Target name is "G_PARAMETERVALUE":
INSERT INTO g2_PluginParameterMap (g_pluginType, g_pluginId, g_itemId, g_parameterName, g_parameterValue) VALUES ('module','core',0,'session.lifetime',788400000)
Since G_PARAMETERVALUE is defined as LONG VARCHAR:
I suspect the value inserted should be in single quotes.
There already are a number of valid values in that table, so there must be correct codepaths somewhere.
So I suspect it is only this particular codepath that might be broken.
2) Target name is "G_ORDERWEIGHT"
INSERT INTO g2_FactoryMap (g_classType, g_className, g_implId, g_implPath, g_implModuleId, g_hints, g_orderWeight) VALUES ('GalleryEntity','GalleryEntity','GalleryEntity','modules/core/classes/GalleryEntity.class','core','N;',4)
In this case, column G_ORDERWEIGHT is defined as VARCHAR(255):
So again, the value being inserted should be in single quotes.
And in this case there are no currently-existing values in the table.
Posts: 757
Hmmm, never mind about this. I checked the install.log from my running installation (which uses odbc) and those values are in single quotes.
So never mind, it must be something in the ibm_db2 driver. I'll look into it.
Posts: 757
Hmmm... I notice that the order of the last two fields of the $data array ('orderweight' and 'hints') are not in the same order as the columns in the SQL:
Does that matter?
Posts: 757
After further investigation, I don't think the order is significant... I went back to ODBC and dumped the vars and the order is the same as with 'ibm_db2'.
BUT...
Notice that the type of $data['orderweight'] is now 'String(1)'. With 'ibm_db2' it is 'int'.
Any suggestions as to where this type is being determined?
Thanks.
Posts: 32509
where exactly do you dump the debug output (query/data)?
Posts: 757
I was dumping them in addMapEntry() in "DatabaseStorageExtras.class".
Now I'm working my way back through the stack trace and dumping "$orderWeight" at each step. I found that in registerImplementation() in "GalleryFactoryHelper_medium.class", "$orderWeight" is type int.
The next step back in the stack trace is performFactoryRegistrations() in "CoreModuleExtra.inc", but it's a bit over my head.
Posts: 757
Ok, I think I found this problem (correct me if I'm wrong).
In performFactoryRegistrations() in "CoreModulesExtra.inc" I changed line 1934 from:
'core', $entry[3], isset($entry[4]) ? $entry[4] : 4);
to:
'core', $entry[3], isset($entry[4]) ? $entry[4] : '4');
Given that column G_ORDERWEIGHT is a LONG VARCHAR (which is a CHAR type, not numeric) I think this makes sense.
This has gotten me past this problem, but now I hit another instance of what appears to be the same problem somewhere else.
Before I spend a lot of time chasing down this next occurrence, do you agree that this is a good solution?
(I don't know why this has never failed before anywhere else. That bothers me.)
Posts: 757
I've now traced all the occurrences of the type mismatch problems. I solved them by changing:
In upgrade() in "CoreModuleExtras.inc":
In performFactoryRegistrations() in "CoreModuleExtras.inc":
//'core', $entry[3], isset($entry[4]) ? $entry[4] : 4); 'core', $entry[3], isset($entry[4]) ? (string) $entry[4] : '4');
(Instead of casting $entry[4], I could have quoted or casted all of the 5th values as they are pushed onto the $entry array. Casting $entry[4] is perhaps less obvious, but it's fewer keystrokes. )
In setParameter() in "GalleryPlugin.class":
//$this->getPluginType(), $this->getId(), $parameterName, $parameterValue, $itemId); $this->getPluginType(), $this->getId(), $parameterName, (string) $parameterValue, $itemId);
Tomorrow I'm going to work on the next problem:
But at least I think there are no more type mismatches.
Let me know what you think about that.
Posts: 32509
i think the above changes are reasonable, since we shouldn't try to insert unquoted numeric values into string columns. right now, we were relying on the adodb driver and the database to handle it correctly.
@fatal error:
you get an error there,
change the failwithstatus line to:
return $ret->wrap(__FILE__, __LINE__);
this was a weird bug, probably very old code.
i'll fix this and change the (string) castings and commit it to cvs HEAD.
Posts: 757
Fantastic, thanks.
I'll proceed with the next problem. ;-)
This must be your turn to stump me... what's "HEAD"?
Posts: 32509
we're using CVS as a repository for the sourcecode of gallery. (cvs.sourceforge.net).
cvs can manage multiple releases/branches of the sourcecode. e.g. if i commit some code to the release/branch HEAD, then i only changed the HEAD version of gallery.
HEAD is the main branch in cvs. if not stated otherwize, everything happens in HEAD, also if you use cvs to get the gallery sourcecode, you're getting the code from the HEAD release.
even if the version in cvs is not intended for production since we always commit our development changes to it, we keep HEAD as clean as possible and you should be able to use HEAD for a production website at anytime.
currently, we have a second active release, BRANCH_API_DEV because we're changing too much to still guarantee a 100% working g2 (well, even BRANCH_API_DEV is usable, but we find a few development bugs from time to time).
around new year, we'll merge the changes of BRANCH_API_DEV into HEAD and we'll stop using BRANCH_API_DEV and develop further directly on HEAD.
Posts: 757
A few more casting fixes:
modules/core/CoreModuleExtras.inc, _createAdminUser():
modules/core/CoreModuleExtras.inc, _createRootAlbumItem():
modules/core/classes/GalleryUser.class, save():
modules/core/classes/helpers/GalleryPermissionHelper_advanced.class, _getAccessListCompacterLock():
If you don't mind, please check them in too.
FYI, I'm now at a point in which the Gallery core installs successfully, but I get an ERROR_STORAGE_FAILURE error when I go to Step 10. I'll keep hacking at it tomorrow or the day after. I've been going continuously full-throttle on this for about 36 hours now... need a breather. And a few beer.
Posts: 32509
36h, lol. extreme
thanks for reporting.
as with the previous changes, i fixed it on a lower level, if possible. (but not in the map interfaces, since that code changes in BRANCH_API_DEV anyway).
Posts: 757
Valiant,
I now have the Installer completing successfully, but I happened to notice that I still get the following error in the install.log:
But I don't get a stack trace with it (presumably because it's considered non-fatal), so I don't know where to start tracking this.
Any suggestions?
Posts: 757
Ah, never mind, I found the stack trace in the log file.
Posts: 757
Hmm, the stack trrace doesn't seem to take me back far enough.
To fix this at the lowest level I need to find where the '$data' is set that is being passed into removeMapEntry().
Posts: 32509
modules/core/classes/helpers/GalleryUserGroupHelper_*.class
it's a little strange that remove user from group or something like that is called during install though.
Posts: 757
Thanks.
OK, I have the install completely working now, and the main.php runs without error.
However, even after I login with the admin id I am not given the option to create an album.
Any suggestions where to start looking, or should I just start with main.php and work my way through the code?
Posts: 32509
if you don't see "add items" in the left side item actions menu,
then you're not logged in. in a default installation (matrix theme,
no removed/added blocks), you should see "logout" in the upper right
corner (login changes to logout upon successful login) and you should
see the add items, add album, ... options in the left side menu.
Posts: 757
Trust me, I'm already very familiar with the process of logging in, and the resultant change of fields in the browser. In the last few months I've done so more times than I care to count. Like I said, "even after logging in...". My login does complete successfully, the indicators in the bottom-right corner do reflect my logged-in "lmenard" account, and I do have the "Site Admin" and "Logout" links in the top-right corner. So the login does seem to have worked according to those indicators, but I don't have the actions available in the left-hand side.
So what I'm asking is "Since you are much more intimately familiar with the flow of the application logic than I am (and given the symptoms described above), do you have any suggestions as to where in the code I should start to look?". Or should I just start in "main.php" and start tracing the hell out of it?
Posts: 32509
then it looks like that the matrix theme default blocks have not been properly added to the pluginParameterMap table during installation.
or they are there, but the select isn't working correctly.
check g2_PluginParameterMap pluginId = matrix for its parameters.
sidebarBlocks, albumBlocks, photoBlocks
they are set during installation, CoreModuleExtras.inc -> matrix theme installation + activation. they are set during activation.
modules/core/classes/GalleryTheme.class function activate calls $this->getSettings() which in turn calls $this->getStandardSettings() which was set by the constructor of themes/matrix/theme.inc .
the returned $settings are an array of key => value pairs and the sidebarBlocks value should be a serialized array = a string.
works all fine on mysql and pg etc. i just checked it and in activate -> setParameter, the values for the sidebarBlock is indeed a string (serialized array), so it should be fine.
-> check in g2_PluginParameterMap if g_pluginId = 'matrix', g_parameterName = 'sidebarBlocks' is present and if its value is a string.