jenkins-bot has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/400685 )
Change subject: Do not collapse references on diffs/old revisions
......................................................................
Do not collapse references on diffs/old revisions
This fixes an other regression introduced via Ied5fe1a.
We fixed an other regression just recently, see T181807. Now I realized
we left a lot of code behind that is now entirely unused:
* The "editable" flag is always true now. It can as well be removed.
* Because of this, the EmptyEditSectionGenerator is unused.
* Because of this, the edit section string can not be empty any more.
This patch here just removes all this code.
What's left is the "initially collapsed" state depending on the number
of references. However, this must only have an effect on regular entity
pages that are neither a diff nor an old revision.
The actual fix for T182767 is in the .less file.
Splitting this patch is not impossible, but I feel the proposed solution
can be much better understood with the dead code removed.
Bug: T182767
Change-Id: Ifc8ac520f70914c3ee5e558afc7cfe82b409b737
---
M repo/includes/Content/EntityContent.php
M repo/includes/ParserOutput/EntityParserOutputGenerator.php
M repo/includes/ParserOutput/EntityParserOutputGeneratorFactory.php
M repo/resources/wikibase.ui.entityViewInit.js
M
repo/tests/phpunit/includes/ParserOutput/EntityParserOutputGeneratorFactoryTest.php
M repo/tests/phpunit/includes/ParserOutput/EntityParserOutputGeneratorTest.php
M view/autoload.php
M view/resources/wikibase/wikibase.less
D view/src/EmptyEditSectionGenerator.php
M view/src/StatementHtmlGenerator.php
D view/tests/phpunit/EmptyEditSectionGeneratorTest.php
M view/tests/phpunit/StatementHtmlGeneratorTest.php
12 files changed, 16 insertions(+), 194 deletions(-)
Approvals:
WMDE-leszek: Looks good to me, approved
jenkins-bot: Verified
diff --git a/repo/includes/Content/EntityContent.php
b/repo/includes/Content/EntityContent.php
index e5605ff..bfe1061 100644
--- a/repo/includes/Content/EntityContent.php
+++ b/repo/includes/Content/EntityContent.php
@@ -262,8 +262,7 @@
$entityParserOutputGeneratorFactory =
WikibaseRepo::getDefaultInstance()->getEntityParserOutputGeneratorFactory();
$outputGenerator =
$entityParserOutputGeneratorFactory->getEntityParserOutputGenerator(
- $options->getUserLang(),
- true
+ $options->getUserLang()
);
$entityRevision = $this->getEntityRevision( $revisionId );
diff --git a/repo/includes/ParserOutput/EntityParserOutputGenerator.php
b/repo/includes/ParserOutput/EntityParserOutputGenerator.php
index c7d92ca..f779ae5 100644
--- a/repo/includes/ParserOutput/EntityParserOutputGenerator.php
+++ b/repo/includes/ParserOutput/EntityParserOutputGenerator.php
@@ -24,7 +24,6 @@
use Wikibase\Repo\MediaWikiLanguageDirectionalityLookup;
use Wikibase\Repo\MediaWikiLocalizedTextProvider;
use Wikibase\Repo\View\RepoSpecialPageLinker;
-use Wikibase\View\EmptyEditSectionGenerator;
use Wikibase\View\LocalizedTextProvider;
use Wikibase\View\Template\TemplateFactory;
use Wikibase\View\TermsListView;
@@ -91,11 +90,6 @@
private $languageCode;
/**
- * @var bool
- */
- private $editable;
-
- /**
* @param DispatchingEntityViewFactory $entityViewFactory
* @param ParserOutputJsConfigBuilder $configBuilder
* @param EntityTitleLookup $entityTitleLookup
@@ -106,7 +100,6 @@
* @param EntityDataFormatProvider $entityDataFormatProvider
* @param ParserOutputDataUpdater[] $dataUpdaters
* @param string $languageCode
- * @param bool $editable
*/
public function __construct(
DispatchingEntityViewFactory $entityViewFactory,
@@ -118,8 +111,7 @@
LocalizedTextProvider $textProvider,
EntityDataFormatProvider $entityDataFormatProvider,
array $dataUpdaters,
- $languageCode,
- $editable
+ $languageCode
) {
$this->entityViewFactory = $entityViewFactory;
$this->configBuilder = $configBuilder;
@@ -131,7 +123,6 @@
$this->entityDataFormatProvider = $entityDataFormatProvider;
$this->dataUpdaters = $dataUpdaters;
$this->languageCode = $languageCode;
- $this->editable = $editable;
}
/**
@@ -293,11 +284,11 @@
$this->languageFallbackChain
);
- $editSectionGenerator = $this->editable ? new
ToolbarEditSectionGenerator(
+ $editSectionGenerator = new ToolbarEditSectionGenerator(
new RepoSpecialPageLinker(),
$this->templateFactory,
$this->textProvider
- ) : new EmptyEditSectionGenerator();
+ );
$languageDirectionalityLookup = new
MediaWikiLanguageDirectionalityLookup();
$languageNameLookup = new LanguageNameLookup(
$this->languageCode );
diff --git a/repo/includes/ParserOutput/EntityParserOutputGeneratorFactory.php
b/repo/includes/ParserOutput/EntityParserOutputGeneratorFactory.php
index 481c971..a614fca 100644
--- a/repo/includes/ParserOutput/EntityParserOutputGeneratorFactory.php
+++ b/repo/includes/ParserOutput/EntityParserOutputGeneratorFactory.php
@@ -131,11 +131,10 @@
* Creates an EntityParserOutputGenerator to create the ParserOutput
for the entity
*
* @param string $userLanguageCode
- * @param bool $editable
*
* @return EntityParserOutputGenerator
*/
- public function getEntityParserOutputGenerator( $userLanguageCode,
$editable ) {
+ public function getEntityParserOutputGenerator( $userLanguageCode ) {
$userLanguage = Language::factory( $userLanguageCode );
return new EntityParserOutputGenerator(
@@ -148,8 +147,7 @@
new MediaWikiLocalizedTextProvider( $userLanguageCode ),
$this->entityDataFormatProvider,
$this->getDataUpdaters(),
- $userLanguageCode,
- $editable
+ $userLanguageCode
);
}
diff --git a/repo/resources/wikibase.ui.entityViewInit.js
b/repo/resources/wikibase.ui.entityViewInit.js
index d0ebda3..e2565bf 100644
--- a/repo/resources/wikibase.ui.entityViewInit.js
+++ b/repo/resources/wikibase.ui.entityViewInit.js
@@ -37,8 +37,6 @@
}
/**
- * Builds an entity store.
- *
* @param {wikibase.api.RepoApi} repoApi
* @param {string} languageCode The language code of the ui language
* @return {wikibase.store.CachingEntityStore}
diff --git
a/repo/tests/phpunit/includes/ParserOutput/EntityParserOutputGeneratorFactoryTest.php
b/repo/tests/phpunit/includes/ParserOutput/EntityParserOutputGeneratorFactoryTest.php
index cb1fb06..33cfb2c 100644
---
a/repo/tests/phpunit/includes/ParserOutput/EntityParserOutputGeneratorFactoryTest.php
+++
b/repo/tests/phpunit/includes/ParserOutput/EntityParserOutputGeneratorFactoryTest.php
@@ -28,9 +28,7 @@
public function testGetEntityParserOutputGenerator() {
$parserOutputGeneratorFactory =
$this->getEntityParserOutputGeneratorFactory();
- $instance =
$parserOutputGeneratorFactory->getEntityParserOutputGenerator(
- 'en', true
- );
+ $instance =
$parserOutputGeneratorFactory->getEntityParserOutputGenerator( 'en' );
$this->assertInstanceOf( EntityParserOutputGenerator::class,
$instance );
}
diff --git
a/repo/tests/phpunit/includes/ParserOutput/EntityParserOutputGeneratorTest.php
b/repo/tests/phpunit/includes/ParserOutput/EntityParserOutputGeneratorTest.php
index 717d9e5..f4e8960 100644
---
a/repo/tests/phpunit/includes/ParserOutput/EntityParserOutputGeneratorTest.php
+++
b/repo/tests/phpunit/includes/ParserOutput/EntityParserOutputGeneratorTest.php
@@ -215,8 +215,7 @@
$this->getMock( LocalizedTextProvider::class ),
$entityDataFormatProvider,
$dataUpdaters,
- 'en',
- true
+ 'en'
);
}
@@ -404,8 +403,7 @@
$this->getMock( LocalizedTextProvider::class ),
new EntityDataFormatProvider(),
$dataUpdaters,
- 'en',
- true
+ 'en'
);
}
diff --git a/view/autoload.php b/view/autoload.php
index c740df4..c100642 100644
--- a/view/autoload.php
+++ b/view/autoload.php
@@ -6,7 +6,6 @@
$wgAutoloadClasses += [
'Wikibase\\View\\DummyLocalizedTextProvider' => __DIR__ .
'/src/DummyLocalizedTextProvider.php',
'Wikibase\\View\\EditSectionGenerator' => __DIR__ .
'/src/EditSectionGenerator.php',
- 'Wikibase\\View\\EmptyEditSectionGenerator' => __DIR__ .
'/src/EmptyEditSectionGenerator.php',
'Wikibase\\View\\EntityIdFormatterFactory' => __DIR__ .
'/src/EntityIdFormatterFactory.php',
'Wikibase\\View\\EntityTermsView' => __DIR__ .
'/src/EntityTermsView.php',
'Wikibase\\View\\EntityView' => __DIR__ . '/src/EntityView.php',
diff --git a/view/resources/wikibase/wikibase.less
b/view/resources/wikibase/wikibase.less
index b84e2ed..bbbdeaf 100644
--- a/view/resources/wikibase/wikibase.less
+++ b/view/resources/wikibase/wikibase.less
@@ -515,7 +515,8 @@
}
/* Some UI elements are initially hidden if JS is enabled */
-.client-js .wikibase-initially-collapsed {
+.client-js
.wikibase-entitytermsview-entitytermsforlanguagelistview.wikibase-initially-collapsed,
+.client-js body:not( .wb-diffpage ):not( .wb-oldrevpage )
.wikibase-initially-collapsed {
display: none;
}
diff --git a/view/src/EmptyEditSectionGenerator.php
b/view/src/EmptyEditSectionGenerator.php
deleted file mode 100644
index 81dd859..0000000
--- a/view/src/EmptyEditSectionGenerator.php
+++ /dev/null
@@ -1,55 +0,0 @@
-<?php
-
-namespace Wikibase\View;
-
-use Wikibase\DataModel\Entity\EntityId;
-use Wikibase\DataModel\Entity\PropertyId;
-use Wikibase\DataModel\Statement\Statement;
-
-/**
- * An EditSectionGenerator returning empty string for edit sections
- *
- * @license GPL-2.0+
- * @author Adrian Heine <[email protected]>
- */
-class EmptyEditSectionGenerator implements EditSectionGenerator {
-
- /**
- * @param Statement $statement
- *
- * @return string Always an empty string.
- */
- public function getStatementEditSection( Statement $statement ) {
- return '';
- }
-
- /**
- * @param string $languageCode Unused.
- * @param EntityId|null $entityId Unused.
- *
- * @return string Always an empty string.
- */
- public function getLabelDescriptionAliasesEditSection( $languageCode,
EntityId $entityId = null ) {
- return '';
- }
-
- /**
- * @param EntityId|null $entityId Unused.
- *
- * @return string Always an empty string.
- */
- public function getSiteLinksEditSection( EntityId $entityId = null ) {
- return '';
- }
-
- /**
- * @param PropertyId $propertyId Unused.
- * @param EntityId|null $entityId Unused.
- *
- * @return string Always an empty string.
- */
- public function getAddStatementToGroupSection( PropertyId $propertyId,
EntityId $entityId = null ) {
- return '';
- }
-
-}
diff --git a/view/src/StatementHtmlGenerator.php
b/view/src/StatementHtmlGenerator.php
index 40c119b..d576fac7 100644
--- a/view/src/StatementHtmlGenerator.php
+++ b/view/src/StatementHtmlGenerator.php
@@ -86,7 +86,6 @@
$references = $statement->getReferences();
$referencesHtml = $this->getHtmlForReferences( $references );
- $collapseReferences = $editSectionHtml !== '' &&
!$references->isEmpty();
return $this->templateFactory->render(
'wikibase-statementview',
@@ -98,7 +97,7 @@
$editSectionHtml,
$referencesHeadingHtml,
$referencesHtml,
- $collapseReferences ? 'wikibase-initially-collapsed' :
''
+ $references->isEmpty() ? '' :
'wikibase-initially-collapsed'
);
}
diff --git a/view/tests/phpunit/EmptyEditSectionGeneratorTest.php
b/view/tests/phpunit/EmptyEditSectionGeneratorTest.php
deleted file mode 100644
index 5b73e3b..0000000
--- a/view/tests/phpunit/EmptyEditSectionGeneratorTest.php
+++ /dev/null
@@ -1,98 +0,0 @@
-<?php
-
-namespace Wikibase\View\Tests;
-
-use PHPUnit_Framework_TestCase;
-use Wikibase\DataModel\Entity\PropertyId;
-use Wikibase\DataModel\Snak\PropertyNoValueSnak;
-use Wikibase\DataModel\Statement\Statement;
-use Wikibase\View\EmptyEditSectionGenerator;
-
-/**
- * @covers Wikibase\View\EmptyEditSectionGenerator
- *
- * @group Wikibase
- * @group WikibaseView
- *
- * @license GPL-2.0+
- * @author Adrian Heine <[email protected]>
- */
-class EmptyEditSectionGeneratorTest extends PHPUnit_Framework_TestCase {
-
- /**
- * @dataProvider getAddStatementToGroupSectionProvider
- */
- public function testGetAddStatementToGroupSection( $propertyId,
$entityId ) {
- $generator = $this->newEmptyEditSectionGenerator();
-
- $this->assertEquals(
- '',
- $generator->getAddStatementToGroupSection( $propertyId,
$entityId )
- );
- }
-
- public function getAddStatementToGroupSectionProvider() {
- return [
- [ new PropertyId( 'P1' ), null ]
- ];
- }
-
- /**
- * @dataProvider getLabelDescriptionAliasesEditSectionProvider
- */
- public function testGetLabelDescriptionAliasesEditSection(
$languageCode, $entityId ) {
- $generator = $this->newEmptyEditSectionGenerator();
-
- $this->assertEquals(
- '',
- $generator->getLabelDescriptionAliasesEditSection(
$languageCode, $entityId )
- );
- }
-
- public function getLabelDescriptionAliasesEditSectionProvider() {
- return [
- [ 'en', new PropertyId( 'P1' ) ]
- ];
- }
-
- /**
- * @dataProvider getSiteLinksEditSectionProvider
- */
- public function testGetSiteLinksEditSection( $entityId ) {
- $generator = $this->newEmptyEditSectionGenerator();
-
- $this->assertEquals(
- '',
- $generator->getSiteLinksEditSection( $entityId )
- );
- }
-
- public function getSiteLinksEditSectionProvider() {
- return [
- [ new PropertyId( 'P1' ) ]
- ];
- }
-
- /**
- * @dataProvider getStatementEditSection
- */
- public function testGetStatementEditSection( $statement ) {
- $generator = $this->newEmptyEditSectionGenerator();
-
- $this->assertEquals(
- '',
- $generator->getStatementEditSection( $statement )
- );
- }
-
- public function getStatementEditSection() {
- return [
- [ new Statement( new PropertyNoValueSnak( new
PropertyId( 'P1' ) ) ) ]
- ];
- }
-
- private function newEmptyEditSectionGenerator() {
- return new EmptyEditSectionGenerator();
- }
-
-}
diff --git a/view/tests/phpunit/StatementHtmlGeneratorTest.php
b/view/tests/phpunit/StatementHtmlGeneratorTest.php
index 99e0506..d928706 100644
--- a/view/tests/phpunit/StatementHtmlGeneratorTest.php
+++ b/view/tests/phpunit/StatementHtmlGeneratorTest.php
@@ -117,11 +117,7 @@
/**
* @dataProvider referencesProvider
*/
- public function testCollapsedReferences(
- Statement $statement,
- $editSectionHtml,
- $expected
- ) {
+ public function testCollapsedReferences( Statement $statement,
$expected ) {
$templateFactory = TemplateFactory::getDefaultInstance();
$statementHtmlGenerator = new StatementHtmlGenerator(
$templateFactory,
@@ -130,7 +126,7 @@
new DummyLocalizedTextProvider()
);
- $html = $statementHtmlGenerator->getHtmlForStatement(
$statement, $editSectionHtml );
+ $html = $statementHtmlGenerator->getHtmlForStatement(
$statement, '' );
$this->assertSame(
$expected ? 1 : 0,
@@ -145,10 +141,8 @@
$referencedStatement->addNewReference( $snak );
return [
- [ $statement, '', false ],
- [ $statement, '<EDIT SECTION>', false ],
- [ $referencedStatement, '', false ],
- [ $referencedStatement, '<EDIT SECTION>', true ],
+ [ $statement, false ],
+ [ $referencedStatement, true ],
];
}
--
To view, visit https://gerrit.wikimedia.org/r/400685
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ifc8ac520f70914c3ee5e558afc7cfe82b409b737
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Thiemo Kreuz (WMDE) <[email protected]>
Gerrit-Reviewer: WMDE-leszek <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits