當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Revision::base36Sha1方法代碼示例

本文整理匯總了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;
 }
開發者ID:mangowi,項目名稱:mediawiki,代碼行數:61,代碼來源:Revision.php

示例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;
     }
 }
開發者ID:Tjorriemorrie,項目名稱:app,代碼行數:20,代碼來源:populateRevisionSha1.php

示例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."))));
 }
開發者ID:nischayn22,項目名稱:mediawiki-core,代碼行數:4,代碼來源:RevisionTest.php

示例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;
 }
開發者ID:OrBin,項目名稱:mediawiki,代碼行數:72,代碼來源:Revision.php

示例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;
 }
開發者ID:laiello,項目名稱:media-wiki-law,代碼行數:42,代碼來源:Revision.php


注:本文中的Revision::base36Sha1方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。