New Install Feedback

Sébastien Le Callonnec <[email protected]> Mon, 10 May 2010 21:45:27 +0100
Newsgroups gmane.comp.web.wiki.phpwiki.talk
Message-ID <[email protected]>
Hi All,


As I have an old phpwiki installation that desperately needs an upgrade, 
I embarked on a journey to install the current version (1.3.14).  As 
some other users, I have experienced some serious troubles, but rather 
than moan and do nothing about it, I thought I'd share my experience 
with you.  All that follows is based on the current source code from svn 
trunk.

Ubuntu 10.04 install, with the following version of php:
sebastien@greystones:~$ php -v | grep ubuntu
PHP 5.3.2-1ubuntu4 with Suhosin-Patch (cli) (built: Apr  9 2010 08:18:14)

In a nutshell, it appears the automatic configuration is broken.

First, you have to manually touch the config files, and make them 
writable.  The reason for this is that dump_file in IniConfig uses 
is_writable which, according to the php docs, returns TRUE if the files 
exists and is writable.  So I had to do the following:

touch config-dist.php ; chmod 777 config-dist.php
touch config-default.php ; chmod 777 config-default.php
touch config.php ; chmod 777 config.php

The chmod is needed because I work under ~/public_html, which is not 
owned by the Apache user.  I remove the permissions after the install 
process.

Next, I had to do various changes to the installation script to get it 
to work -- I have attached these changes as a patch.

The first change is to display an error message when the files I created 
manually above are not "writable": this allows the user to understand 
what is going wrong.


I also had to add:
define('DEBUG', 0);
because define('DEBUG', 1); is commented out, but there was no other 
default value.


Then, I had to add an alias to _variable called _define in the _variable 
class as it is called (in particular) by numeric_define.  Finally, I 
have changed the configurator page to use utf-8 rather than latin-1 as 
some characters are encoded in UTF-8 (e.g. in the “Language” section). 
It might look “cosmetic”, but it is actually darn important because it 
is then used to dump the config file, or for copy-paste into config.ini.


For database set up, here is what I have done:
sebastien@greystones:~$ mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 54
Server version: 5.1.41-3ubuntu12 (Ubuntu)

Type 'help;' or '\h' for help. Type '\c' to clear the current input 
statement.

mysql> CREATE DATABASE phpwiki DEFAULT CHARACTER SET utf8 DEFAULT 
COLLATE utf8_unicode_ci;
Query OK, 1 row affected (0.00 sec)

mysql> Bye
sebastien@greystones:~$ mysql -u root -p phpwiki < 
~/public_html/phpwiki/schemas/mysql-initialize.sql
Enter password:

One of the issues here is that in the automatic installation, I had 
chosen to prefix table names with "phpwiki_", but the script obviously 
doesn't have this prefix.  Granted, there is a comment in config.ini 
that states that the script must be changed manually if you set a 
prefix, but as this file was generated automatically, I don't get to see 
this comment.  Ideally, the configurator should run the scripts for me, 
and cater for this prefix when required.


For some reason, “MySQL” was not appearing in the DB type list despite 
being in the list as possible options; modifying the loop as a foreach 
in _variable_selection::get_html() fixed that.


I now still have to successfully import my existing pages into a new 
install, and after a few attempts it looks like it won't be any stroll 
in the park either...

I think there is still a lot to be done to get a proper automated 
installation, but I hope my experience will help other users out there!


Regards,
Sébastien.
ps.- Sorry for the looooong email.

------------------------------------------------------------------------------

_______________________________________________
Phpwiki-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/phpwiki-talk
configurator.patch (text/x-patch, 5.5 KB)
Index: lib/IniConfig.php
===================================================================
--- lib/IniConfig.php	(revision 7388)
+++ lib/IniConfig.php	(working copy)
@@ -113,8 +113,8 @@
     // check config/config.php dump for faster startup
     $dump = substr($file, 0, -3)."php";
     if (isWindows($dump)) $dump = str_replace("/","\\",$dump);
