2014-11-20 00:33:51 +00:00
|
|
|
<?php
|
|
|
|
|
/**
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
|
|
|
|
*
|
|
|
|
|
* @file
|
|
|
|
|
* @author Aaron Schulz
|
|
|
|
|
*/
|
|
|
|
|
|
2015-12-04 22:18:07 +00:00
|
|
|
use MediaWiki\Logger\LoggerFactory;
|
|
|
|
|
|
2014-11-20 00:33:51 +00:00
|
|
|
/**
|
2015-09-21 14:31:01 +00:00
|
|
|
* Prepare an edit in shared cache so that it can be reused on edit
|
2014-11-20 00:33:51 +00:00
|
|
|
*
|
|
|
|
|
* This endpoint can be called via AJAX as the user focuses on the edit
|
|
|
|
|
* summary box. By the time of submission, the parse may have already
|
|
|
|
|
* finished, and can be immediately used on page save. Certain parser
|
|
|
|
|
* functions like {{REVISIONID}} or {{CURRENTTIME}} may cause the cache
|
|
|
|
|
* to not be used on edit. Template and files used are check for changes
|
|
|
|
|
* since the output was generated. The cache TTL is also kept low for sanity.
|
|
|
|
|
*
|
|
|
|
|
* @ingroup API
|
|
|
|
|
* @since 1.25
|
|
|
|
|
*/
|
|
|
|
|
class ApiStashEdit extends ApiBase {
|
2015-03-26 21:19:39 +00:00
|
|
|
const ERROR_NONE = 'stashed';
|
|
|
|
|
const ERROR_PARSE = 'error_parse';
|
|
|
|
|
const ERROR_CACHE = 'error_cache';
|
|
|
|
|
const ERROR_UNCACHEABLE = 'uncacheable';
|
|
|
|
|
|
2016-05-06 12:33:54 +00:00
|
|
|
const PRESUME_FRESH_TTL_SEC = 30;
|
2016-06-08 10:23:39 +00:00
|
|
|
const MAX_CACHE_TTL = 300; // 5 minutes
|
2016-04-27 22:43:38 +00:00
|
|
|
|
2014-11-20 00:33:51 +00:00
|
|
|
public function execute() {
|
|
|
|
|
$user = $this->getUser();
|
|
|
|
|
$params = $this->extractRequestParams();
|
|
|
|
|
|
2016-05-26 19:04:22 +00:00
|
|
|
if ( $user->isBot() ) { // sanity
|
|
|
|
|
$this->dieUsage( 'This interface is not supported for bots', 'botsnotsupported' );
|
|
|
|
|
}
|
|
|
|
|
|
2014-11-20 00:33:51 +00:00
|
|
|
$page = $this->getTitleOrPageId( $params );
|
|
|
|
|
$title = $page->getTitle();
|
|
|
|
|
|
|
|
|
|
if ( !ContentHandler::getForModelID( $params['contentmodel'] )
|
|
|
|
|
->isSupportedFormat( $params['contentformat'] )
|
|
|
|
|
) {
|
2016-03-08 08:04:45 +00:00
|
|
|
$this->dieUsage( 'Unsupported content model/format', 'badmodelformat' );
|
2014-11-20 00:33:51 +00:00
|
|
|
}
|
|
|
|
|
|
2014-12-09 21:48:17 +00:00
|
|
|
// Trim and fix newlines so the key SHA1's match (see RequestContext::getText())
|
|
|
|
|
$text = rtrim( str_replace( "\r\n", "\n", $params['text'] ) );
|
2014-11-20 00:33:51 +00:00
|
|
|
$textContent = ContentHandler::makeContent(
|
|
|
|
|
$text, $title, $params['contentmodel'], $params['contentformat'] );
|
|
|
|
|
|
|
|
|
|
$page = WikiPage::factory( $title );
|
|
|
|
|
if ( $page->exists() ) {
|
|
|
|
|
// Page exists: get the merged content with the proposed change
|
|
|
|
|
$baseRev = Revision::newFromPageId( $page->getId(), $params['baserevid'] );
|
|
|
|
|
if ( !$baseRev ) {
|
|
|
|
|
$this->dieUsage( "No revision ID {$params['baserevid']}", 'missingrev' );
|
|
|
|
|
}
|
|
|
|
|
$currentRev = $page->getRevision();
|
|
|
|
|
if ( !$currentRev ) {
|
|
|
|
|
$this->dieUsage( "No current revision of page ID {$page->getId()}", 'missingrev' );
|
|
|
|
|
}
|
|
|
|
|
// Merge in the new version of the section to get the proposed version
|
|
|
|
|
$editContent = $page->replaceSectionAtRev(
|
|
|
|
|
$params['section'],
|
|
|
|
|
$textContent,
|
|
|
|
|
$params['sectiontitle'],
|
|
|
|
|
$baseRev->getId()
|
|
|
|
|
);
|
|
|
|
|
if ( !$editContent ) {
|
2016-03-08 08:04:45 +00:00
|
|
|
$this->dieUsage( 'Could not merge updated section.', 'replacefailed' );
|
2014-11-20 00:33:51 +00:00
|
|
|
}
|
|
|
|
|
if ( $currentRev->getId() == $baseRev->getId() ) {
|
|
|
|
|
// Base revision was still the latest; nothing to merge
|
|
|
|
|
$content = $editContent;
|
|
|
|
|
} else {
|
|
|
|
|
// Merge the edit into the current version
|
|
|
|
|
$baseContent = $baseRev->getContent();
|
|
|
|
|
$currentContent = $currentRev->getContent();
|
|
|
|
|
if ( !$baseContent || !$currentContent ) {
|
|
|
|
|
$this->dieUsage( "Missing content for page ID {$page->getId()}", 'missingrev' );
|
|
|
|
|
}
|
|
|
|
|
$handler = ContentHandler::getForModelID( $baseContent->getModel() );
|
|
|
|
|
$content = $handler->merge3( $baseContent, $editContent, $currentContent );
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
// New pages: use the user-provided content model
|
|
|
|
|
$content = $textContent;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( !$content ) { // merge3() failed
|
|
|
|
|
$this->getResult()->addValue( null,
|
2016-02-17 09:09:32 +00:00
|
|
|
$this->getModuleName(), [ 'status' => 'editconflict' ] );
|
2014-11-20 00:33:51 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// The user will abort the AJAX request by pressing "save", so ignore that
|
|
|
|
|
ignore_user_abort( true );
|
|
|
|
|
|
2015-12-10 21:56:11 +00:00
|
|
|
// Use the master DB for fast blocking locks
|
|
|
|
|
$dbw = wfGetDB( DB_MASTER );
|
|
|
|
|
|
2014-11-20 00:33:51 +00:00
|
|
|
// Get a key based on the source text, format, and user preferences
|
|
|
|
|
$key = self::getStashKey( $title, $content, $user );
|
|
|
|
|
// De-duplicate requests on the same key
|
|
|
|
|
if ( $user->pingLimiter( 'stashedit' ) ) {
|
|
|
|
|
$status = 'ratelimited';
|
2015-12-10 21:56:11 +00:00
|
|
|
} elseif ( $dbw->lock( $key, __METHOD__, 1 ) ) {
|
2016-06-13 10:09:45 +00:00
|
|
|
$status = self::parseAndStash( $page, $content, $user, $params['summary'] );
|
2015-12-10 21:56:11 +00:00
|
|
|
$dbw->unlock( $key, __METHOD__ );
|
2014-11-20 00:33:51 +00:00
|
|
|
} else {
|
|
|
|
|
$status = 'busy';
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-26 19:46:32 +00:00
|
|
|
$this->getStats()->increment( "editstash.cache_stores.$status" );
|
|
|
|
|
|
2016-02-17 09:09:32 +00:00
|
|
|
$this->getResult()->addValue( null, $this->getModuleName(), [ 'status' => $status ] );
|
2015-03-26 21:19:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param WikiPage $page
|
2016-06-13 10:09:45 +00:00
|
|
|
* @param Content $content Edit content
|
2015-03-26 21:19:39 +00:00
|
|
|
* @param User $user
|
2016-06-13 10:09:45 +00:00
|
|
|
* @param string $summary Edit summary
|
2015-03-26 21:19:39 +00:00
|
|
|
* @return integer ApiStashEdit::ERROR_* constant
|
|
|
|
|
* @since 1.25
|
|
|
|
|
*/
|
2016-06-13 10:09:45 +00:00
|
|
|
public static function parseAndStash( WikiPage $page, Content $content, User $user, $summary ) {
|
2015-10-26 07:41:05 +00:00
|
|
|
$cache = ObjectCache::getLocalClusterInstance();
|
2015-12-04 22:18:07 +00:00
|
|
|
$logger = LoggerFactory::getInstance( 'StashEdit' );
|
2015-03-26 21:19:39 +00:00
|
|
|
|
|
|
|
|
$format = $content->getDefaultFormat();
|
|
|
|
|
$editInfo = $page->prepareContentForEdit( $content, null, $user, $format, false );
|
2016-06-06 22:38:03 +00:00
|
|
|
$title = $page->getTitle();
|
2015-03-26 21:19:39 +00:00
|
|
|
|
2014-11-20 00:33:51 +00:00
|
|
|
if ( $editInfo && $editInfo->output ) {
|
2016-06-06 22:38:03 +00:00
|
|
|
$key = self::getStashKey( $title, $content, $user );
|
2015-03-26 21:19:39 +00:00
|
|
|
|
2016-01-27 01:23:53 +00:00
|
|
|
// Let extensions add ParserOutput metadata or warm other caches
|
2016-06-13 10:09:45 +00:00
|
|
|
Hooks::run( 'ParserOutputStashForEdit',
|
|
|
|
|
[ $page, $content, $editInfo->output, $summary, $user ] );
|
2016-01-27 01:23:53 +00:00
|
|
|
|
2016-06-10 04:03:59 +00:00
|
|
|
list( $stashInfo, $ttl, $code ) = self::buildStashValue(
|
2016-05-13 20:49:56 +00:00
|
|
|
$editInfo->pstContent,
|
|
|
|
|
$editInfo->output,
|
|
|
|
|
$editInfo->timestamp,
|
|
|
|
|
$user
|
2014-12-04 09:42:20 +00:00
|
|
|
);
|
2015-03-26 21:19:39 +00:00
|
|
|
|
2014-12-04 09:42:20 +00:00
|
|
|
if ( $stashInfo ) {
|
2015-10-26 07:41:05 +00:00
|
|
|
$ok = $cache->set( $key, $stashInfo, $ttl );
|
2014-11-20 00:33:51 +00:00
|
|
|
if ( $ok ) {
|
2016-06-06 22:38:03 +00:00
|
|
|
$logger->debug( "Cached parser output for key '$key' ('$title')." );
|
2015-03-26 21:19:39 +00:00
|
|
|
return self::ERROR_NONE;
|
2014-11-20 00:33:51 +00:00
|
|
|
} else {
|
2016-06-06 22:38:03 +00:00
|
|
|
$logger->error( "Failed to cache parser output for key '$key' ('$title')." );
|
2015-03-26 21:19:39 +00:00
|
|
|
return self::ERROR_CACHE;
|
2014-11-20 00:33:51 +00:00
|
|
|
}
|
|
|
|
|
} else {
|
2016-06-10 04:03:59 +00:00
|
|
|
$logger->info( "Uncacheable parser output for key '$key' ('$title') [$code]." );
|
2015-03-26 21:19:39 +00:00
|
|
|
return self::ERROR_UNCACHEABLE;
|
2014-11-20 00:33:51 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-26 21:19:39 +00:00
|
|
|
return self::ERROR_PARSE;
|
2014-11-20 00:33:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Check that a prepared edit is in cache and still up-to-date
|
|
|
|
|
*
|
|
|
|
|
* This method blocks if the prepared edit is already being rendered,
|
|
|
|
|
* waiting until rendering finishes before doing final validity checks.
|
|
|
|
|
*
|
|
|
|
|
* The cache is rejected if template or file changes are detected.
|
|
|
|
|
* Note that foreign template or file transclusions are not checked.
|
|
|
|
|
*
|
|
|
|
|
* The result is a map (pstContent,output,timestamp) with fields
|
|
|
|
|
* extracted directly from WikiPage::prepareContentForEdit().
|
|
|
|
|
*
|
|
|
|
|
* @param Title $title
|
|
|
|
|
* @param Content $content
|
|
|
|
|
* @param User $user User to get parser options from
|
|
|
|
|
* @return stdClass|bool Returns false on cache miss
|
|
|
|
|
*/
|
|
|
|
|
public static function checkCache( Title $title, Content $content, User $user ) {
|
2016-05-26 18:36:40 +00:00
|
|
|
if ( $user->isBot() ) {
|
|
|
|
|
return false; // bots never stash - don't pollute stats
|
|
|
|
|
}
|
|
|
|
|
|
2015-10-26 07:41:05 +00:00
|
|
|
$cache = ObjectCache::getLocalClusterInstance();
|
2015-12-04 22:18:07 +00:00
|
|
|
$logger = LoggerFactory::getInstance( 'StashEdit' );
|
2015-12-16 19:42:12 +00:00
|
|
|
$stats = RequestContext::getMain()->getStats();
|
2014-11-20 00:33:51 +00:00
|
|
|
|
|
|
|
|
$key = self::getStashKey( $title, $content, $user );
|
2015-10-26 07:41:05 +00:00
|
|
|
$editInfo = $cache->get( $key );
|
2014-11-20 00:33:51 +00:00
|
|
|
if ( !is_object( $editInfo ) ) {
|
|
|
|
|
$start = microtime( true );
|
|
|
|
|
// We ignore user aborts and keep parsing. Block on any prior parsing
|
2015-12-10 21:56:11 +00:00
|
|
|
// so as to use its results and make use of the time spent parsing.
|
|
|
|
|
// Skip this logic if there no master connection in case this method
|
|
|
|
|
// is called on an HTTP GET request for some reason.
|
|
|
|
|
$lb = wfGetLB();
|
|
|
|
|
$dbw = $lb->getAnyOpenConnection( $lb->getWriterIndex() );
|
|
|
|
|
if ( $dbw && $dbw->lock( $key, __METHOD__, 30 ) ) {
|
2015-10-26 07:41:05 +00:00
|
|
|
$editInfo = $cache->get( $key );
|
2015-12-10 21:56:11 +00:00
|
|
|
$dbw->unlock( $key, __METHOD__ );
|
2014-11-20 00:33:51 +00:00
|
|
|
}
|
2015-12-16 19:42:12 +00:00
|
|
|
|
|
|
|
|
$timeMs = 1000 * max( 0, microtime( true ) - $start );
|
2016-04-19 01:13:08 +00:00
|
|
|
$stats->timing( 'editstash.lock_wait_time', $timeMs );
|
2014-11-20 00:33:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( !is_object( $editInfo ) || !$editInfo->output ) {
|
2016-04-19 01:13:08 +00:00
|
|
|
$stats->increment( 'editstash.cache_misses.no_stash' );
|
2016-06-06 22:38:03 +00:00
|
|
|
$logger->debug( "Empty cache for key '$key' ('$title'); user '{$user->getName()}'." );
|
2014-11-20 00:33:51 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2016-04-27 22:43:38 +00:00
|
|
|
$age = time() - wfTimestamp( TS_UNIX, $editInfo->output->getCacheTime() );
|
|
|
|
|
if ( $age <= self::PRESUME_FRESH_TTL_SEC ) {
|
2016-06-17 23:16:27 +00:00
|
|
|
// Assume nothing changed in this time
|
2016-04-19 01:13:08 +00:00
|
|
|
$stats->increment( 'editstash.cache_hits.presumed_fresh' );
|
2016-04-27 22:43:38 +00:00
|
|
|
$logger->debug( "Timestamp-based cache hit for key '$key' (age: $age sec)." );
|
2016-05-13 20:49:56 +00:00
|
|
|
} elseif ( isset( $editInfo->edits ) && $editInfo->edits === $user->getEditCount() ) {
|
2016-05-14 10:54:05 +00:00
|
|
|
// Logged-in user made no local upload/template edits in the meantime
|
2016-05-13 20:49:56 +00:00
|
|
|
$stats->increment( 'editstash.cache_hits.presumed_fresh' );
|
|
|
|
|
$logger->debug( "Edit count based cache hit for key '$key' (age: $age sec)." );
|
2016-05-14 10:54:05 +00:00
|
|
|
} elseif ( $user->isAnon()
|
|
|
|
|
&& self::lastEditTime( $user ) < $editInfo->output->getCacheTime()
|
|
|
|
|
) {
|
|
|
|
|
// Logged-out user made no local upload/template edits in the meantime
|
|
|
|
|
$stats->increment( 'editstash.cache_hits.presumed_fresh' );
|
|
|
|
|
$logger->debug( "Edit check based cache hit for key '$key' (age: $age sec)." );
|
2016-06-17 23:16:27 +00:00
|
|
|
} else {
|
|
|
|
|
// User may have changed included content
|
|
|
|
|
$editInfo = false;
|
2014-11-20 00:33:51 +00:00
|
|
|
}
|
|
|
|
|
|
2016-06-17 23:16:27 +00:00
|
|
|
if ( !$editInfo ) {
|
|
|
|
|
$stats->increment( 'editstash.cache_misses.proven_stale' );
|
|
|
|
|
$logger->info( "Stale cache for key '$key'; old key with outside edits. (age: $age sec)" );
|
|
|
|
|
} elseif ( $editInfo->output->getFlag( 'vary-revision' ) ) {
|
|
|
|
|
// This can be used for the initial parse, e.g. for filters or doEditContent(),
|
|
|
|
|
// but a second parse will be triggered in doEditUpdates(). This is not optimal.
|
|
|
|
|
$logger->info( "Partially usable cache for key '$key' ('$title') [vary_revision]." );
|
|
|
|
|
}
|
2015-07-13 19:11:16 +00:00
|
|
|
|
2016-06-17 23:16:27 +00:00
|
|
|
return $editInfo;
|
2014-11-20 00:33:51 +00:00
|
|
|
}
|
|
|
|
|
|
2016-05-14 10:54:05 +00:00
|
|
|
/**
|
|
|
|
|
* @param User $user
|
|
|
|
|
* @return string|null TS_MW timestamp or null
|
|
|
|
|
*/
|
|
|
|
|
private static function lastEditTime( User $user ) {
|
|
|
|
|
$time = wfGetDB( DB_SLAVE )->selectField(
|
|
|
|
|
'recentchanges',
|
|
|
|
|
'MAX(rc_timestamp)',
|
|
|
|
|
[ 'rc_user_text' => $user->getName() ],
|
|
|
|
|
__METHOD__
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return wfTimestampOrNull( TS_MW, $time );
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-04 09:42:20 +00:00
|
|
|
/**
|
|
|
|
|
* Get the temporary prepared edit stash key for a user
|
|
|
|
|
*
|
|
|
|
|
* This key can be used for caching prepared edits provided:
|
|
|
|
|
* - a) The $user was used for PST options
|
|
|
|
|
* - b) The parser output was made from the PST using cannonical matching options
|
|
|
|
|
*
|
|
|
|
|
* @param Title $title
|
|
|
|
|
* @param Content $content
|
|
|
|
|
* @param User $user User to get parser options from
|
|
|
|
|
* @return string
|
|
|
|
|
*/
|
2016-05-14 10:54:05 +00:00
|
|
|
private static function getStashKey( Title $title, Content $content, User $user ) {
|
2016-02-17 09:09:32 +00:00
|
|
|
$hash = sha1( implode( ':', [
|
2016-06-06 21:34:14 +00:00
|
|
|
// Account for the edit model/text
|
2014-12-04 09:42:20 +00:00
|
|
|
$content->getModel(),
|
|
|
|
|
$content->getDefaultFormat(),
|
|
|
|
|
sha1( $content->serialize( $content->getDefaultFormat() ) ),
|
2016-06-06 21:34:14 +00:00
|
|
|
// Account for user name related variables like signatures
|
|
|
|
|
$user->getId(),
|
2016-06-07 00:27:37 +00:00
|
|
|
md5( $user->getName() )
|
2016-02-17 09:09:32 +00:00
|
|
|
] ) );
|
2014-12-04 09:42:20 +00:00
|
|
|
|
|
|
|
|
return wfMemcKey( 'prepared-edit', md5( $title->getPrefixedDBkey() ), $hash );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Build a value to store in memcached based on the PST content and parser output
|
|
|
|
|
*
|
|
|
|
|
* This makes a simple version of WikiPage::prepareContentForEdit() as stash info
|
|
|
|
|
*
|
|
|
|
|
* @param Content $pstContent
|
|
|
|
|
* @param ParserOutput $parserOutput
|
|
|
|
|
* @param string $timestamp TS_MW
|
2016-05-13 20:49:56 +00:00
|
|
|
* @param User $user
|
2016-06-10 04:03:59 +00:00
|
|
|
* @return array (stash info array, TTL in seconds, info code) or (null, 0, info code)
|
2014-12-04 09:42:20 +00:00
|
|
|
*/
|
2016-05-14 10:54:05 +00:00
|
|
|
private static function buildStashValue(
|
2016-05-13 20:49:56 +00:00
|
|
|
Content $pstContent, ParserOutput $parserOutput, $timestamp, User $user
|
2014-12-04 09:42:20 +00:00
|
|
|
) {
|
2016-05-13 20:49:56 +00:00
|
|
|
// If an item is renewed, mind the cache TTL determined by config and parser functions.
|
|
|
|
|
// Put an upper limit on the TTL for sanity to avoid extreme template/file staleness.
|
2014-12-04 09:42:20 +00:00
|
|
|
$since = time() - wfTimestamp( TS_UNIX, $parserOutput->getTimestamp() );
|
2016-06-08 10:23:39 +00:00
|
|
|
$ttl = min( $parserOutput->getCacheExpiry() - $since, self::MAX_CACHE_TTL );
|
2016-06-10 04:03:59 +00:00
|
|
|
if ( $ttl <= 0 ) {
|
|
|
|
|
return [ null, 0, 'no_ttl' ];
|
2014-12-04 09:42:20 +00:00
|
|
|
}
|
|
|
|
|
|
2016-06-10 04:03:59 +00:00
|
|
|
// Only store what is actually needed
|
|
|
|
|
$stashInfo = (object)[
|
|
|
|
|
'pstContent' => $pstContent,
|
|
|
|
|
'output' => $parserOutput,
|
|
|
|
|
'timestamp' => $timestamp,
|
|
|
|
|
'edits' => $user->getEditCount()
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
return [ $stashInfo, $ttl, 'ok' ];
|
2014-12-04 09:42:20 +00:00
|
|
|
}
|
|
|
|
|
|
2014-11-20 00:33:51 +00:00
|
|
|
public function getAllowedParams() {
|
2016-02-17 09:09:32 +00:00
|
|
|
return [
|
|
|
|
|
'title' => [
|
2014-11-20 00:33:51 +00:00
|
|
|
ApiBase::PARAM_TYPE => 'string',
|
|
|
|
|
ApiBase::PARAM_REQUIRED => true
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
|
|
|
|
'section' => [
|
2014-11-20 00:33:51 +00:00
|
|
|
ApiBase::PARAM_TYPE => 'string',
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
|
|
|
|
'sectiontitle' => [
|
2014-11-20 00:33:51 +00:00
|
|
|
ApiBase::PARAM_TYPE => 'string'
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
|
|
|
|
'text' => [
|
2015-05-07 16:39:55 +00:00
|
|
|
ApiBase::PARAM_TYPE => 'text',
|
2014-11-20 00:33:51 +00:00
|
|
|
ApiBase::PARAM_REQUIRED => true
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
2016-06-13 10:09:45 +00:00
|
|
|
'summary' => [
|
|
|
|
|
ApiBase::PARAM_TYPE => 'string',
|
|
|
|
|
],
|
2016-02-17 09:09:32 +00:00
|
|
|
'contentmodel' => [
|
2014-11-20 00:33:51 +00:00
|
|
|
ApiBase::PARAM_TYPE => ContentHandler::getContentModels(),
|
|
|
|
|
ApiBase::PARAM_REQUIRED => true
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
|
|
|
|
'contentformat' => [
|
2014-11-20 00:33:51 +00:00
|
|
|
ApiBase::PARAM_TYPE => ContentHandler::getAllContentFormats(),
|
|
|
|
|
ApiBase::PARAM_REQUIRED => true
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
|
|
|
|
'baserevid' => [
|
2014-11-20 00:33:51 +00:00
|
|
|
ApiBase::PARAM_TYPE => 'integer',
|
|
|
|
|
ApiBase::PARAM_REQUIRED => true
|
2016-02-17 09:09:32 +00:00
|
|
|
]
|
|
|
|
|
];
|
2014-11-20 00:33:51 +00:00
|
|
|
}
|
|
|
|
|
|
2016-03-08 07:46:02 +00:00
|
|
|
public function needsToken() {
|
2014-11-20 00:33:51 +00:00
|
|
|
return 'csrf';
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-08 07:46:02 +00:00
|
|
|
public function mustBePosted() {
|
2014-11-20 00:33:51 +00:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-08 07:46:02 +00:00
|
|
|
public function isWriteMode() {
|
2015-12-10 21:56:11 +00:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-08 07:46:02 +00:00
|
|
|
public function isInternal() {
|
2014-11-20 00:33:51 +00:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|