本文整理匯總了PHP中LogPage::getRcComment方法的典型用法代碼示例。如果您正苦於以下問題:PHP LogPage::getRcComment方法的具體用法?PHP LogPage::getRcComment怎麽用?PHP LogPage::getRcComment使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類LogPage
的用法示例。
在下文中一共展示了LogPage::getRcComment方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: wfTimestamp
/**
* Record a file upload in the upload log and the image table
*/
function recordUpload2($oldver, $comment, $pageText, $props = false, $timestamp = false, $user = null)
{
if (is_null($user)) {
global $wgUser;
$user = $wgUser;
}
$dbw = $this->repo->getMasterDB();
$dbw->begin();
if (!$props) {
$props = $this->repo->getFileProps($this->getVirtualUrl());
}
if ($timestamp === false) {
$timestamp = $dbw->timestamp();
}
$props['description'] = $comment;
$props['user'] = $user->getId();
$props['user_text'] = $user->getName();
$props['timestamp'] = wfTimestamp(TS_MW, $timestamp);
// DB -> TS_MW
$this->setProps($props);
# Delete thumbnails
$this->purgeThumbnails();
# The file is already on its final location, remove it from the squid cache
SquidUpdate::purge(array($this->getURL()));
# Fail now if the file isn't there
if (!$this->fileExists) {
wfDebug(__METHOD__ . ": File " . $this->getRel() . " went missing!\n");
return false;
}
$reupload = false;
# Test to see if the row exists using INSERT IGNORE
# This avoids race conditions by locking the row until the commit, and also
# doesn't deadlock. SELECT FOR UPDATE causes a deadlock for every race condition.
$dbw->insert('image', array('img_name' => $this->getName(), 'img_size' => $this->size, 'img_width' => intval($this->width), 'img_height' => intval($this->height), 'img_bits' => $this->bits, 'img_media_type' => $this->media_type, 'img_major_mime' => $this->major_mime, 'img_minor_mime' => $this->minor_mime, 'img_timestamp' => $timestamp, 'img_description' => $comment, 'img_user' => $user->getId(), 'img_user_text' => $user->getName(), 'img_metadata' => $this->metadata, 'img_sha1' => $this->sha1), __METHOD__, 'IGNORE');
if ($dbw->affectedRows() == 0) {
$reupload = true;
# Collision, this is an update of a file
# Insert previous contents into oldimage
$dbw->insertSelect('oldimage', 'image', array('oi_name' => 'img_name', 'oi_archive_name' => $dbw->addQuotes($oldver), 'oi_size' => 'img_size', 'oi_width' => 'img_width', 'oi_height' => 'img_height', 'oi_bits' => 'img_bits', 'oi_timestamp' => 'img_timestamp', 'oi_description' => 'img_description', 'oi_user' => 'img_user', 'oi_user_text' => 'img_user_text', 'oi_metadata' => 'img_metadata', 'oi_media_type' => 'img_media_type', 'oi_major_mime' => 'img_major_mime', 'oi_minor_mime' => 'img_minor_mime', 'oi_sha1' => 'img_sha1'), array('img_name' => $this->getName()), __METHOD__);
# Update the current image row
$dbw->update('image', array('img_size' => $this->size, 'img_width' => intval($this->width), 'img_height' => intval($this->height), 'img_bits' => $this->bits, 'img_media_type' => $this->media_type, 'img_major_mime' => $this->major_mime, 'img_minor_mime' => $this->minor_mime, 'img_timestamp' => $timestamp, 'img_description' => $comment, 'img_user' => $user->getId(), 'img_user_text' => $user->getName(), 'img_metadata' => $this->metadata, 'img_sha1' => $this->sha1), array('img_name' => $this->getName()), __METHOD__);
} else {
# This is a new file
# Update the image count
$dbw->begin();
$site_stats = $dbw->tableName('site_stats');
$dbw->query("UPDATE {$site_stats} SET ss_images=ss_images+1", __METHOD__);
$dbw->commit();
}
$descTitle = $this->getTitle();
$article = new ImagePage($descTitle);
$article->setFile($this);
# Add the log entry
$log = new LogPage('upload');
$action = $reupload ? 'overwrite' : 'upload';
$log->addEntry($action, $descTitle, $comment, array(), $user);
if ($descTitle->exists()) {
# Create a null revision
$latest = $descTitle->getLatestRevID();
$nullRevision = Revision::newNullRevision($dbw, $descTitle->getArticleId(), $log->getRcComment(), false);
$nullRevision->insertOn($dbw);
wfRunHooks('NewRevisionFromEditComplete', array($article, $nullRevision, $latest, $user));
$article->updateRevisionOn($dbw, $nullRevision);
# Invalidate the cache for the description page
$descTitle->invalidateCache();
$descTitle->purgeSquid();
} else {
# New file; create the description page.
# There's already a log entry, so don't make a second RC entry
# Squid and file cache for the description page are purged by doEdit.
$article->doEdit($pageText, $comment, EDIT_NEW | EDIT_SUPPRESS_RC);
}
# Commit the transaction now, in case something goes wrong later
# The most important thing is that files don't get lost, especially archives
$dbw->commit();
# Save to cache and purge the squid
# We shall not saveToCache before the commit since otherwise
# in case of a rollback there is an usable file from memcached
# which in fact doesn't really exist (bug 24978)
$this->saveToCache();
# Hooks, hooks, the magic of hooks...
wfRunHooks('FileUpload', array($this, $reupload, $descTitle->exists()));
# Invalidate cache for all pages using this file
$update = new HTMLCacheUpdate($this->getTitle(), 'imagelinks');
$update->doUpdate();
# Invalidate cache for all pages that redirects on this page
$redirs = $this->getTitle()->getRedirectsHere();
foreach ($redirs as $redir) {
$update = new HTMLCacheUpdate($redir, 'imagelinks');
$update->doUpdate();
}
return true;
}
示例2: wfProfileIn
/**
* Record a file upload in the upload log and the image table
* @param $oldver
* @param $comment string
* @param $pageText string
* @param $props bool|array
* @param $timestamp bool|string
* @param $user null|User
* @return bool
*/
function recordUpload2($oldver, $comment, $pageText, $props = false, $timestamp = false, $user = null)
{
wfProfileIn(__METHOD__);
if (is_null($user)) {
global $wgUser;
$user = $wgUser;
}
$dbw = $this->repo->getMasterDB();
$dbw->begin(__METHOD__);
if (!$props) {
wfProfileIn(__METHOD__ . '-getProps');
$props = $this->repo->getFileProps($this->getVirtualUrl());
wfProfileOut(__METHOD__ . '-getProps');
}
if ($timestamp === false) {
$timestamp = $dbw->timestamp();
}
$props['description'] = $comment;
$props['user'] = $user->getId();
$props['user_text'] = $user->getName();
$props['timestamp'] = wfTimestamp(TS_MW, $timestamp);
// DB -> TS_MW
$this->setProps($props);
# Fail now if the file isn't there
if (!$this->fileExists) {
wfDebug(__METHOD__ . ": File " . $this->getRel() . " went missing!\n");
wfProfileOut(__METHOD__);
return false;
}
$reupload = false;
# Test to see if the row exists using INSERT IGNORE
# This avoids race conditions by locking the row until the commit, and also
# doesn't deadlock. SELECT FOR UPDATE causes a deadlock for every race condition.
$dbw->insert('image', array('img_name' => $this->getName(), 'img_size' => $this->size, 'img_width' => intval($this->width), 'img_height' => intval($this->height), 'img_bits' => $this->bits, 'img_media_type' => $this->media_type, 'img_major_mime' => $this->major_mime, 'img_minor_mime' => $this->minor_mime, 'img_timestamp' => $timestamp, 'img_description' => $comment, 'img_user' => $user->getId(), 'img_user_text' => $user->getName(), 'img_metadata' => $this->metadata, 'img_sha1' => $this->sha1), __METHOD__, 'IGNORE');
if ($dbw->affectedRows() == 0) {
# (bug 34993) Note: $oldver can be empty here, if the previous
# version of the file was broken. Allow registration of the new
# version to continue anyway, because that's better than having
# an image that's not fixable by user operations.
$reupload = true;
# Collision, this is an update of a file
# Insert previous contents into oldimage
$dbw->insertSelect('oldimage', 'image', array('oi_name' => 'img_name', 'oi_archive_name' => $dbw->addQuotes($oldver), 'oi_size' => 'img_size', 'oi_width' => 'img_width', 'oi_height' => 'img_height', 'oi_bits' => 'img_bits', 'oi_timestamp' => 'img_timestamp', 'oi_description' => 'img_description', 'oi_user' => 'img_user', 'oi_user_text' => 'img_user_text', 'oi_metadata' => 'img_metadata', 'oi_media_type' => 'img_media_type', 'oi_major_mime' => 'img_major_mime', 'oi_minor_mime' => 'img_minor_mime', 'oi_sha1' => 'img_sha1'), array('img_name' => $this->getName()), __METHOD__);
# Update the current image row
$dbw->update('image', array('img_size' => $this->size, 'img_width' => intval($this->width), 'img_height' => intval($this->height), 'img_bits' => $this->bits, 'img_media_type' => $this->media_type, 'img_major_mime' => $this->major_mime, 'img_minor_mime' => $this->minor_mime, 'img_timestamp' => $timestamp, 'img_description' => $comment, 'img_user' => $user->getId(), 'img_user_text' => $user->getName(), 'img_metadata' => $this->metadata, 'img_sha1' => $this->sha1), array('img_name' => $this->getName()), __METHOD__);
} else {
# This is a new file, so update the image count
DeferredUpdates::addUpdate(SiteStatsUpdate::factory(array('images' => 1)));
}
$descTitle = $this->getTitle();
$wikiPage = new WikiFilePage($descTitle);
$wikiPage->setFile($this);
# Add the log entry
$log = new LogPage('upload');
$action = $reupload ? 'overwrite' : 'upload';
$logId = $log->addEntry($action, $descTitle, $comment, array(), $user);
wfProfileIn(__METHOD__ . '-edit');
$exists = $descTitle->exists();
if ($exists) {
# Create a null revision
$latest = $descTitle->getLatestRevID();
$nullRevision = Revision::newNullRevision($dbw, $descTitle->getArticleID(), $log->getRcComment(), false);
if (!is_null($nullRevision)) {
$nullRevision->insertOn($dbw);
wfRunHooks('NewRevisionFromEditComplete', array($wikiPage, $nullRevision, $latest, $user));
$wikiPage->updateRevisionOn($dbw, $nullRevision);
}
}
# Commit the transaction now, in case something goes wrong later
# The most important thing is that files don't get lost, especially archives
# NOTE: once we have support for nested transactions, the commit may be moved
# to after $wikiPage->doEdit has been called.
$dbw->commit(__METHOD__);
if ($exists) {
# Invalidate the cache for the description page
$descTitle->invalidateCache();
$descTitle->purgeSquid();
} else {
# New file; create the description page.
# There's already a log entry, so don't make a second RC entry
# Squid and file cache for the description page are purged by doEditContent.
$content = ContentHandler::makeContent($pageText, $descTitle);
$status = $wikiPage->doEditContent($content, $comment, EDIT_NEW | EDIT_SUPPRESS_RC, false, $user);
if (isset($status->value['revision'])) {
// XXX; doEdit() uses a transaction
$dbw->begin(__METHOD__);
$dbw->update('logging', array('log_page' => $status->value['revision']->getPage()), array('log_id' => $logId), __METHOD__);
$dbw->commit(__METHOD__);
// commit before anything bad can happen
}
//.........這裏部分代碼省略.........
示例3: recordDownload
/**
* Record a file upload in the upload log and the image table
*/
private function recordDownload($comment = '', $timestamp = false)
{
global $wgUser;
$dbw = $this->repo->getMasterDB();
if ($timestamp === false) {
$timestamp = $dbw->timestamp();
}
list($major, $minor) = self::splitMime($this->mime);
# Test to see if the row exists using INSERT IGNORE
# This avoids race conditions by locking the row until the commit, and also
# doesn't deadlock. SELECT FOR UPDATE causes a deadlock for every race condition.
$dbw->insert('ic_image', array('img_name' => $this->getName(), 'img_size' => $this->size, 'img_width' => intval($this->width), 'img_height' => intval($this->height), 'img_bits' => $this->bits, 'img_media_type' => $this->type, 'img_major_mime' => $major, 'img_minor_mime' => $minor, 'img_timestamp' => $timestamp, 'img_description' => $comment, 'img_user' => $wgUser->getID(), 'img_user_text' => $wgUser->getName(), 'img_metadata' => $this->metadata), __METHOD__, 'IGNORE');
if ($dbw->affectedRows() == 0) {
# Collision, this is an update of a file
# Update the current image row
$dbw->update('ic_image', array('img_size' => $this->size, 'img_width' => intval($this->width), 'img_height' => intval($this->height), 'img_bits' => $this->bits, 'img_media_type' => $this->media_type, 'img_major_mime' => $this->major_mime, 'img_minor_mime' => $this->minor_mime, 'img_timestamp' => $timestamp, 'img_description' => $comment, 'img_user' => $wgUser->getID(), 'img_user_text' => $wgUser->getName(), 'img_metadata' => $this->metadata), array('img_name' => $this->getName()), __METHOD__);
} else {
# This is a new file
# Update the image count
$site_stats = $dbw->tableName('site_stats');
$dbw->query("UPDATE {$site_stats} SET ss_images=ss_images+1", __METHOD__);
}
$descTitle = $this->getTitle();
$article = new Article($descTitle);
# Add the log entry
$log = new LogPage('icdownload');
$log->addEntry('InstantCommons download', $descTitle, $comment);
if ($descTitle->exists()) {
# Create a null revision
$nullRevision = Revision::newNullRevision($dbw, $descTitle->getArticleId(), $log->getRcComment(), false);
$nullRevision->insertOn($dbw);
$article->updateRevisionOn($dbw, $nullRevision);
# Invalidate the cache for the description page
$descTitle->invalidateCache();
$descTitle->purgeSquid();
}
# Commit the transaction now, in case something goes wrong later
# The most important thing is that files don't get lost, especially archives
$dbw->immediateCommit();
# Invalidate cache for all pages using this file
$update = new HTMLCacheUpdate($this->getTitle(), 'imagelinks');
$update->doUpdate();
return true;
}
示例4: wfTimestamp
/**
* Record a file upload in the upload log and the image table
*/
function recordUpload2($oldver, $comment, $pageText, $props = false, $timestamp = false)
{
global $wgUser;
$dbw = $this->repo->getMasterDB();
if (!$props) {
$props = $this->repo->getFileProps($this->getVirtualUrl());
}
$props['description'] = $comment;
$props['user'] = $wgUser->getID();
$props['user_text'] = $wgUser->getName();
$props['timestamp'] = wfTimestamp(TS_MW);
$this->setProps($props);
// Delete thumbnails and refresh the metadata cache
$this->purgeThumbnails();
$this->saveToCache();
wfPurgeSquidServers(array($this->getURL()));
// Fail now if the file isn't there
if (!$this->fileExists) {
wfDebug(__METHOD__ . ": File " . $this->getPath() . " went missing!\n");
return false;
}
$reupload = false;
if ($timestamp === false) {
$timestamp = $dbw->timestamp();
}
# Test to see if the row exists using INSERT IGNORE
# This avoids race conditions by locking the row until the commit, and also
# doesn't deadlock. SELECT FOR UPDATE causes a deadlock for every race condition.
$dbw->insert('image', array('img_name' => $this->getName(), 'img_size' => $this->size, 'img_width' => intval($this->width), 'img_height' => intval($this->height), 'img_bits' => $this->bits, 'img_media_type' => $this->media_type, 'img_major_mime' => $this->major_mime, 'img_minor_mime' => $this->minor_mime, 'img_timestamp' => $timestamp, 'img_description' => $comment, 'img_user' => $wgUser->getID(), 'img_user_text' => $wgUser->getName(), 'img_metadata' => $this->metadata, 'img_sha1' => $this->sha1), __METHOD__, 'IGNORE');
if ($dbw->affectedRows() == 0) {
$reupload = true;
# Collision, this is an update of a file
# Insert previous contents into oldimage
$dbw->insertSelect('oldimage', 'image', array('oi_name' => 'img_name', 'oi_archive_name' => $dbw->addQuotes($oldver), 'oi_size' => 'img_size', 'oi_width' => 'img_width', 'oi_height' => 'img_height', 'oi_bits' => 'img_bits', 'oi_timestamp' => 'img_timestamp', 'oi_description' => 'img_description', 'oi_user' => 'img_user', 'oi_user_text' => 'img_user_text', 'oi_metadata' => 'img_metadata', 'oi_media_type' => 'img_media_type', 'oi_major_mime' => 'img_major_mime', 'oi_minor_mime' => 'img_minor_mime', 'oi_sha1' => 'img_sha1'), array('img_name' => $this->getName()), __METHOD__);
# Update the current image row
$dbw->update('image', array('img_size' => $this->size, 'img_width' => intval($this->width), 'img_height' => intval($this->height), 'img_bits' => $this->bits, 'img_media_type' => $this->media_type, 'img_major_mime' => $this->major_mime, 'img_minor_mime' => $this->minor_mime, 'img_timestamp' => $timestamp, 'img_description' => $comment, 'img_user' => $wgUser->getID(), 'img_user_text' => $wgUser->getName(), 'img_metadata' => $this->metadata, 'img_sha1' => $this->sha1), array('img_name' => $this->getName()), __METHOD__);
} else {
# This is a new file
# Update the image count
$site_stats = $dbw->tableName('site_stats');
$dbw->query("UPDATE {$site_stats} SET ss_images=ss_images+1", __METHOD__);
}
$descTitle = $this->getTitle();
$article = new Article($descTitle);
# Add the log entry
$log = new LogPage('upload');
$action = $reupload ? 'overwrite' : 'upload';
$log->addEntry($action, $descTitle, $comment);
if ($descTitle->exists()) {
# Create a null revision
$nullRevision = Revision::newNullRevision($dbw, $descTitle->getArticleId(), $log->getRcComment(), false);
$nullRevision->insertOn($dbw);
$article->updateRevisionOn($dbw, $nullRevision);
# Invalidate the cache for the description page
$descTitle->invalidateCache();
$descTitle->purgeSquid();
} else {
// New file; create the description page.
// There's already a log entry, so don't make a second RC entry
$article->doEdit($pageText, $comment, EDIT_NEW | EDIT_SUPPRESS_RC);
}
# Hooks, hooks, the magic of hooks...
wfRunHooks('FileUpload', array($this));
# Commit the transaction now, in case something goes wrong later
# The most important thing is that files don't get lost, especially archives
$dbw->immediateCommit();
# Invalidate cache for all pages using this file
$update = new HTMLCacheUpdate($this->getTitle(), 'imagelinks');
$update->doUpdate();
return true;
}
示例5: wfTimestamp
/**
* Record a file upload in the upload log and the image table
*/
function recordUpload2($oldver, $comment, $pageText, $props = false, $timestamp = false, $user = null)
{
global $wgCityId;
if (is_null($user)) {
global $wgUser;
$user = $wgUser;
}
$dbw = $this->repo->getMasterDB();
$dbw->begin();
if (!$props) {
$props = $this->repo->getFileProps($this->getVirtualUrl());
}
if ($timestamp === false) {
$timestamp = $dbw->timestamp();
}
$props['description'] = $comment;
$props['user'] = $user->getId();
$props['user_text'] = $user->getName();
$props['timestamp'] = wfTimestamp(TS_MW, $timestamp);
// DB -> TS_MW
$this->setProps($props);
# Fail now if the file isn't there
if (!$this->fileExists) {
wfDebug(__METHOD__ . ": File " . $this->getRel() . " went missing!\n");
return false;
}
$reupload = false;
# Test to see if the row exists using INSERT IGNORE
# This avoids race conditions by locking the row until the commit, and also
# doesn't deadlock. SELECT FOR UPDATE causes a deadlock for every race condition.
$dbw->insert('image', array('img_name' => $this->getName(), 'img_size' => $this->size, 'img_width' => intval($this->width), 'img_height' => intval($this->height), 'img_bits' => $this->bits, 'img_media_type' => $this->media_type, 'img_major_mime' => $this->major_mime, 'img_minor_mime' => $this->minor_mime, 'img_timestamp' => $timestamp, 'img_description' => $comment, 'img_user' => $user->getId(), 'img_user_text' => $user->getName(), 'img_metadata' => $this->metadata, 'img_sha1' => $this->sha1), __METHOD__, 'IGNORE');
if ($dbw->affectedRows() == 0) {
if ($oldver == '') {
// XXX
# (bug 34993) publish() can displace the current file and yet fail to save
# a new one. The next publish attempt will treat the file as a brand new file
# and pass an empty $oldver. Allow this bogus value so we can displace the
# `image` row to `oldimage`, leaving room for the new current file `image` row.
#throw new MWException( "Empty oi_archive_name. Database and storage out of sync?" );
Wikia::logBacktrace(__METHOD__ . "::oi_archive_name - [{$this->getName()}]");
// Wikia change (BAC-1068)
}
$reupload = true;
# Collision, this is an update of a file
# Insert previous contents into oldimage
$dbw->insertSelect('oldimage', 'image', array('oi_name' => 'img_name', 'oi_archive_name' => $dbw->addQuotes($oldver), 'oi_size' => 'img_size', 'oi_width' => 'img_width', 'oi_height' => 'img_height', 'oi_bits' => 'img_bits', 'oi_timestamp' => 'img_timestamp', 'oi_description' => 'img_description', 'oi_user' => 'img_user', 'oi_user_text' => 'img_user_text', 'oi_metadata' => 'img_metadata', 'oi_media_type' => 'img_media_type', 'oi_major_mime' => 'img_major_mime', 'oi_minor_mime' => 'img_minor_mime', 'oi_sha1' => 'img_sha1'), array('img_name' => $this->getName()), __METHOD__);
# Update the current image row
$dbw->update('image', array('img_size' => $this->size, 'img_width' => intval($this->width), 'img_height' => intval($this->height), 'img_bits' => $this->bits, 'img_media_type' => $this->media_type, 'img_major_mime' => $this->major_mime, 'img_minor_mime' => $this->minor_mime, 'img_timestamp' => $timestamp, 'img_description' => $comment, 'img_user' => $user->getId(), 'img_user_text' => $user->getName(), 'img_metadata' => $this->metadata, 'img_sha1' => $this->sha1), array('img_name' => $this->getName()), __METHOD__);
} else {
# This is a new file
# Update the image count
$dbw->begin(__METHOD__);
$dbw->update('site_stats', array('ss_images = ss_images+1'), '*', __METHOD__);
$dbw->commit(__METHOD__);
}
$descTitle = $this->getTitle();
$wikiPage = new WikiFilePage($descTitle);
$wikiPage->setFile($this);
# Add the log entry
$log = new LogPage('upload');
$action = $reupload ? 'overwrite' : 'upload';
$log->addEntry($action, $descTitle, $comment, array(), $user);
if ($descTitle->exists()) {
# Create a null revision
$latest = $descTitle->getLatestRevID();
$nullRevision = Revision::newNullRevision($dbw, $descTitle->getArticleId(), $log->getRcComment(), false);
if (!is_null($nullRevision)) {
$nullRevision->insertOn($dbw);
wfRunHooks('NewRevisionFromEditComplete', array($wikiPage, $nullRevision, $latest, $user));
$wikiPage->updateRevisionOn($dbw, $nullRevision);
}
# Invalidate the cache for the description page
$descTitle->invalidateCache();
$descTitle->purgeSquid();
} else {
# New file; create the description page.
# There's already a log entry, so don't make a second RC entry
# Squid and file cache for the description page are purged by doEdit.
$wikiPage->doEdit($pageText, $comment, EDIT_NEW | EDIT_SUPPRESS_RC, false, $user);
}
/* wikia change - begin (VID-1568) */
// Update/Insert video info
try {
\VideoInfoHooksHelper::upsertVideoInfo($this, $reupload);
} catch (\Exception $e) {
$dbw->rollback();
return false;
}
/* wikia change - end (VID-1568) */
# Commit the transaction now, in case something goes wrong later
# The most important thing is that files don't get lost, especially archives
$dbw->commit();
# Save to cache and purge the squid
# We shall not saveToCache before the commit since otherwise
# in case of a rollback there is an usable file from memcached
# which in fact doesn't really exist (bug 24978)
$this->saveToCache();
//.........這裏部分代碼省略.........