-    if (file_exists($dump) and is_readable($dump) and sort_file_mtime($dump, $file) < 0) {
-        @include($dump);
+    if (file_exists($dump) and is_readable($dump) and filesize($dump) > 0 and sort_file_mtime($dump, $file) < 0) {
+        @include($dump) or die("Error including " . $dump);
         if (function_exists('wiki_configrestore') and (wiki_configrestore() === 'noerr')) {
             fixup_dynamic_configs();
             return;
@@ -545,6 +545,8 @@
     // The question is if reading this is faster then doing IniConfig() + fixup_static_configs()
     if (is_writable($dump)) {
         save_dump($dump);
+    } else {
+    	die($dump . " is not writable");
     }
     // store locale[] in config.php? This is too problematic.
     fixup_dynamic_configs($file); // [100ms]
Index: configurator.php
===================================================================
--- configurator.php	(revision 7388)
+++ configurator.php	(working copy)
@@ -150,21 +150,21 @@
 } else {
     if (!function_exists("IniConfig")) {
         include_once("lib/prepend.php");
-	include_once("lib/IniConfig.php");
+        include_once("lib/IniConfig.php");
     }
     $def_file = (substr(PHP_OS,0,3) == 'WIN') ? 'config\\config-default.ini' : 'config/config-default.ini';
     $fs_def_file = dirname(__FILE__) . (substr(PHP_OS,0,3) == 'WIN' ? '\\' : '/') . $def_file;
     IniConfig($fs_def_file);
 }
 
-echo '<','?xml version="1.0" encoding="iso-8859-1"?',">\n";
+echo '<','?xml version="1.0" encoding="utf-8"?',">\n";
 ?>
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml">
 <head>
 <!-- $Id$ -->
-<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 <title>Configuration tool for PhpWiki <?php echo $config_file ?></title>
 <style type="text/css" media="screen">
 <!--
@@ -173,7 +173,7 @@
 pre { font-size: 120%; }
 td { border: thin solid black }
 tr { border: none }
-div.hint { border: thin solid red, background-color: #eeeeee; }
+div.hint { background-color: #eeeeee; }
 tr.hidden { border: none; display: none; }
 td.part { background-color: #eeeeee; color: inherit; }
 td.instructions { background-color: #ffffee; width: <?php echo $tdwidth ?>px; color: inherit; }
@@ -272,6 +272,7 @@
 </div>
 
 <?php
+define('DEBUG', 0);
 //define('DEBUG', 1);
 /**
  * The Configurator is a php script to aid in the configuration of PhpWiki.
@@ -638,8 +639,7 @@
                     'mysqlt' => "mysqlt (only ADODB)",
                     'ODBC'   => "ODBC (only ADODB or PDO)",
                     'firebird' => "Firebird (only PDO)",
-                    'oracle'  => "Oracle (only PDO)",
-), "
+                    'oracle'  => "Oracle (only PDO)"), "
 SQL DB types. The DSN hosttype.");
 
 $properties["SQL User"] =
@@ -1718,6 +1718,10 @@
         else
 	    $this->prefix = "";
     }
+    
+    function _define($config_item_name, $default_value='', $description = '', $jscheck = '') {
+    	$this->_variable($config_item_name, $default_value, $description, $jscheck);
+    }
 
     function value() {
       global $HTTP_POST_VARS;
@@ -1852,8 +1856,9 @@
 	    $this->default_value = constant($this->get_config_item_name());
 	else
 	    $this->default_value = null;
-        while(list($option, $label) = each($values)) {
-	    if (!is_null($this->default_value) and $this->default_value === $option)
+
+        foreach ($values as $option => $label) {
+	    if (!is_null($this->default_value) && $this->default_value === $option)
 		$output .= "  <option value=\"$option\" selected=\"selected\">$label</option>\n";
 	    else
 		$output .= "  <option value=\"$option\">$label</option>\n";
@@ -2228,29 +2233,6 @@
     }
 }
 
-/*
-class _ini_set
-extends _variable {
-    function value() {
-        global $HTTP_POST_VARS;
-        if ($v = $HTTP_POST_VARS[$this->config_item_name])
-            return $v;
-        else {
-	    return ini_get($this->get_config_item_name);
-        }
-    }
-    function _config_format($value) {
-        return sprintf("ini_set('%s', '%s');", $this->get_config_item_name(), $value);
-    }
-    function _get_config_line($posted_value) {
-        if ($posted_value && ! $posted_value == $this->default_value)
-            return "\n" . $this->_config_format($posted_value);
-        else
-            return "\n;" . $this->_config_format($this->default_value);
-    }
-}
-*/
-
 class boolean_define
 extends _define {
 
@@ -2505,7 +2487,7 @@
     }
     
     if ($fp) {
-        fputs($fp, $config);
+        fputs($fp, utf8_encode($config));
         fclose($fp);
         echo "<p>The configuration was written to <code><b>$config_file</b></code>.</p>\n";
         if ($new_filename) {
@@ -2522,7 +2504,7 @@
     echo "<hr />\n<p>Here's the configuration file based on your answers:</p>\n";
     echo "<form method=\"get\" action=\"", $configurator, "\">\n";
     echo "<textarea id='config-output' readonly='readonly' style='width:100%;' rows='30' cols='100'>\n";
-    echo htmlentities($config);
+    echo htmlentities($config, ENT_COMPAT, "UTF-8");
     echo "</textarea></form>\n";
     echo "<hr />\n";