Page MenuHomePhabricator

Configuration variable to truncate or disable automatic edit summaries
Closed, ResolvedPublic

Description

Author: fdg001

Description:
It would be helpful if there was a variable to either

  • limit the number of chars in an auto-summary (currently 200), or
  • completely disable auto-summaries (though this can also be done by setting

MediaWiki:Autosumm-new to " ")

This could rather easily be done by editing the getAutosummary function in
Article.php (I myself am not qualified for this, unfortunatly).


Version: unspecified
Severity: enhancement

Details

Reference
bz8968

Event Timeline

bzimport raised the priority of this task from to Low.Nov 21 2014, 9:32 PM
bzimport set Reference to bz8968.
bzimport added a subscriber: Unknown Object (MLST).

fdg001 wrote:

Here's how I think it might be done:
(However, I don't know how to register the new variable $autoSummChars so it's
customizable in Special:Allmessages...)

public static function getAutosummary( $oldtext, $newtext, $flags ) {

  1. This code is UGLY UGLY UGLY.
  2. Somebody PLEASE come up with a more elegant way to do it.
		#Redirect autosummaries
		$summary = self::getRedirectAutosummary( $newtext );

		if ($summary)
			return $summary;

		#Blanking autosummaries
		if (!($flags & EDIT_NEW))
			$summary = self::getBlankingAutosummary( $oldtext, $newtext );

		if ($summary)
			return $summary;

		#New page autosummaries
		if ($flags & EDIT_NEW && strlen($newtext)) {
			#If they're making a new article, give its text, truncated, in the summary.
			if ($autoSummChars > 0) {
				global $wgContLang;
				$truncatedtext = $wgContLang->truncate(
					str_replace("\n", ' ', $newtext),
					max( 0, $autoSummChars - strlen( wfMsgForContent( 'autosumm-new') ) ),
					'...' );
				$summary = wfMsgForContent( 'autosumm-new', $truncatedtext );
			} else {
				$summary = "";
			}
		}

		if ($summary)
			return $summary;

		return $summary;

}

fdg001 wrote:

proposed patch

The previous comment stripped the whitespaces, so here's a slightly altered
version as an attachment.
I've marked my changes with "-- FND".

attachment Article.php ignored as obsolete

robchur wrote:

Please submit patches as unified diffs against Subversion trunk.

ayg wrote:

Not so important for a three-line patch, though. Anyway, note that the variable
should be a global declared in DefaultSettings.php, not a local variable that
was never assigned a value as here.

fdg001 wrote:

proposed patch (revised)

Here's the revised version as a patch.
Please note that it's untested, as I don't have a MW installation to test it on
at the moment.
But it's very simple, so I would have to be a complete moron to screw this one
up...

(In reply to comment #3)

Please submit patches as unified diffs against Subversion trunk.

Thanks to Brion and Simetrical, I actually know what that means and figured out
how to do it...

(In reply to comment #4)

Anyway, note that the variable
should be a global declared in DefaultSettings.php, not a local variable that

was never assigned a value as here.

I wasn't sure whether declaring/initializing the variable in
DefaultSettings.php would suffice - well, I guess it does...

Attached:

This is done in 1.13, see [[mw:Manual:$wgUseAutomaticEditSummaries]]