29 global
$wgVersion, $wgWMESchemaEditAttemptStepSamplingRate;
30 $extensionRegistry = ExtensionRegistry::getInstance();
31 if ( !$extensionRegistry->isLoaded(
'EventLogging' ) ) {
35 $samplingRate = $wgWMESchemaEditAttemptStepSamplingRate ?? 0.0625;
36 $inSample = EventLogging::sessionInSample( 1 / $samplingRate, $data[
'editing_session_id'] );
37 $shouldOversample = $extensionRegistry->isLoaded(
'WikimediaEvents' ) &&
38 WikimediaEventsHooks::shouldSchemaEditAttemptStepOversample( $article->getContext() );
39 if ( !$inSample && !$shouldOversample ) {
43 $user = $article->getContext()->getUser();
44 $page = $article->getPage();
45 $title = $article->getTitle();
50 'is_oversample' => !$inSample,
51 'editor_interface' =>
'wikitext',
52 'platform' =>
'desktop',
53 'integration' =>
'page',
54 'page_id' => $page->getId(),
55 'page_title' =>
$title->getPrefixedText(),
56 'page_ns' =>
$title->getNamespace(),
57 'revision_id' => $page->getRevision() ? $page->getRevision()->getId() : 0,
58 'user_id' => $user->getId(),
59 'user_editcount' => $user->getEditCount() ?: 0,
63 if ( $user->isAnon() ) {
64 $data[
'user_class'] =
'IP';
67 return EventLogging::logEvent(
'EditAttemptStep', 18530416, $data );
84 $request = $article->getContext()->getRequest();
87 $user = $article->getContext()->getUser();
88 if ( $user->getOption(
'usebetatoolbar' ) ) {
96 if ( ExtensionRegistry::getInstance()->isLoaded(
'EventLogging' ) && !$request->wasPosted() ) {
99 if ( $request->getVal(
'section' ) ) {
100 $data[
'init_type'] =
'section';
102 $data[
'init_type'] =
'page';
104 if ( $request->getHeader(
'Referer' ) ) {
105 if ( $request->getVal(
'section' ) ===
'new' || !$article->exists() ) {
106 $data[
'init_mechanism'] =
'new';
108 $data[
'init_mechanism'] =
'click';
111 $data[
'init_mechanism'] =
'url';
132 $editingStatsId = $req->getVal(
'editingStatsId' );
133 if ( !$editingStatsId || !$req->wasPosted() ) {
142 'name' =>
'editingStatsId',
143 'id' =>
'editingStatsId',
144 'value' => $editingStatsId
160 if ( $wgUser->getOption(
'usebetatoolbar' ) ) {
179 $defaultPreferences[
'usebetatoolbar'] = [
181 'label-message' =>
'wikieditor-toolbar-preference',
182 'help-message' =>
'wikieditor-toolbar-preference-help',
183 'section' =>
'editing/editor',
213 $msg = $ml->
msg(
'sig-text' )->params(
'~~~~' )->inContentLanguage();
214 return $raw ? $msg->plain() : $msg->text();
221 $requiredMagicWords = [
232 if ( class_exists( MagicWordFactory::class ) ) {
233 $factory = MediaWikiServices::getInstance()->getMagicWordFactory();
235 foreach ( $requiredMagicWords as $name ) {
236 if ( class_exists( MagicWordFactory::class ) ) {
237 $magicWords[$name] = $factory->get( $name )->getSynonym( 0 );
250 if ( !self::$statsId ) {
263 $request = $article->getContext()->getRequest();
264 if ( $request->getVal(
'editingStatsId' ) ) {
268 [
'editing_session_id' => $request->getVal(
'editingStatsId' ) ]
281 $request = $article->getContext()->getRequest();
282 if ( $request->getVal(
'editingStatsId' ) ) {
284 $data[
'editing_session_id'] = $request->getVal(
'editingStatsId' );
286 if ( $status->
isOK() ) {
287 $action =
'saveSuccess';
289 $action =
'saveFailure';
292 if ( isset( $errors[0][0] ) ) {
293 $data[
'save_failure_message'] = $errors[0][0];
297 $data[
'save_failure_type'] =
'editConflict';
299 $data[
'save_failure_type'] =
'editPageDeleted';
300 } elseif ( isset( $errors[0][0] ) && $errors[0][0] ===
'abusefilter-disallowed' ) {
301 $data[
'save_failure_type'] =
'extensionAbuseFilter';
302 } elseif ( isset( $editPage->
getArticle()->getPage()->ConfirmEdit_ActivateCaptcha ) ) {
304 $data[
'save_failure_type'] =
'extensionCaptcha';
305 } elseif ( isset( $errors[0][0] ) && $errors[0][0] ===
'spam-blacklisted-link' ) {
306 $data[
'save_failure_type'] =
'extensionSpamBlacklist';
310 $data[
'save_failure_type'] =
'responseUnknown';
$wgVersion
MediaWiki version number.
The edit page/HTML interface (split from Article) The actual database and text munging is still in Ar...
const AS_CONFLICT_DETECTED
Status: (non-resolvable) edit conflict.
const AS_ARTICLE_WAS_DELETED
Status: article was deleted while editing and param wpRecreate == false or form was not posted.
static generateHex( $chars)
Generate a run of cryptographically random data and return it in hexadecimal string format.
static get( $id)
Factory: creates an object representing an ID.
This is one of the Core classes and should be read at least once by any new developers.
addModuleStyles( $modules)
Load the styles of one or more ResourceLoader modules on this page.
addHTML( $text)
Append $text to the body HTML.
addModules( $modules)
Load one or more ResourceLoader modules on this page.
Context object that contains information about the state of a specific ResourceLoader web request.
isOK()
Returns whether the operation completed.
Generic operation result class Has warning/error list, boolean status and arbitrary value.
getErrorsArray()
Get the list of errors (but not warnings)
static editPageShowEditFormInitial(EditPage $editPage, OutputPage $outputPage)
EditPage::showEditForm:initial hook.
static getEditingStatsId()
Gets a 32 character alphanumeric random string to be used for stats.
static editPageAttemptSave(EditPage $editPage)
This is attached to the MediaWiki 'EditPage::attemptSave' hook.
static getMagicWords()
Expose useful magic words which are used by the wikieditor toolbar.
static getModuleData(ResourceLoaderContext $context, Config $config)
static getSignatureMessage(MessageLocalizer $ml, $raw=false)
static EditPageBeforeEditToolbar(&$toolbar)
EditPageBeforeEditToolbar hook.
static editPageAttemptSaveAfter(EditPage $editPage, Status $status)
This is attached to the MediaWiki 'EditPage::attemptSave:after' hook.
static getModuleDataSummary(ResourceLoaderContext $context, Config $config)
static getPreferences( $user, &$defaultPreferences)
GetPreferences hook.
static editPageShowEditFormFields(EditPage $editPage, OutputPage $outputPage)
EditPage::showEditForm:fields hook.
static doEventLogging( $action, $article, $data=[])
Log stuff to EventLogging's Schema:EditAttemptStep - see https://meta.wikimedia.org/wiki/Schema:EditA...
const CONTENT_MODEL_WIKITEXT
Interface for configuration instances.
Interface for localizing messages in MediaWiki.
msg( $key,... $params)
This is the method for getting translated interface messages.