global $wgAutopromoteOnceLogInRC, $wgAuth;
$toPromote = array();
- if ( $this->getId() ) {
+ if ( !wfReadOnly() && $this->getId() ) {
$toPromote = Autopromote::getAutopromoteOnceGroups( $this, $event );
if ( count( $toPromote ) ) {
$oldGroups = $this->getGroups(); // previous groups
}
}
}
+
return $toPromote;
}
if ( $this->mQuickTouched === null ) {
$key = wfMemcKey( 'user-quicktouched', 'id', $this->mId );
$timestamp = $wgMemc->get( $key );
- if ( !$timestamp ) {
+ if ( $timestamp ) {
+ $this->mQuickTouched = $timestamp;
+ } else {
# Set the timestamp to get HTTP 304 cache hits
$this->touch();
}
* @param int|null $expire Unix timestamp (in seconds) when the cookie should expire.
* 0 (the default) causes it to expire $wgCookieExpiration seconds from now.
* null causes it to be a session cookie.
- * @param array|null $options Assoc of additional cookie options:
+ * @param array $options Assoc of additional cookie options:
* prefix: string, name prefix ($wgCookiePrefix)
* domain: string, cookie domain ($wgCookieDomain)
* path: string, cookie path ($wgCookiePath)
* 'prefix', 'domain', and 'secure'
* @since 1.22 Replaced $prefix, $domain, and $forceSecure with $options
*/
- public function setcookie( $name, $value, $expire = 0, $options = null ) {
+ public function setcookie( $name, $value, $expire = 0, $options = array() ) {
global $wgCookiePath, $wgCookiePrefix, $wgCookieDomain;
global $wgCookieSecure, $wgCookieExpiration, $wgCookieHttpOnly;
* @param string $name The name of the cookie.
* @param string $value The value to be stored in the cookie.
* @param int|null $expire Ignored in this faux subclass.
- * @param array|null $options Ignored in this faux subclass.
+ * @param array $options Ignored in this faux subclass.
*/
- public function setcookie( $name, $value, $expire = 0, $options = null ) {
+ public function setcookie( $name, $value, $expire = 0, $options = array() ) {
$this->cookies[$name] = $value;
}
$result_array['wikitext'] = array();
ApiResult::setContent( $result_array['wikitext'], $this->content->serialize( $format ) );
}
- if ( !is_null( $params['summary'] ) ) {
+ if ( !is_null( $params['summary'] ) ||
+ ( !is_null( $params['sectiontitle'] ) && $this->section === 'new' )
+ ) {
$result_array['parsedsummary'] = array();
- ApiResult::setContent(
- $result_array['parsedsummary'],
- Linker::formatComment( $params['summary'], $titleObj )
- );
+ ApiResult::setContent( $result_array['parsedsummary'], $this->formatSummary( $titleObj, $params ) );
}
$result->addValue( null, $this->getModuleName(), $result_array );
ApiResult::setContent( $result_array['text'], $p_result->getText() );
}
- if ( !is_null( $params['summary'] ) ) {
+ if ( !is_null( $params['summary'] ) ||
+ ( !is_null( $params['sectiontitle'] ) && $this->section === 'new' )
+ ) {
$result_array['parsedsummary'] = array();
- ApiResult::setContent(
- $result_array['parsedsummary'],
- Linker::formatComment( $params['summary'], $titleObj )
- );
+ ApiResult::setContent( $result_array['parsedsummary'], $this->formatSummary( $titleObj, $params ) );
}
if ( isset( $prop['langlinks'] ) ) {
return $section;
}
+ /**
+ * This mimicks the behavior of EditPage in formatting a summary
+ *
+ * @param Title $title of the page being parsed
+ * @param Array $params the API parameters of the request
+ * @return Content|bool
+ */
+ private function formatSummary( $title, $params ) {
+ global $wgParser;
+ $summary = !is_null( $params['summary'] ) ? $params['summary'] : '';
+ $sectionTitle = !is_null( $params['sectiontitle'] ) ? $params['sectiontitle'] : '';
+
+ if ( $this->section === 'new' && ( $sectionTitle === '' || $summary === '' ) ) {
+ if( $sectionTitle !== '' ) {
+ $summary = $params['sectiontitle'];
+ }
+ if ( $summary !== '' ) {
+ $summary = wfMessage( 'newsectionsummary' )->rawParams( $wgParser->stripSectionName( $summary ) )
+ ->inContentLanguage()->text();
+ }
+ }
+ return Linker::formatComment( $summary, $title, $this->section === 'new' );
+ }
+
private function formatLangLinks( $links ) {
$result = array();
foreach ( $links as $link ) {
<?php
echo Html::submitButton(
$this->getMsg( $this->data['loggedin'] ? 'createacct-another-submit' : 'createacct-submit' ),
- $attrs = array(
+ array(
'id' => 'wpCreateaccount',
'name' => 'wpCreateaccount',
'tabindex' => $tabIndex++
$( function () {
// Do not enable on user .js/.css pages, as there's no sane way of "previewing"
// the scripts or styles without reloading the page.
- // Do not enable for ProofreadPage Index page editors, which have no textbox
- if ( $( '#mw-userjsyoucanpreview' ).length || $( '#mw-usercssyoucanpreview' ).length || $( '#wpTextbox1' ).length === 0 ) {
+ if ( $( '#mw-userjsyoucanpreview' ).length || $( '#mw-usercssyoucanpreview' ).length ) {
return;
}
public function getProperty() {
return $this->property;
}
+
+ protected function whatSecondArg( $a, $b = false ) {
+ return $b;
+ }
}
$classReflection = new ReflectionClass( $this->object );
$methodReflection = $classReflection->getMethod( $method );
$methodReflection->setAccessible( true );
- return $methodReflection->invoke( $this->object, $args );
+ return $methodReflection->invokeArgs( $this->object, $args );
}
public function __set( $name, $value ) {
$this->assertSame( 2, $this->wrapped->property );
$this->assertSame( 2, $this->raw->getProperty() );
}
+
+ function testCallMethodTwoArgs() {
+ $this->assertSame( 'two', $this->wrapped->whatSecondArg( 'one', 'two' ) );
+ }
}
/**
* @group ContentHandler
- * @group Database
- *
- * @note Declare that we are using the database, because otherwise we'll fail in
- * the "databaseless" test run. This is because the LinkHolderArray used by the
- * parser needs database access.
*/
class ContentHandlerTest extends MediaWikiTestCase {
// Reset namespace cache
MWNamespace::getCanonicalNamespaces( true );
$wgContLang->resetNamespaces();
+ // And LinkCache
+ LinkCache::destroySingleton();
}
protected function tearDown() {
// Reset namespace cache
MWNamespace::getCanonicalNamespaces( true );
$wgContLang->resetNamespaces();
+ // And LinkCache
+ LinkCache::destroySingleton();
parent::tearDown();
}
*/
public function testGetForTitle( $title, $expectedContentModel ) {
$title = Title::newFromText( $title );
+ LinkCache::singleton()->addBadLinkObj( $title );
$handler = ContentHandler::getForTitle( $title );
$this->assertEquals( $expectedContentModel, $handler->getModelID() );
}
public function testGetPageLanguage( $title, $expected ) {
if ( is_string( $title ) ) {
$title = Title::newFromText( $title );
+ LinkCache::singleton()->addBadLinkObj( $title );
}
$expected = wfGetLangObj( $expected );
$expectedModelId, $expectedNativeData, $shouldFail
) {
$title = Title::newFromText( $title );
-
+ LinkCache::singleton()->addBadLinkObj( $title );
try {
$content = ContentHandler::makeContent( $data, $title, $modelId, $format );