=== New features in 1.32 ===
* (T112474) Generalized the ResourceLoader mechanism for overriding modules
using a particular page during edit previews.
+* (T12331) You can now log page creation events by setting $wgPageCreationLog
+ to true.
* Added 'ApiParseMakeOutputPage' hook.
* (T174313) Added checkbox on Special:ListUsers to display only users in temporary
user groups.
];
/**
- * Maintain a log of newusers at Log/newusers?
+ * Maintain a log of newusers at Special:Log/newusers?
*/
$wgNewUserLog = true;
+/**
+ * Maintain a log of page creations at Special:Log/create?
+ * @since 1.32
+ */
+$wgPageCreationLog = false;
+
/** @} */ # end logging }
/*************************************************************************//**
}
if ( $wgNewUserLog ) {
- // Add a new log type
+ // Add new user log type
$wgLogTypes[] = 'newusers';
$wgLogNames['newusers'] = 'newuserlogpage';
$wgLogHeaders['newusers'] = 'newuserlogpagetext';
$wgLogActionsHandlers['newusers/autocreate'] = NewUsersLogFormatter::class;
}
+if ( $wgPageCreationLog ) {
+ // Add page creation log type
+ $wgLogTypes[] = 'create';
+ $wgLogActionsHandlers['create/create'] = LogFormatter::class;
+}
+
if ( $wgPageLanguageUseDB ) {
$wgLogTypes[] = 'pagelang';
$wgLogActionsHandlers['pagelang/pagelang'] = PageLangLogFormatter::class;
private function doCreate(
Content $content, $flags, User $user, $summary, array $meta
) {
- global $wgUseRCPatrol, $wgUseNPPatrol;
+ global $wgUseRCPatrol, $wgUseNPPatrol, $wgPageCreationLog;
$status = Status::newGood( [ 'new' => true, 'revision' => null ] );
$user->incEditCount();
+ if ( $wgPageCreationLog ) {
+ // Log the page creation
+ // @TODO: Do we want a 'recreate' action?
+ $logEntry = new ManualLogEntry( 'create', 'create' );
+ $logEntry->setPerformer( $user );
+ $logEntry->setTarget( $this->mTitle );
+ $logEntry->setComment( $summary );
+ $logEntry->setTimestamp( $now );
+ $logEntry->setAssociatedRevId( $revisionId );
+ $logid = $logEntry->insert();
+ // Note that we don't publish page creation events to recentchanges
+ // (i.e. $logEntry->publish()) since this would create duplicate entries,
+ // one for the edit and one for the page creation.
+ }
+
$dbw->endAtomic( __METHOD__ );
$this->mTimestamp = $now;
"dellogpage": "Deletion log",
"dellogpagetext": "Below is a list of the most recent deletions.",
"deletionlog": "deletion log",
+ "log-name-create": "Page creation log",
+ "log-description-create": "Below is a list of the most recent page creations.",
+ "logentry-create-create": "$1 {{GENDER:$2|created}} page $3",
"reverted": "Reverted to earlier revision",
"deletecomment": "Reason:",
"deleteotherreason": "Other/additional reason:",
"dellogpage": "{{doc-logpage}}\n\nThe name of the deletion log. Used as heading on [[Special:Log/delete]] and in the drop down menu for selecting logs on [[Special:Log]].\n{{Identical|Deletion log}}",
"dellogpagetext": "Text in [[Special:Log/delete]].",
"deletionlog": "Used as text for the link which points to the deletion log:\n* Used as <code>$1</code> in {{msg-mw|Filewasdeleted}}\n* Used as <code>$2</code> in {{msg-mw|Deletedtext}}\n* Used in log lines on [[Special:DeletedContributions]]\n{{Identical|Deletion log}}",
+ "log-name-create": "{{doc-logpage}}\n\nThe name of the page creation log. Used as heading on [[Special:Log/create]] and in the drop down menu for selecting logs on [[Special:Log]].",
+ "log-description-create": "Text in [[Special:Log/create]].",
+ "logentry-create-create": "{{Logentry|[[Special:Log/create]]}}",
"reverted": "{{Identical|Revert}}",
"deletecomment": "{{Identical|Reason}}",
"deleteotherreason": "{{Identical|Other/additional reason}}",
* @covers WikiPage::doEditUpdates
*/
public function testDoEditContent() {
+ $this->setMwGlobals( 'wgPageCreationLog', true );
+
$page = $this->newPage( __METHOD__ );
$title = $page->getTitle();
$page->doEditContent( $content, "[[testing]] 1" );
+ $id = $page->getId();
+
+ // Test page creation logging
+ $this->assertSelect(
+ 'logging',
+ [ 'log_type', 'log_action' ],
+ [ 'log_page' => $id ],
+ [ [ 'create', 'create' ] ]
+ );
+
$this->assertTrue( $title->getArticleID() > 0, "Title object should have new page id" );
- $this->assertTrue( $page->getId() > 0, "WikiPage should have new page id" );
+ $this->assertTrue( $id > 0, "WikiPage should have new page id" );
$this->assertTrue( $title->exists(), "Title object should indicate that the page now exists" );
$this->assertTrue( $page->exists(), "WikiPage object should indicate that the page now exists" );
- $id = $page->getId();
-
# ------------------------
$dbr = wfGetDB( DB_REPLICA );
$res = $dbr->select( 'pagelinks', '*', [ 'pl_from' => $id ] );