Merge "Use PHP 7 "\u{NNNN}" Unicode codepoint escapes in string literals"
[lhc/web/wiklou.git] / includes / page / WikiPage.php
index cbce884..e186279 100644 (file)
@@ -1874,7 +1874,7 @@ class WikiPage implements Page, IDBAccessObject {
        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 ] );
 
@@ -1950,6 +1950,21 @@ class WikiPage implements Page, IDBAccessObject {
 
                $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;
 
@@ -3311,9 +3326,7 @@ class WikiPage implements Page, IDBAccessObject {
                }
 
                // raise error, when the edit is an edit without a new version
-               $statusRev = isset( $status->value['revision'] )
-                       ? $status->value['revision']
-                       : null;
+               $statusRev = $status->value['revision'] ?? null;
                if ( !( $statusRev instanceof Revision ) ) {
                        $resultDetails = [ 'current' => $current ];
                        return [ [ 'alreadyrolled',