Changed all urlname/page_id columns to varchar(255) because 63 characters just isn't long enough
authorDan
Fri, 23 Nov 2007 17:59:24 -0500
changeset 228 7846d45bd250
parent 227 0f039028f7a5
child 229 b2f985e4cef3
Changed all urlname/page_id columns to varchar(255) because 63 characters just isn't long enough
includes/pageprocess.php
includes/pageutils.php
index.php
plugins/SpecialPageFuncs.php
schema.sql
upgrade.sql
--- a/includes/pageprocess.php	Thu Nov 22 02:10:12 2007 -0500
+++ b/includes/pageprocess.php	Fri Nov 23 17:59:24 2007 -0500
@@ -617,6 +617,7 @@
     global $db, $session, $paths, $template, $plugins; // Common objects
     global $email;
     
+    $page_urlname = dirtify_page_id($this->page_id);
     if ( $this->page_id == $paths->cpage['urlname_nons'] && $this->namespace == $paths->namespace )
     {
       $page_name = ( isset($paths->cpage['name']) ) ? $paths->cpage['name'] : $this->page_id;
@@ -626,7 +627,7 @@
       $page_name = ( isset($paths->pages[$this->page_id]) ) ? $paths->pages[$this->page_id]['name'] : $this->page_id;
     }
     
