From 0c3dc9223fe3cb6e4664db32b7576545bbb25518 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Sun, 6 Feb 2005 07:28:21 +0000 Subject: [PATCH] * (bug 1430) Don't check for template data when editing page that doesn't exist patch from zigger --- includes/Article.php | 6 +++++- includes/EditPage.php | 33 ++++++++++++++++++--------------- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/includes/Article.php b/includes/Article.php index 79c0eb0e22..bff74f09a3 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -479,12 +479,16 @@ class Article { if ( -1 != $this->mUser ) return; + # New or non-existent articles have no user information + $id = $this->getID(); + if ( 0 == $id ) return; + $fname = 'Article::loadLastEdit'; $dbr =& $this->getDB(); $s = $dbr->selectRow( array( 'revision', 'page') , array( 'rev_user','rev_user_text','rev_timestamp', 'rev_comment','rev_minor_edit' ), - array( 'page_id' => $this->getID(), 'page_latest=rev_id' ), $fname, $this->getSelectOptions() ); + array( 'page_id' => $id, 'page_latest=rev_id' ), $fname, $this->getSelectOptions() ); if ( $s !== false ) { $this->mUser = $s->rev_user; diff --git a/includes/EditPage.php b/includes/EditPage.php index f645af164d..95e59c84ee 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -580,24 +580,27 @@ class EditPage { $wgOut->setOnloadHandler( 'document.editform.wpTextbox1.focus()' ); } # Prepare a list of templates used by this page - $db =& wfGetDB( DB_SLAVE ); - $page = $db->tableName( 'page' ); - $links = $db->tableName( 'links' ); + $templates = ''; $id = $this->mTitle->getArticleID(); - $sql = "SELECT page_namespace,page_title,page_id ". - "FROM $page,$links WHERE l_to=page_id AND l_from={$id} and page_namespace=".NS_TEMPLATE; - $res = $db->query( $sql, "EditPage::editform" ); - - if ( $db->numRows( $res ) ) { - $templates = '
'. wfMsg( 'templatesused' ) . ''; - } else { - $templates = ''; } global $wgLivePreview, $wgStylePath; -- 2.20.1