# HG changeset patch
# User Dan
# Date 1242222237 14400
# Node ID d894086f38ccceee0e34668e492bfe6ef7004488
# Parent 0506adb8eb6cab0b4bd2efe8ff86e68dd03dcf11
Fixed behavior of log display and title fetch for nonexistent pages
diff -r 0506adb8eb6c -r d894086f38cc includes/namespaces/default.php
--- a/includes/namespaces/default.php Wed May 13 09:43:00 2009 -0400
+++ b/includes/namespaces/default.php Wed May 13 09:43:57 2009 -0400
@@ -142,8 +142,9 @@
$this->exists = false;
$ns_char = substr($paths->nslist['Special'], -1);
-
$page_name = $this->namespace == 'Article' ? dirtify_page_id($this->page_id) : "{$this->namespace}{$ns_char}" . dirtify_page_id($this->page_id);
+ $this->title = $page_name;
+
$this->cdata = array(
'name' => $page_name,
'urlname' => $this->page_id,
@@ -735,16 +736,7 @@
$html .= '';
$html .= '
' . $lang->get('catedit_catbox_lbl_categories') . ' ';
- $where = '( c.page_id=\'' . $db->escape($this->page_id) . '\' AND c.namespace=\'' . $db->escape($this->namespace) . '\' )';
- $prefix = table_prefix;
- $sql = <<
sql_query($sql);
+ $q = $db->sql_query('SELECT category_id FROM ' . table_prefix . "categories WHERE page_id = '$this->page_id' AND namespace = '$this->namespace';");
if ( !$q )
$db->_die();
@@ -945,7 +937,17 @@
$page_id_db = $db->escape($page_id);
$namespace_db = $db->escape($namespace);
- $q = $db->sql_query('SELECT * FROM ' . table_prefix . "pages WHERE urlname = '$page_id_db' AND namespace = '$namespace_db';");
+ $q = $db->sql_query('SELECT p.*, COUNT(ca.comment_id) AS comments_approved, COUNT(cu.comment_id) AS comments_unapproved, COUNT(cs.comment_id) AS comments_spam'
+ . ' FROM ' . table_prefix . "pages AS p\n"
+ . " LEFT JOIN " . table_prefix . "comments AS ca\n"
+ . " ON ( (ca.approved = " . COMMENT_APPROVED . " AND ca.page_id = p.urlname ) OR ca.comment_id IS NULL)\n"
+ . " LEFT JOIN " . table_prefix . "comments AS cu\n"
+ . " ON ( (cu.approved = " . COMMENT_UNAPPROVED . " AND cu.page_id = p.urlname ) OR cu.comment_id IS NULL)\n"
+ . " LEFT JOIN " . table_prefix . "comments AS cs\n"
+ . " ON ( (cs.approved = " . COMMENT_SPAM . " AND cs.page_id = p.urlname ) OR cs.comment_id IS NULL)\n"
+ . " WHERE p.urlname = '$page_id_db' AND p.namespace = '$namespace_db'\n"
+ . " GROUP BY p.urlname, p.name, p.namespace, p.page_order, p.special, p.visible, p.protected, p.wiki_mode, p.comments_on, p.delvotes, p.delvote_ips, p.page_format, p.password;");
+
if ( !$q )
$db->_die();
diff -r 0506adb8eb6c -r d894086f38cc includes/namespaces/user.php
--- a/includes/namespaces/user.php Wed May 13 09:43:00 2009 -0400
+++ b/includes/namespaces/user.php Wed May 13 09:43:57 2009 -0400
@@ -14,6 +14,21 @@
class Namespace_User extends Namespace_Default
{
+ public function __construct($page_id, $namespace, $revision_id = 0)
+ {
+ global $db, $session, $paths, $template, $plugins; // Common objects
+ global $lang;
+
+ parent::__construct($page_id, $namespace, $revision_id);
+
+ if ( ( $this->title == str_replace('_', ' ', $this->page_id) || $this->title == $paths->nslist['User'] . str_replace('_', ' ', $this->page_id) ) || !$this->exists )
+ {
+ $this->title = $lang->get('userpage_page_title', array('username' => $this->page_id));
+ $this->cdata['name'] = $this->title;
+ }
+
+ }
+
public function send()
{
global $db, $session, $paths, $template, $plugins; // Common objects
@@ -55,10 +70,8 @@
*
* See plugins.php for a guide on creating and attaching to hooks.
*/
-
+
$page_urlname = dirtify_page_id($this->page_id);
- if ( $this->page_id == $paths->page_id && $this->namespace == $paths->namespace )
- $page_name = $this->cdata['name'];
$target_username = strtr($page_urlname,
Array(
@@ -70,13 +83,7 @@
$target_username = preg_replace('/^' . str_replace('/', '\\/', preg_quote($paths->nslist['User'])) . '/', '', $target_username);
list($target_username) = explode('/', $target_username);
- if ( ( $page_name == str_replace('_', ' ', $this->page_id) || $page_name == $paths->nslist['User'] . str_replace('_', ' ', $this->page_id) ) || !$this->exists )
- {
- $page_name = $lang->get('userpage_page_title', array('username' => $target_username));
- }
-
- $output->set_title($page_name);
-
+ $output->set_title($this->title);
$q = $db->sql_query('SELECT u.username, u.user_id AS authoritative_uid, u.real_name, u.email, u.reg_time, u.user_has_avatar, u.avatar_type, x.*, COUNT(c.comment_id) AS n_comments
FROM '.table_prefix.'users u
LEFT JOIN '.table_prefix.'users_extra AS x
diff -r 0506adb8eb6c -r d894086f38cc plugins/SpecialLog.php
--- a/plugins/SpecialLog.php Wed May 13 09:43:00 2009 -0400
+++ b/plugins/SpecialLog.php Wed May 13 09:43:57 2009 -0400
@@ -311,7 +311,10 @@
$crumb = $lang->get('log_breadcrumb_author', array('user' => $user_link));
break;
case 'page':
- $crumb = $lang->get('log_breadcrumb_page', array('page' => '' . htmlspecialchars(get_page_title($value)) . ''));
+ list($pid, $ns) = RenderMan::strToPageID($value);
+ $ns = namespace_factory($pid, $ns);
+ $exist = $ns->exists() ? '' : ' class="wikilink-nonexistent"';
+ $crumb = $lang->get('log_breadcrumb_page', array('page' => '' . htmlspecialchars($ns->title) . ''));
break;
case 'action':
$action = ( $lang->get("log_formaction_{$value}") === "log_formaction_{$value}" ) ? $lang->get("log_action_{$value}") : $lang->get("log_formaction_{$value}");