本文整理汇总了PHP中Revision::base36Sha1方法的典型用法代码示例。如果您正苦于以下问题:PHP Revision::base36Sha1方法的具体用法?PHP Revision::base36Sha1怎么用?PHP Revision::base36Sha1使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Revision
的用法示例。
在下文中一共展示了Revision::base36Sha1方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: insertOn
/**
* Insert a new revision into the database, returning the new revision ID
* number on success and dies horribly on failure.
*
* @param $dbw DatabaseBase: (master connection)
* @throws MWException
* @return Integer
*/
public function insertOn($dbw)
{
global $wgDefaultExternalStore, $wgContentHandlerUseDB;
wfProfileIn(__METHOD__);
$this->checkContentModel();
$data = $this->mText;
$flags = self::compressRevisionText($data);
# Write to external storage if required
if ($wgDefaultExternalStore) {
// Store and get the URL
$data = ExternalStore::insertToDefault($data);
if (!$data) {
wfProfileOut(__METHOD__);
throw new MWException("Unable to store text to external storage");
}
if ($flags) {
$flags .= ',';
}
$flags .= 'external';
}
# Record the text (or external storage URL) to the text table
if (!isset($this->mTextId)) {
$old_id = $dbw->nextSequenceValue('text_old_id_seq');
$dbw->insert('text', array('old_id' => $old_id, 'old_text' => $data, 'old_flags' => $flags), __METHOD__);
$this->mTextId = $dbw->insertId();
}
if ($this->mComment === null) {
$this->mComment = "";
}
# Record the edit in revisions
$rev_id = isset($this->mId) ? $this->mId : $dbw->nextSequenceValue('revision_rev_id_seq');
$row = array('rev_id' => $rev_id, 'rev_page' => $this->mPage, 'rev_text_id' => $this->mTextId, 'rev_comment' => $this->mComment, 'rev_minor_edit' => $this->mMinorEdit ? 1 : 0, 'rev_user' => $this->mUser, 'rev_user_text' => $this->mUserText, 'rev_timestamp' => $dbw->timestamp($this->mTimestamp), 'rev_deleted' => $this->mDeleted, 'rev_len' => $this->mSize, 'rev_parent_id' => is_null($this->mParentId) ? $this->getPreviousRevisionId($dbw) : $this->mParentId, 'rev_sha1' => is_null($this->mSha1) ? Revision::base36Sha1($this->mText) : $this->mSha1);
if ($wgContentHandlerUseDB) {
//NOTE: Store null for the default model and format, to save space.
//XXX: Makes the DB sensitive to changed defaults. Make this behavior optional? Only in miser mode?
$model = $this->getContentModel();
$format = $this->getContentFormat();
$title = $this->getTitle();
if ($title === null) {
wfProfileOut(__METHOD__);
throw new MWException("Insufficient information to determine the title of the revision's page!");
}
$defaultModel = ContentHandler::getDefaultModelFor($title);
$defaultFormat = ContentHandler::getForModelID($defaultModel)->getDefaultFormat();
$row['rev_content_model'] = $model === $defaultModel ? null : $model;
$row['rev_content_format'] = $format === $defaultFormat ? null : $format;
}
$dbw->insert('revision', $row, __METHOD__);
$this->mId = !is_null($rev_id) ? $rev_id : $dbw->insertId();
wfRunHooks('RevisionInsertComplete', array(&$this, $data, $flags));
wfProfileOut(__METHOD__);
return $this->mId;
}
示例2: upgradeLegacyArchiveRow
/**
* @param $row
* @return bool
*/
protected function upgradeLegacyArchiveRow($row)
{
$db = $this->getDB(DB_MASTER);
$rev = Revision::newFromArchiveRow($row);
$text = $rev->getRawText();
if (!is_string($text)) {
# This should not happen, but sometimes does (bug 20757)
$this->output("Text of revision with timestamp {$row->ar_timestamp} unavailable!\n");
return false;
} else {
# Archive table as no PK, but (NS,title,time) should be near unique.
# Any duplicates on those should also have duplicated text anyway.
$db->update('archive', array('ar_sha1' => Revision::base36Sha1($text)), array('ar_namespace' => $row->ar_namespace, 'ar_title' => $row->ar_title, 'ar_timestamp' => $row->ar_timestamp, 'ar_len' => $row->ar_len), __METHOD__);
return true;
}
}
示例3: dataGetSha1
public function dataGetSha1()
{
return array(array("hello world.", CONTENT_MODEL_WIKITEXT, Revision::base36Sha1("hello world.")), array(serialize("hello world."), "testing", Revision::base36Sha1(serialize("hello world."))));
}
示例4: insertOn
/**
* Insert a new revision into the database, returning the new revision ID
* number on success and dies horribly on failure.
*
* @param IDatabase $dbw (master connection)
* @throws MWException
* @return int
*/
public function insertOn($dbw)
{
global $wgDefaultExternalStore, $wgContentHandlerUseDB;
// Not allowed to have rev_page equal to 0, false, etc.
if (!$this->mPage) {
$title = $this->getTitle();
if ($title instanceof Title) {
$titleText = ' for page ' . $title->getPrefixedText();
} else {
$titleText = '';
}
throw new MWException("Cannot insert revision{$titleText}: page ID must be nonzero");
}
$this->checkContentModel();
$data = $this->mText;
$flags = self::compressRevisionText($data);
# Write to external storage if required
if ($wgDefaultExternalStore) {
// Store and get the URL
$data = ExternalStore::insertToDefault($data);
if (!$data) {
throw new MWException("Unable to store text to external storage");
}
if ($flags) {
$flags .= ',';
}
$flags .= 'external';
}
# Record the text (or external storage URL) to the text table
if ($this->mTextId === null) {
$old_id = $dbw->nextSequenceValue('text_old_id_seq');
$dbw->insert('text', array('old_id' => $old_id, 'old_text' => $data, 'old_flags' => $flags), __METHOD__);
$this->mTextId = $dbw->insertId();
}
if ($this->mComment === null) {
$this->mComment = "";
}
# Record the edit in revisions
$rev_id = $this->mId !== null ? $this->mId : $dbw->nextSequenceValue('revision_rev_id_seq');
$row = array('rev_id' => $rev_id, 'rev_page' => $this->mPage, 'rev_text_id' => $this->mTextId, 'rev_comment' => $this->mComment, 'rev_minor_edit' => $this->mMinorEdit ? 1 : 0, 'rev_user' => $this->mUser, 'rev_user_text' => $this->mUserText, 'rev_timestamp' => $dbw->timestamp($this->mTimestamp), 'rev_deleted' => $this->mDeleted, 'rev_len' => $this->mSize, 'rev_parent_id' => $this->mParentId === null ? $this->getPreviousRevisionId($dbw) : $this->mParentId, 'rev_sha1' => $this->mSha1 === null ? Revision::base36Sha1($this->mText) : $this->mSha1);
if ($wgContentHandlerUseDB) {
// NOTE: Store null for the default model and format, to save space.
// XXX: Makes the DB sensitive to changed defaults.
// Make this behavior optional? Only in miser mode?
$model = $this->getContentModel();
$format = $this->getContentFormat();
$title = $this->getTitle();
if ($title === null) {
throw new MWException("Insufficient information to determine the title of the " . "revision's page!");
}
$defaultModel = ContentHandler::getDefaultModelFor($title);
$defaultFormat = ContentHandler::getForModelID($defaultModel)->getDefaultFormat();
$row['rev_content_model'] = $model === $defaultModel ? null : $model;
$row['rev_content_format'] = $format === $defaultFormat ? null : $format;
}
$dbw->insert('revision', $row, __METHOD__);
$this->mId = $rev_id !== null ? $rev_id : $dbw->insertId();
// Assertion to try to catch T92046
if ((int) $this->mId === 0) {
throw new UnexpectedValueException('After insert, Revision mId is ' . var_export($this->mId, 1) . ': ' . var_export($row, 1));
}
Hooks::run('RevisionInsertComplete', array(&$this, $data, $flags));
return $this->mId;
}
示例5: insertOn
/**
* Insert a new revision into the database, returning the new revision ID
* number on success and dies horribly on failure.
*
* @param $dbw DatabaseBase: (master connection)
* @return Integer
*/
public function insertOn($dbw)
{
global $wgDefaultExternalStore;
wfProfileIn(__METHOD__);
$data = $this->mText;
$flags = Revision::compressRevisionText($data);
# Write to external storage if required
if ($wgDefaultExternalStore) {
// Store and get the URL
$data = ExternalStore::insertToDefault($data);
if (!$data) {
throw new MWException("Unable to store text to external storage");
}
if ($flags) {
$flags .= ',';
}
$flags .= 'external';
}
# Record the text (or external storage URL) to the text table
if (!isset($this->mTextId)) {
$old_id = $dbw->nextSequenceValue('text_old_id_seq');
$dbw->insert('text', array('old_id' => $old_id, 'old_text' => $data, 'old_flags' => $flags), __METHOD__);
$this->mTextId = $dbw->insertId();
}
if ($this->mComment === null) {
$this->mComment = "";
}
# Record the edit in revisions
$rev_id = isset($this->mId) ? $this->mId : $dbw->nextSequenceValue('revision_rev_id_seq');
$dbw->insert('revision', array('rev_id' => $rev_id, 'rev_page' => $this->mPage, 'rev_text_id' => $this->mTextId, 'rev_comment' => $this->mComment, 'rev_minor_edit' => $this->mMinorEdit ? 1 : 0, 'rev_user' => $this->mUser, 'rev_user_text' => $this->mUserText, 'rev_timestamp' => $dbw->timestamp($this->mTimestamp), 'rev_deleted' => $this->mDeleted, 'rev_len' => $this->mSize, 'rev_parent_id' => is_null($this->mParentId) ? $this->getPreviousRevisionId($dbw) : $this->mParentId, 'rev_sha1' => is_null($this->mSha1) ? Revision::base36Sha1($this->mText) : $this->mSha1), __METHOD__);
$this->mId = !is_null($rev_id) ? $rev_id : $dbw->insertId();
wfRunHooks('RevisionInsertComplete', array(&$this, $data, $flags));
wfProfileOut(__METHOD__);
return $this->mId;
}