diff --git a/src/Xtools/Page.php b/src/Xtools/Page.php index cc76f64f9..b2a81e302 100644 --- a/src/Xtools/Page.php +++ b/src/Xtools/Page.php @@ -421,41 +421,45 @@ public function getCheckWikiErrors() */ public function getWikidataErrors() { - $errors = []; - - if (empty($this->getWikidataId())) { - return []; - } - - $wikidataInfo = $this->getRepository()->getWikidataInfo($this); - - $terms = array_map(function ($entry) { - return $entry['term']; - }, $wikidataInfo); - - $lang = $this->getLang(); - - if (!in_array('label', $terms)) { - $errors[] = [ - 'prio' => 2, - 'name' => 'Wikidata', - 'notice' => "Label for language $lang is missing", // FIXME: i18n - 'explanation' => "See: Help:Label", - ]; - } - - if (!in_array('description', $terms)) { - $errors[] = [ - 'prio' => 3, - 'name' => 'Wikidata', - 'notice' => "Description for language $lang is missing", // FIXME: i18n - 'explanation' => "See: Help:Description", - ]; - } - - return $errors; + // FIXME: wikidatawiki_p.wb_entity_per_page is no more. + // Figure out how to check for missing description, etc. + return []; + + // $errors = []; + + // if (empty($this->getWikidataId())) { + // return []; + // } + + // $wikidataInfo = $this->getRepository()->getWikidataInfo($this); + + // $terms = array_map(function ($entry) { + // return $entry['term']; + // }, $wikidataInfo); + + // $lang = $this->getLang(); + + // if (!in_array('label', $terms)) { + // $errors[] = [ + // 'prio' => 2, + // 'name' => 'Wikidata', + // 'notice' => "Label for language $lang is missing", // FIXME: i18n + // 'explanation' => "See: Help:Label", + // ]; + // } + + // if (!in_array('description', $terms)) { + // $errors[] = [ + // 'prio' => 3, + // 'name' => 'Wikidata', + // 'notice' => "Description for language $lang is missing", // FIXME: i18n + // 'explanation' => "See: Help:Description", + // ]; + // } + + // return $errors; } /** diff --git a/src/Xtools/ProjectRepository.php b/src/Xtools/ProjectRepository.php index 63eef46c3..f97975829 100644 --- a/src/Xtools/ProjectRepository.php +++ b/src/Xtools/ProjectRepository.php @@ -344,7 +344,7 @@ public function pageHasContent(Project $project, $namespaceId, $pageTitle) . " LIMIT 1"; $params = [ 'ns' => $namespaceId, - 'title' => $pageTitle, + 'title' => str_replace(' ', '_', $pageTitle), ]; $pages = $conn->executeQuery($query, $params)->fetchAll(); return count($pages) > 0; diff --git a/tests/Xtools/PageTest.php b/tests/Xtools/PageTest.php index 3d63ce850..181da3699 100644 --- a/tests/Xtools/PageTest.php +++ b/tests/Xtools/PageTest.php @@ -229,50 +229,50 @@ public function testUsersEdits() //$this->assertCount(3, $page->getRevisions($user)->getCount()); } - /** - * Wikidata errors. With this test getWikidataInfo doesn't return a Description, - * so getWikidataErrors should complain accordingly - */ - public function testWikidataErrors() - { - $pageRepo = $this->getMock(PagesRepository::class, ['getWikidataInfo', 'getPageInfo']); - - $pageRepo - ->method('getWikidataInfo') - ->with() - ->willReturn([ - [ - 'term' => 'label', - 'term_text' => 'My article', - ], - ]); - $pageRepo - ->method('getPageInfo') - ->with() - ->willReturn([ - 'pagelanguage' => 'en', - 'pageprops' => [ - 'wikibase_item' => 'Q123', - ], - ]); - - $page = new Page(new Project('exampleWiki'), 'Page'); - $page->setRepository($pageRepo); - - $wikidataErrors = $page->getWikidataErrors(); - - $this->assertArraySubset( - [ - 'prio' => 3, - 'name' => 'Wikidata', - ], - $wikidataErrors[0] - ); - $this->assertContains( - 'Description', - $wikidataErrors[0]['notice'] - ); - } + // /** + // * Wikidata errors. With this test getWikidataInfo doesn't return a Description, + // * so getWikidataErrors should complain accordingly + // */ + // public function testWikidataErrors() + // { + // $pageRepo = $this->getMock(PagesRepository::class, ['getWikidataInfo', 'getPageInfo']); + + // $pageRepo + // ->method('getWikidataInfo') + // ->with() + // ->willReturn([ + // [ + // 'term' => 'label', + // 'term_text' => 'My article', + // ], + // ]); + // $pageRepo + // ->method('getPageInfo') + // ->with() + // ->willReturn([ + // 'pagelanguage' => 'en', + // 'pageprops' => [ + // 'wikibase_item' => 'Q123', + // ], + // ]); + + // $page = new Page(new Project('exampleWiki'), 'Page'); + // $page->setRepository($pageRepo); + + // $wikidataErrors = $page->getWikidataErrors(); + + // $this->assertArraySubset( + // [ + // 'prio' => 3, + // 'name' => 'Wikidata', + // ], + // $wikidataErrors[0] + // ); + // $this->assertContains( + // 'Description', + // $wikidataErrors[0]['notice'] + // ); + // } /** * Test getErros and getCheckWikiErrors. @@ -292,15 +292,16 @@ public function testErrors() 'explanation' => 'This is how to fix the error' ], ]; - $wikidataErrors = [ - [ - 'prio' => 3, - 'name' => 'Wikidata', - 'notice' => 'Description for language en is missing', - 'explanation' => "See: Help:Description", - ], - ]; + // $wikidataErrors = [ + // [ + // 'prio' => 3, + // 'name' => 'Wikidata', + // 'notice' => 'Description for language en is missing', + // 'explanation' => "See: Help:Description", + // ], + // ]; + $wikidataErrors = []; $pageRepo->method('getCheckWikiErrors') ->willReturn($checkWikiErrors);