[MediaWiki-commits] [Gerrit] Split out WikiPage 'page' field for EditPage - change (mediawiki/core)

2015-11-25 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged.

Change subject: Split out WikiPage 'page' field for EditPage
..


Split out WikiPage 'page' field for EditPage

* This fixes numerous IDEA warnings
* Also fixed some other warnings by fixing documentation

Change-Id: I2a76ce79c0d04a28a6cd74116dfce4e67435f44a
---
M includes/EditPage.php
M includes/page/WikiPage.php
2 files changed, 29 insertions(+), 19 deletions(-)

Approvals:
  Legoktm: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/EditPage.php b/includes/EditPage.php
index 2bddc3e..96db74d 100644
--- a/includes/EditPage.php
+++ b/includes/EditPage.php
@@ -201,6 +201,8 @@
 
/** @var Article */
public $mArticle;
+   /** @var WikiPage */
+   private $page;
 
/** @var Title */
public $mTitle;
@@ -399,6 +401,7 @@
 */
public function __construct( Article $article ) {
$this->mArticle = $article;
+   $this->page = $article->getPage(); // model object
$this->mTitle = $article->getTitle();
 
$this->contentModel = $this->mTitle->getContentModel();
@@ -1002,6 +1005,7 @@
 * for saving, preview parsing and so on...
 *
 * @param WebRequest $request
+* @return string|null
 */
protected function importContentFormData( &$request ) {
return; // Don't do anything, EditPage already extracted 
wpTextbox1
@@ -1014,7 +1018,7 @@
 */
function initialiseForm() {
global $wgUser;
-   $this->edittime = $this->mArticle->getTimestamp();
+   $this->edittime = $this->page->getTimestamp();
 
$content = $this->getContentObject( false ); # TODO: track 
content object?!
if ( $content === false ) {
@@ -1098,13 +1102,13 @@
!$undorev->isDeleted( 
Revision::DELETED_TEXT ) &&
!$oldrev->isDeleted( 
Revision::DELETED_TEXT )
) {
-   $content = 
$this->mArticle->getUndoContent( $undorev, $oldrev );
+   $content = 
$this->page->getUndoContent( $undorev, $oldrev );
 
if ( $content === false ) {
# Warn the user that 
something went wrong
$undoMsg = 'failure';
} else {
-   $oldContent = 
$this->mArticle->getPage()->getContent( Revision::RAW );
+   $oldContent = 
$this->page->getContent( Revision::RAW );
$popts = 
ParserOptions::newFromUserAndLang( $wgUser, $wgContLang );
$newContent = 
$content->preSaveTransform( $this->mTitle, $wgUser, $popts );
 
@@ -1207,7 +1211,7 @@
 * @return Content
 */
protected function getCurrentContent() {
-   $rev = $this->mArticle->getRevision();
+   $rev = $this->page->getRevision();
$content = $rev ? $rev->getContent( Revision::RAW ) : null;
 
if ( $content === false || $content === null ) {
@@ -1337,7 +1341,7 @@
 * @param int $statusValue The status value (to check for new article 
status)
 */
protected function setPostEditCookie( $statusValue ) {
-   $revisionId = $this->mArticle->getLatest();
+   $revisionId = $this->page->getLatest();
$postEditKey = self::POST_EDIT_COOKIE_KEY_PREFIX . $revisionId;
 
$val = 'saved';
@@ -1760,8 +1764,8 @@
 
# Load the page data from the master. If anything changes in 
the meantime,
# we detect it by using page_latest like a token in a 1 try 
compare-and-swap.
-   $this->mArticle->loadPageData( 'fromdbmaster' );
-   $new = !$this->mArticle->exists();
+   $this->page->loadPageData( 'fromdbmaster' );
+   $new = !$this->page->exists();
 
if ( $new ) {
// Late check for create permission, just in case 
*PARANOIA*
@@ -1813,16 +1817,16 @@
 
# Article exists. Check for edit conflict.
 
-   $this->mArticle->clear(); # Force reload of dates, etc.
-   $timestamp = $this->mArticle->getTimestamp();
+   $this->page->clear(); # Force reload of dates, etc.
+   $timestamp = $this->page->getTimestamp();
 
wfDebug( "timestamp: {$timestamp}, edittime: 

[MediaWiki-commits] [Gerrit] Split out WikiPage 'page' field for EditPage - change (mediawiki/core)

2015-11-24 Thread Aaron Schulz (Code Review)
Aaron Schulz has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/255266

Change subject: Split out WikiPage 'page' field for EditPage
..

Split out WikiPage 'page' field for EditPage

* This fixes numerous IDEA warnings
* Also fixed some other warnings by fixing documentation

Change-Id: I2a76ce79c0d04a28a6cd74116dfce4e67435f44a
---
M includes/EditPage.php
M includes/page/WikiPage.php
2 files changed, 29 insertions(+), 19 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/66/255266/1

diff --git a/includes/EditPage.php b/includes/EditPage.php
index 2bddc3e..96db74d 100644
--- a/includes/EditPage.php
+++ b/includes/EditPage.php
@@ -201,6 +201,8 @@
 
/** @var Article */
public $mArticle;
+   /** @var WikiPage */
+   private $page;
 
/** @var Title */
public $mTitle;
@@ -399,6 +401,7 @@
 */
public function __construct( Article $article ) {
$this->mArticle = $article;
+   $this->page = $article->getPage(); // model object
$this->mTitle = $article->getTitle();
 
$this->contentModel = $this->mTitle->getContentModel();
@@ -1002,6 +1005,7 @@
 * for saving, preview parsing and so on...
 *
 * @param WebRequest $request
+* @return string|null
 */
protected function importContentFormData( &$request ) {
return; // Don't do anything, EditPage already extracted 
wpTextbox1
@@ -1014,7 +1018,7 @@
 */
function initialiseForm() {
global $wgUser;
-   $this->edittime = $this->mArticle->getTimestamp();
+   $this->edittime = $this->page->getTimestamp();
 
$content = $this->getContentObject( false ); # TODO: track 
content object?!
if ( $content === false ) {
@@ -1098,13 +1102,13 @@
!$undorev->isDeleted( 
Revision::DELETED_TEXT ) &&
!$oldrev->isDeleted( 
Revision::DELETED_TEXT )
) {
-   $content = 
$this->mArticle->getUndoContent( $undorev, $oldrev );
+   $content = 
$this->page->getUndoContent( $undorev, $oldrev );
 
if ( $content === false ) {
# Warn the user that 
something went wrong
$undoMsg = 'failure';
} else {
-   $oldContent = 
$this->mArticle->getPage()->getContent( Revision::RAW );
+   $oldContent = 
$this->page->getContent( Revision::RAW );
$popts = 
ParserOptions::newFromUserAndLang( $wgUser, $wgContLang );
$newContent = 
$content->preSaveTransform( $this->mTitle, $wgUser, $popts );
 
@@ -1207,7 +1211,7 @@
 * @return Content
 */
protected function getCurrentContent() {
-   $rev = $this->mArticle->getRevision();
+   $rev = $this->page->getRevision();
$content = $rev ? $rev->getContent( Revision::RAW ) : null;
 
if ( $content === false || $content === null ) {
@@ -1337,7 +1341,7 @@
 * @param int $statusValue The status value (to check for new article 
status)
 */
protected function setPostEditCookie( $statusValue ) {
-   $revisionId = $this->mArticle->getLatest();
+   $revisionId = $this->page->getLatest();
$postEditKey = self::POST_EDIT_COOKIE_KEY_PREFIX . $revisionId;
 
$val = 'saved';
@@ -1760,8 +1764,8 @@
 
# Load the page data from the master. If anything changes in 
the meantime,
# we detect it by using page_latest like a token in a 1 try 
compare-and-swap.
-   $this->mArticle->loadPageData( 'fromdbmaster' );
-   $new = !$this->mArticle->exists();
+   $this->page->loadPageData( 'fromdbmaster' );
+   $new = !$this->page->exists();
 
if ( $new ) {
// Late check for create permission, just in case 
*PARANOIA*
@@ -1813,16 +1817,16 @@
 
# Article exists. Check for edit conflict.
 
-   $this->mArticle->clear(); # Force reload of dates, etc.
-   $timestamp = $this->mArticle->getTimestamp();
+   $this->page->clear(); # Force reload of dates, etc.
+   $timestamp = $this->page->getTimestamp();