Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1541 remove deprecated function #1543

Merged
merged 2 commits into from
Jul 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -531,32 +531,31 @@ public function getAgency($nid) {
public function getNode($nid, $mode) {
$vid = 0;

// Do not use node of moderation state archived.
$id = $this->database
->query('SELECT id FROM content_moderation_state_field_data
WHERE moderation_state = :mstate AND content_entity_id = :nid',
[':mstate' => 'archived', ':nid' => $nid])
->fetchField();
if ($id) {
return NULL;
}

if ($mode == "published") {
$vid = $this->database
->query('SELECT MAX(vid) AS vid FROM node_field_revision WHERE status = 1 AND nid = :nid', [':nid' => $nid])
->fetchField();
$query = $this->entityTypeManager->getStorage('node')
->getQuery()
->allRevisions()
->condition('nid', $nid)
->condition('status', 1)
->sort('vid', 'DESC')
->range(0, 1)
->accessCheck(TRUE);
}
elseif ($mode == "draft") {
$vid = $this->database
->query('SELECT MAX(vid) AS vid FROM node_field_revision WHERE nid = :nid', [':nid' => $nid])
->fetchField();
}
else {
// @todo Unknown
$query = $this->entityTypeManager->getStorage('node')
->getQuery()
->allRevisions()
->condition('nid', $nid)
->sort('vid', 'DESC')
->range(0, 1)
->accessCheck(TRUE);
}

if ($vid) {
$node = node_revision_load($vid);
$result = $query->execute();

if (!empty($result)) {
$revision_id = key($result);
$node = $this->entityTypeManager->getStorage('node')->loadRevision($revision_id);
}
else {
$node = NULL;
Expand Down
Loading