mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-24 06:24:08 +00:00
Clean up VisualEditorDataModule and document ve.version
* Check in #getGitHeadHash now ensures a false value is
cached as well.
* Made ve.version.id being false when invalid more stable
since we now rely on this as of eeb3ac3b19
.
* Added documentation for ve.version.
Change-Id: I164aa9ebaa7f8a4d1e8f2210af76e06b23abef09
This commit is contained in:
parent
c98a964d5f
commit
e4662a65cd
|
@ -83,7 +83,7 @@
|
|||
},
|
||||
{
|
||||
"name": "MediaWiki integration",
|
||||
"classes": ["ve.init.mw*"]
|
||||
"classes": ["ve.init.mw*", "ve.version"]
|
||||
},
|
||||
{
|
||||
"name": "Stand-alone",
|
||||
|
|
|
@ -35,3 +35,26 @@
|
|||
* @class QUnit
|
||||
* @source <http://api.qunitjs.com/>
|
||||
*/
|
||||
|
||||
/**
|
||||
* Provided by VisualEditorDataModule.php for the MediaWiki environment.
|
||||
*
|
||||
* @class ve.version
|
||||
* @singleton
|
||||
*/
|
||||
|
||||
/**
|
||||
* @property {string|boolean} [id=false] Git commit hash (abbreviated to 7 characters)
|
||||
*/
|
||||
|
||||
/**
|
||||
* @property {string|boolean} [url=false] URL to git commit viewer for #id
|
||||
*/
|
||||
|
||||
/**
|
||||
* @property {number|boolean} [timestamp=false] Commit date (UNIX timestamp)
|
||||
*/
|
||||
|
||||
/**
|
||||
* @property {string} [dateString=""] Formatted date or empty string
|
||||
*/
|
||||
|
|
|
@ -39,7 +39,8 @@ class VisualEditorDataModule extends ResourceLoaderModule {
|
|||
// Version information
|
||||
$language = Language::factory( $context->getLanguage() );
|
||||
|
||||
$id = substr( $this->getGitHeadHash(), 0, 7 );
|
||||
$hash = $this->getGitHeadHash();
|
||||
$id = $hash ? substr( $this->getGitHeadHash(), 0, 7 ) : false;
|
||||
$url = $this->gitInfo->getHeadViewUrl();
|
||||
$date = $this->gitInfo->getHeadCommitDate();
|
||||
$dateString = $date ? $language->timeanddate( $date, true ) : '';
|
||||
|
@ -53,6 +54,7 @@ class VisualEditorDataModule extends ResourceLoaderModule {
|
|||
$messages,
|
||||
ResourceLoader::inDebugMode()
|
||||
) . ');'.
|
||||
// Documented in .docs/external.json
|
||||
've.version = ' . FormatJson::encode(
|
||||
array(
|
||||
'id' => $id,
|
||||
|
@ -161,7 +163,7 @@ class VisualEditorDataModule extends ResourceLoaderModule {
|
|||
}
|
||||
|
||||
protected function getGitHeadHash() {
|
||||
if ( !$this->gitHeadHash ) {
|
||||
if ( $this->gitHeadHash === null ) {
|
||||
$this->gitHeadHash = $this->gitInfo->getHeadSHA1();
|
||||
}
|
||||
return $this->gitHeadHash;
|
||||
|
|
Loading…
Reference in a new issue