Skip to content

Commit

Permalink
Merge pull request #1200 from UN-OCHA/berliner/HPC-9890
Browse files Browse the repository at this point in the history
HPC-9890: Don't request rendered content during migrations
  • Loading branch information
berliner authored Nov 20, 2024
2 parents d2afeee + 6807468 commit 4a2b1a9
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function loadNodeForRemoteContent(RemoteContentInterface $content) {
/**
* {@inheritdoc}
*/
public function loadRemoteContentForNode(NodeInterface $node, $refresh = FALSE) {
public function loadRemoteContentForNode(NodeInterface $node, $refresh = FALSE, $rendered = TRUE) {
$remote_field = $this->getRemoteFieldName();
if (!$node->hasField($remote_field)) {
return;
Expand All @@ -81,7 +81,7 @@ public function loadRemoteContentForNode(NodeInterface $node, $refresh = FALSE)
if ($refresh) {
$remote_source_instance->disableCache();
}
return $remote_source_instance->getArticle($article_id);
return $remote_source_instance->getArticle($article_id, $rendered);
}

/**
Expand Down Expand Up @@ -172,7 +172,7 @@ protected function getMigration(NodeInterface $node) {
*/
public function updateNodeFromRemote(NodeInterface $node, $dry_run = FALSE, $reset = FALSE) {
$remote_field = self::REMOTE_ARTICLE_FIELD;
$article = $this->loadRemoteContentForNode($node, TRUE);
$article = $this->loadRemoteContentForNode($node, TRUE, FALSE);
if (!$article) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public function getDocument($id) {
/**
* {@inheritdoc}
*/
public function getArticle($id) {
public function getArticle($id, $rendered = TRUE) {
$fields = [
'id',
'title',
Expand All @@ -103,15 +103,15 @@ public function getArticle($id) {
'title',
'tags',
];
$fields['content'] = [
$fields['content'] = array_filter([
'id',
'uuid',
'type',
'typeLabel',
'promoted',
'rendered',
$rendered ? 'rendered' : NULL,
'configuration',
];
]);
$fields['image'] = [
'credits',
'imageUrl',
Expand All @@ -127,16 +127,16 @@ public function getArticle($id) {
/**
* {@inheritdoc}
*/
public function getParagraph($id) {
$fields = [
public function getParagraph($id, $rendered = TRUE) {
$fields = array_filter([
'id',
'uuid',
'type',
'typeLabel',
'promoted',
'rendered',
$rendered ? 'rendered' : NULL,
'configuration',
];
]);
$paragraph_data = $this->fetchData('paragraph', ['id' => $id], $fields);
return new RemoteParagraph($paragraph_data, $this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,13 @@ public function searchDocumentsByTitle($title);
*
* @param int $id
* The id of the article on the remote.
* @param bool $rendered
* Allow to switch off rendering.
*
* @return \Drupal\ghi_content\RemoteContent\RemoteArticleInterface
* The article object.
*/
public function getArticle($id);
public function getArticle($id, $rendered = TRUE);

/**
* Search articles by title.
Expand All @@ -85,11 +87,13 @@ public function searchArticlesByTitle($title);
*
* @param int $id
* The id of the paragraph on the remote.
* @param bool $rendered
* Allow to switch off rendering.
*
* @return \Drupal\ghi_content\RemoteContent\RemoteParagraphInterface
* The result object.
*/
public function getParagraph($id);
public function getParagraph($id, $rendered = TRUE);

/**
* Issue a query against a remote source.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function defaultConfiguration() {
/**
* {@inheritdoc}
*/
public function getArticle($id) {
public function getArticle($id, $rendered = TRUE) {
$json = $this->getFixture('article', $id);
return $json->article ? new RemoteArticle($json->article, $this) : NULL;
}
Expand All @@ -66,7 +66,7 @@ public function getArticleTitle($id) {
/**
* {@inheritdoc}
*/
public function getParagraph($id) {
public function getParagraph($id, $rendered = TRUE) {
// @todo Implement this.
return (object) [];
}
Expand Down

0 comments on commit 4a2b1a9

Please sign in to comment.