/** * @dataProvider entityRedirectProvider */ public function testGetEntityRedirect(EntityContent $content, EntityRedirect $redirect = null) { $this->assertEquals($content->getEntityRedirect(), $redirect); if ($redirect === null) { $this->assertNull($content->getRedirectTarget()); } else { $this->assertNotNull($content->getRedirectTarget()); } }
/** * Returns modification updates for the given EntityContent. * * @see Content::getSecondaryDataUpdates * * @since 0.5 * * @param EntityContent $content * @param Title $title * * @return DataUpdate[] */ public function getEntityModificationUpdates(EntityContent $content, Title $title) { $updates = array(); $entityId = $content->getEntityId(); //FIXME: we should not need this! if ($entityId === null) { $entityId = $this->getIdForTitle($title); } if ($content->isRedirect()) { // Remove the entity from the terms table since it's now a redirect. $updates[] = new DataUpdateAdapter(array($this->termIndex, 'deleteTermsOfEntity'), $entityId); // Register the redirect from the EntityPerPage table. $updates[] = new DataUpdateAdapter(array($this->entityPerPage, 'addRedirectPage'), $entityId, $title->getArticleID(), $content->getEntityRedirect()->getTargetId()); } else { // Register the entity in the EntityPerPage table. $updates[] = new DataUpdateAdapter(array($this->entityPerPage, 'addEntityPage'), $entityId, $title->getArticleID()); // Register the entity in the terms table. $updates[] = new DataUpdateAdapter(array($this->termIndex, 'saveTermsOfEntity'), $content->getEntity()); } // Call the WikibaseEntityModificationUpdate hook. // Do this after doing all well-known updates. $updates[] = new DataUpdateAdapter('wfRunHooks', 'WikibaseEntityModificationUpdate', array($content, $title)); return $updates; }