Don't try to get newtimestamp from edit if no change was made

ApiEditPage can give us 'nochange' instead of the
'oldrevid'/'newrevid'/'newtimestamp' keys if we gave it a null edit.

Bug: 73463
Change-Id: Ic22597dfed11de3823471673404090a9bce12928
This commit is contained in:
Alex Monk 2014-11-17 01:00:06 +00:00
parent fce0ed5d6c
commit ff3d76f488
2 changed files with 19 additions and 12 deletions

View file

@ -153,12 +153,15 @@ class ApiVisualEditorEdit extends ApiVisualEditor {
}
$lang = $this->getLanguage();
if ( isset( $saveresult['edit']['newtimestamp'] ) ) {
$ts = $saveresult['edit']['newtimestamp'];
$result['lastModified'] = array(
'date' => $lang->userDate( $ts, $user ),
'time' => $lang->userTime( $ts, $user )
);
}
if ( isset( $saveresult['edit']['newrevid'] ) ) {
$result['newrevid'] = intval( $saveresult['edit']['newrevid'] );

View file

@ -436,7 +436,8 @@ ve.init.mw.ViewPageTarget.prototype.onSurfaceReady = function () {
* @param {number} newid New revision id, undefined if unchanged
* @param {boolean} isRedirect Whether this page is a redirect or not
* @param {string} displayTitle What HTML to show as the page title
* @param {Object} lastModified Object containing user-formatted date and time strings
* @param {Object} lastModified Object containing user-formatted date
and time strings, or undefined if we made no change.
*/
ve.init.mw.ViewPageTarget.prototype.onSave = function (
html, categoriesHtml, newid, isRedirect, displayTitle, lastModified, contentSub
@ -1528,7 +1529,8 @@ ve.init.mw.ViewPageTarget.prototype.onWindowPopState = function ( e ) {
* @param {string} html Rendered HTML from server
* @param {string} categoriesHtml Rendered categories HTML from server
* @param {string} displayTitle What HTML to show as the page title
* @param {Object} lastModified Object containing user-formatted date and time strings
* @param {Object} lastModified Object containing user-formatted date
and time strings, or undefined if we made no change.
* @param {string} contentSub What HTML to show as the content subtitle
*/
ve.init.mw.ViewPageTarget.prototype.replacePageContent = function (
@ -1536,11 +1538,13 @@ ve.init.mw.ViewPageTarget.prototype.replacePageContent = function (
) {
var $content = $( $.parseHTML( html ) ), $editableContent;
if ( lastModified ) {
$( '#footer-info-lastmod' ).text( ' ' + mw.msg(
'lastmodifiedat',
lastModified.date,
lastModified.time
) );
}
if ( $( '#mw-imagepage-content' ).length ) {
// On file pages, we only want to replace the (local) description.