mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/AbuseFilter.git
synced 2024-09-24 10:48:17 +00:00
Merge "New variable: new_pst which provides a PSTed version of new_wikitext"
This commit is contained in:
commit
963655c81e
|
@ -107,6 +107,7 @@ class AbuseFilter {
|
|||
'added_links' => 'added-links',
|
||||
'removed_links' => 'removed-links',
|
||||
'all_links' => 'all-links',
|
||||
'new_pst' => 'new-pst',
|
||||
'new_text' => 'new-text-stripped',
|
||||
'new_html' => 'new-html',
|
||||
'article_restrictions_edit' => 'restrictions-edit',
|
||||
|
@ -1993,6 +1994,14 @@ class AbuseFilter {
|
|||
'title' => $title->getText(),
|
||||
'text-var' => 'old_wikitext'
|
||||
) );
|
||||
$vars->setLazyLoadVar( 'new_pst', 'parse-wikitext',
|
||||
array(
|
||||
'namespace' => $title->getNamespace(),
|
||||
'title' => $title->getText(),
|
||||
'wikitext-var' => 'new_wikitext',
|
||||
'article' => $page,
|
||||
'pst' => true,
|
||||
) );
|
||||
$vars->setLazyLoadVar( 'new_html', 'parse-wikitext',
|
||||
array(
|
||||
'namespace' => $title->getNamespace(),
|
||||
|
|
|
@ -336,6 +336,7 @@ Tags should be short, and they should not contain special characters.',
|
|||
'abusefilter-edit-builder-vars-removed-links' => 'All external links removed in the edit',
|
||||
'abusefilter-edit-builder-vars-old-text' => 'Old page wikitext, before the edit',
|
||||
'abusefilter-edit-builder-vars-new-text' => 'New page wikitext, after the edit',
|
||||
'abusefilter-edit-builder-vars-new-pst' => 'New page wikitext, pre-save transformed',
|
||||
'abusefilter-edit-builder-vars-new-text-stripped' => 'New page text, stripped of any markup',
|
||||
'abusefilter-edit-builder-vars-new-html' => 'Parsed HTML source of the new revision',
|
||||
'abusefilter-edit-builder-vars-recent-contributors' => 'Last ten users to contribute to the page',
|
||||
|
@ -898,6 +899,7 @@ Abuse filter syntax option in a dropdown from the group {{msg-mw|abusefilter-edi
|
|||
'abusefilter-edit-builder-vars-user-groups' => 'See also:
|
||||
* {{msg-mw|Abusefilter-edit-builder-vars-global-user-groups}}',
|
||||
'abusefilter-edit-builder-vars-user-blocked' => 'Paraphrased: Boolean value on whether the user is blocked. Abuse filter syntax option in a dropdown from the group {{msg-mw|abusefilter-edit-builder-group-vars}}.',
|
||||
'abusefilter-edit-builder-vars-new-pst' => 'Paraphrased: The output wikitext after pre-save transform is applied to new_wikitext. Abuse filter syntax option in a dropdown from the group {{msg-mw|abusefilter-edit-builder-group-vars}}.',
|
||||
'abusefilter-edit-builder-vars-restrictions-edit' => 'This variable contains the level of protection required to edit the page. ("Edit" here is not a verb, but an adjective, like "Edit-related protection level"). Abuse filter syntax option in a dropdown from the group {{msg-mw|abusefilter-edit-builder-group-vars}}.
|
||||
|
||||
See also {{msg-mw|Abusefilter-edit-builder-vars-restrictions-create}}, {{msg-mw|Abusefilter-edit-builder-vars-restrictions-move}}, {{msg-mw|Abusefilter-edit-builder-vars-restrictions-upload}}.',
|
||||
|
|
|
@ -437,10 +437,14 @@ class AFComputedVariable {
|
|||
// XXX: Use prepareContentForEdit. But we need a Content object for that.
|
||||
$new_text = $vars->getVar( $textVar )->toString();
|
||||
$editInfo = $article->prepareTextForEdit( $new_text );
|
||||
$newHTML = $editInfo->output->getText();
|
||||
// Kill the PP limit comments. Ideally we'd just remove these by not setting the
|
||||
// parser option, but then we can't share a parse operation with the edit, which is bad.
|
||||
$result = preg_replace( '/<!--\s*NewPP limit report[^>]*-->\s*$/si', '', $newHTML );
|
||||
if ( isset( $parameters['pst'] ) && $parameters['pst'] ) {
|
||||
$result = $editInfo->pstContent->serialize( $editInfo->format );
|
||||
} else {
|
||||
$newHTML = $editInfo->output->getText();
|
||||
// Kill the PP limit comments. Ideally we'd just remove these by not setting the
|
||||
// parser option, but then we can't share a parse operation with the edit, which is bad.
|
||||
$result = preg_replace( '/<!--\s*NewPP limit report[^>]*-->\s*$/si', '', $newHTML );
|
||||
}
|
||||
break;
|
||||
}
|
||||
// Otherwise fall back to database
|
||||
|
@ -452,9 +456,14 @@ class AFComputedVariable {
|
|||
if ( !defined( 'MW_SUPPORTS_CONTENTHANDLER' )
|
||||
|| $article->getContentModel() === CONTENT_MODEL_WIKITEXT ) {
|
||||
|
||||
$text = $vars->getVar( $textVar )->toString();
|
||||
$editInfo = $this->parseNonEditWikitext( $text, $article );
|
||||
$result = $editInfo->output->getText();
|
||||
if ( isset( $parameters['pst'] ) && $parameters['pst'] ) {
|
||||
// $textVar is already PSTed when it's not loaded from an ongoing edit.
|
||||
$result = $vars->getVar( $textVar )->toString();
|
||||
} else {
|
||||
$text = $vars->getVar( $textVar )->toString();
|
||||
$editInfo = $this->parseNonEditWikitext( $text, $article );
|
||||
$result = $editInfo->output->getText();
|
||||
}
|
||||
} else {
|
||||
// TODO: Parser Output from Content object. But we don't have the content object.
|
||||
// And for non-text content, $wikitext is usually not going to be a valid
|
||||
|
|
Loading…
Reference in a new issue