Thanks to Edfel who send me his books database, I was able to test the
upgrade procedure with a database including a lot of categories,
subcategories and books. This lead to the discovery of 2 more bugs in
pninit.php ( a missing single quote and a wrong typecasting to int)
I have corrected these bugs in the CVS.
If you want to test upgrading from books .750, you need pninit.php
version 1.8 or more
Also looking at Edfel database revealed that some of you have a .750RC4
or .750RC5 books version but already have the code and pubdate fields in
the books_books, books_modrequest and books_newbook tables
If you are in this case, the easiest way to manage this situation is to
comment or delete all the lines:
//new fields for pubdate and code added
$dbconn =& pnDBGetConn(true);
$pntable =& pnDBGetTables();
$table = $pntable[books_books];
$templatecolumn = &$pntable['books_books_column'];
$sql = "ALTER TABLE $table
ADD ".$templatecolumn['pubdate']." date DEFAULT
'0000-00-00' NOT NULL";
$dbconn->Execute($sql);
if ($dbconn->ErrorNo() != 0) {
pnSessionSetVar('errormsg', _UPDATETABLEFAILED .
$templatecolumn['pubdate'] . ' error ' . $dbconn->ErrorMsg());
return false;
}
$sql = "ALTER TABLE $table
ADD ".$templatecolumn['code']." varchar(150)";
$dbconn->Execute($sql);
if ($dbconn->ErrorNo() != 0) {
pnSessionSetVar('errormsg', _UPDATETABLEFAILED .
$templatecolumn['code'] . ' error ' . $dbconn->ErrorMsg());
return false;
}
$table = $pntable[books_modrequest];
$templatecolumn = &$pntable['books_modrequest_column'];
$sql = "ALTER TABLE $table
ADD ".$templatecolumn['pubdate']." date DEFAULT
'0000-00-00' NOT NULL";
$dbconn->Execute($sql);
if ($dbconn->ErrorNo() != 0) {
pnSessionSetVar('errormsg', _UPDATETABLEFAILED .
$templatecolumn['pubdate'] . ' error ' . $dbconn->ErrorMsg());
return false;
}
$sql = "ALTER TABLE $table
ADD ".$templatecolumn['code']." varchar(150)";
$dbconn->Execute($sql);
if ($dbconn->ErrorNo() != 0) {
pnSessionSetVar('errormsg', _UPDATETABLEFAILED .
$templatecolumn['code'] . ' error ' . $dbconn->ErrorMsg());
return false;
}
$table = $pntable[books_newbook];
$templatecolumn = &$pntable['books_newbook_column'];
$sql = "ALTER TABLE $table
ADD ".$templatecolumn['pubdate']." date DEFAULT
'0000-00-00' NOT NULL";
$dbconn->Execute($sql);
if ($dbconn->ErrorNo() != 0) {
pnSessionSetVar('errormsg', _UPDATETABLEFAILED .
$templatecolumn['pubdate'] . ' error ' . $dbconn->ErrorMsg());
return false;
}
$sql = "ALTER TABLE $table
ADD ".$templatecolumn['code']." varchar(150)";
$dbconn->Execute($sql);
if ($dbconn->ErrorNo() != 0) {
pnSessionSetVar('errormsg', _UPDATETABLEFAILED .
$templatecolumn['code'] . ' error ' . $dbconn->ErrorMsg());
return false;
}
in the modules/books/pninit.php file BEFORE attempting the upgrade. This
will prevent the module from sopping the upgrade complaining that these
fields already exist.
I must be the culprit of this situation because I think I had a wrong
pnversion.php file at some time !!
I will look into adding lines to test if these fields exist before
attempting to create them.