Hello,

I just installed the 7.x-1.1+4-dev version of the module in my test environment. I have a user that can access all published content and only blog post unpublished content. I logged in as the user and accessed the Content page (/admin/content), then selected status = not published and clicked the filter button. All blog posts displayed, both published and not published.

Thank you. Ann.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

ann b’s picture

Title: Content Page: Status Field Not Working » Content Overview Page: Status Field Not Working
ann b’s picture

Core is setting the status field to published.

file: node.admin.inc
function: node_admin_nodes()

if (!user_access('bypass node access')) {
    // If the user is able to view their own unpublished nodes, allow them
    // to see these in addition to published nodes. Check that they actually
    // have some unpublished nodes to view before adding the condition.
    if (user_access('view own unpublished content') && $own_unpublished = db_query('SELECT nid FROM {node} WHERE uid = :uid AND status = :status', array(':uid' => $GLOBALS['user']->uid, ':status' => 0))->fetchCol()) {

      $query->condition(db_or()
        ->condition('n.status', 1)
        ->condition('n.nid', $own_unpublished, 'IN')
      );


}

    else {
      // If not, restrict the query to published nodes.
      $query->condition('n.status', 1);
    }
  }

This code is called after the status field from the filter on the Content Overview page is added to the query (or not if the value is set to any). This appears to be a bug. Then the view_unpublished module removes any status conditions it finds in the query. It used to remove the status field only if it was the second to last condition in the query. It seems to be trying to determine which condition was added by node_admin_nodes() .

if (isset($condition['field']) && $condition['field'] === 'n.status') {

            // This condition is (probably) coming from
            // modules/node/node.admin.inc,
            // function node_admin_nodes(): $query->condition('n.status', 1);
            // We don't want it.
			    unset($conditions[$key]);
}

Does anyone have any insight on this? Have the maintainers decided to show all of the content the user has view_unpublished rights to, regardless of whether or not it's published? Then the filter status field is ignored?

ann b’s picture

Summary:

Drupal Core 7.27
file: node.admin.inc
function: node_admin_nodes()

  1. Users with bypass node access are not affected by this issue.
  2. Regular users can see published nodes, and some can see their own unpublished content.

View Unpublished Module 7.x-1.1
file: view_unpublished.module
function: view_unpublished_query_alter($query)

  1. Users with bypass node access are not affected by this issue.
  2. Regular users will have the status condition removed from the query if it is the last condition. This condition may have been added by core.

Issue: Unpublished content does not show up for regular users.

View Unpublished Module 7.x-1.1+4-dev
file: view_unpublished.module
function: view_unpublished_query_node_access_alter($query)

  1. All users will have any status condition(s) removed from the query.

Issue: The status field setting on the Content Overview Page is ignored.

irmela’s picture

Hey there,

I'm having the same Problem. Would be great if there would be a patch to solve it.

Thanks!

ann b’s picture

We used views to created a separate page to find blog posts. It looks very similar to the Content Overview Page, and took less than 15 minutes to create. We created a view displayed as a page, selected the table format, and used exposed filters. Now our blog post users can filter the blog posts and view published and/or unpublished posts. We added some other filters as well.

toelli’s picture

I looked into this problem and this patch i wrote should fix this.

entendu’s picture

Status: Active » Closed (duplicate)

This looks like a dupe of #1192074. I am applying a fix there.