-    $target_username = strtr($page_name, 
+    $target_username = strtr($page_urlname, 
       Array(
         '_' => ' ',
         '<' => '&lt;',
--- a/includes/pageutils.php	Thu Nov 22 02:10:12 2007 -0500
+++ b/includes/pageutils.php	Fri Nov 23 17:59:24 2007 -0500
@@ -623,8 +623,8 @@
         {
           $rc = '';
         }
-        echo '<td class="' . $cls . '"' . $rc . '><a href="'.makeUrlNS('User', $r['author']).'" ';
-        if ( !isPage($paths->nslist['User'] . $r['author']) )
+        echo '<td class="' . $cls . '"' . $rc . '><a href="'.makeUrlNS('User', sanitize_page_id($r['author'])).'" ';
+        if ( !isPage($paths->nslist['User'] . sanitize_page_id($r['author'])) )
         {
           echo 'class="wikilink-nonexistent"';
         }
@@ -672,8 +672,8 @@
         echo '<td class="' . $cls . '">' . $r['date_string'] . '</td class="' . $cls . '">';
         
         // User
-        echo '<td class="' . $cls . '"><a href="'.makeUrlNS('User', $r['author']).'" ';
-        if(!isPage($paths->nslist['User'] . $r['author'])) echo 'class="wikilink-nonexistent"';
+        echo '<td class="' . $cls . '"><a href="'.makeUrlNS('User', sanitize_page_id($r['author'])).'" ';
+        if(!isPage($paths->nslist['User'] . sanitize_page_id($r['author']))) echo 'class="wikilink-nonexistent"';
         echo '>' . $r['author'] . '</a></td class="' . $cls . '">';
         
         
@@ -1020,7 +1020,7 @@
         
         // Determine the name, and whether to link to the user page or not
         $name = '';
-        if($row['user_id'] > 0) $name .= '<a href="'.makeUrlNS('User', str_replace(' ', '_', $row['name'])).'">';
+        if($row['user_id'] > 0) $name .= '<a href="'.makeUrlNS('User', sanitize_page_id(' ', '_', $row['name'])).'">';
         $name .= $row['name'];
         if($row['user_id'] > 0) $name .= '</a>';
         $strings['NAME'] = $name; unset($name);
--- a/index.php	Thu Nov 22 02:10:12 2007 -0500
+++ b/index.php	Fri Nov 23 17:59:24 2007 -0500
@@ -54,7 +54,7 @@
   switch($_GET['do'])
   {
     default:
-      die_friendly('Invalid action', '<p>The action "'.$_GET['do'].'" is not defined. Return to <a href="'.makeUrl($paths->page).'">viewing this page\'s text</a>.</p>');
+      die_friendly('Invalid action', '<p>The action "'.htmlspecialchars($_GET['do']).'" is not defined. Return to <a href="'.makeUrl($paths->page).'">viewing this page\'s text</a>.</p>');
       break;
     case 'view':
       // echo PageUtils::getpage($paths->page, true, ( (isset($_GET['oldid'])) ? $_GET['oldid'] : false ));
@@ -117,10 +117,18 @@
       $template->footer();
       break;
     case 'edit':
-      if(isset($_POST['_cancel'])) { header('Location: '.makeUrl($paths->page)); echo '<html><head><title>Redirecting...</title></head><body>If you haven\'t been redirected yet, <a href="'.makeUrl($paths->page).'">click here</a>.'; break; }
-      if(isset($_POST['_save'])) {
+      if(isset($_POST['_cancel']))
+      {
+        redirect(makeUrl($paths->page), '', '', 0);
+        break;
+      }
+      if(isset($_POST['_save']))
+      {
         $e = PageUtils::savepage($paths->cpage['urlname_nons'], $paths->namespace, $_POST['page_text'], $_POST['edit_summary'], isset($_POST['minor']));
-        header('Location: '.makeUrl($paths->page)); echo '<html><head><title>Redirecting...</title></head><body>If you haven\'t been redirected yet, <a href="'.makeUrl($paths->page).'">click here</a>.'; break;
+        if ( $e == 'good' )
+        {
+          redirect(makeUrl($paths->page), 'Changes saved', 'Your changes to this page have been saved. Redirecting...', 3);
+        }
       }
       $template->header();
       if(isset($_POST['_preview']))
--- a/plugins/SpecialPageFuncs.php	Thu Nov 22 02:10:12 2007 -0500
+++ b/plugins/SpecialPageFuncs.php	Fri Nov 23 17:59:24 2007 -0500
@@ -172,6 +172,7 @@
     exit;
   }
   $template->header();
+  /*
   if ( !$session->get_permissions('create_page') )
   {
     echo 'Wiki mode is disabled, only admins can create pages.';
@@ -181,6 +182,7 @@
     
     exit;
   }
+  */
   echo RenderMan::render('Using the form below you can create a page.');
   ?>
   <form action="" method="post">
--- a/schema.sql	Thu Nov 22 02:10:12 2007 -0500
+++ b/schema.sql	Fri Nov 23 17:59:24 2007 -0500
@@ -49,7 +49,7 @@
 ) CHARACTER SET `utf8` COLLATE `utf8_bin`;
 
 CREATE TABLE {{TABLE_PREFIX}}page_text(
-  page_id varchar(63),
+  page_id varchar(255),
   namespace varchar(16) NOT NULL default 'Article',
   page_text text,
   char_tag varchar(63),
@@ -58,8 +58,8 @@
 
 CREATE TABLE {{TABLE_PREFIX}}pages(
   page_order int(8),
-  name varchar(127),
-  urlname varchar(63),
+  name varchar(255),
+  urlname varchar(255),
   namespace varchar(16) NOT NULL default 'Article',
   special tinyint(1) default '0',
   visible tinyint(1) default '1',
--- a/upgrade.sql	Thu Nov 22 02:10:12 2007 -0500
+++ b/upgrade.sql	Fri Nov 23 17:59:24 2007 -0500
@@ -14,6 +14,9 @@
 ALTER TABLE {{TABLE_PREFIX}}search_index COLLATE = utf8_bin, MODIFY COLUMN word varchar(64) NOT NULL;
 -- The search cache is no longer needed because of the new unified search engine
 @DROP TABLE {{TABLE_PREFIX}}search_cache;
+-- Yes, it appears we need pages with names this long after all
+ALTER TABLE {{TABLE_PREFIX}}pages MODIFY COLUMN urlname varchar(255), MODIFY COLUMN name varchar(255);
+ALTER TABLE {{TABLE_PREFIX}}page_text MODIFY COLUMN page_id varchar(255);
 ---END 1.0.2b1---
 ---BEGIN 1.0.1.1---
 ---END 1.0.1.1---