Jump to content

How do the page statuses "draft" and "versions" work?


MoritzLost
 Share

Recommended Posts

I'm trying to build a bitwise filter for a database query for my textformatter module, and I stumbled over some page statuses I don't quite understand:

/**
* Page has pending draft changes (name: "draft"). 
* #pw-internal
* 
*/
const statusDraft = 64;

/**
* Page has version data available (name: "versions").
* #pw-internal
* 
*/
const statusVersions = 128;

If I'm not mistaked, there's no way to create multiple draft of a page in the ProcessWire core without module, is that correct? I initially assumed was the status assigned to unpublished pages, but the unpublished status corresponds to id 2048. Is the only way to create drafts with the ProDrafts module?

For my purposes, I just need to understand how I should treat those statuses. I'm trying to get all pages that are published and either hidden or not hidden (I want to make this configurable). Do I need to exclude pages that have the statusDraft, or statusVersions? Only one of them? Only in combination with other statuses? Or can I safely ignore those (so it's fine if the pages have the status or not)? I don't own the ProDrafts module, so I can't check the code to see how individual drafts are stored and how the draft ids correspond to the published id.

Any insight into those statuses is appreciated. Thanks in advance!

Link to comment
Share on other sites

Hi horst,

thanks for the reply! I'll use that check to make sure no pages are linked that shouldn't be visible. However, I would still like to filter out pages with statuses that will never be viewable. I'm querying the database directly to get a list of pages for performance reasons. Since I'm performing one costly regex per title, I would like to only get the pages that are actually published & viewable, so I still need to understand all status IDs to determine whether they're relevant for the bitmask ...

I looked into what checks $page->viewable perfoms, but haven't been able to find a reference to the IDs for "draft" and "versions", so maybe they are not relevant after all?

  • Like 1
Link to comment
Share on other sites

4 hours ago, MoritzLost said:

I looked into what checks $page->viewable perfoms, but haven't been able to find a reference to the IDs for "draft" and "versions", so maybe they are not relevant after all?

I think this is a question for @ryan (?)

  • Like 1
Link to comment
Share on other sites

Yup, these are used in ProDrafts. See attached files. I guess you can use them as wel, but since they are marked internal I would not rely heavily and them and in general usage should be avoided.

 

Screen Shot 2018-11-19 at 19.58.35.png

Screen Shot 2018-11-19 at 19.59.56.png

  • Like 2
Link to comment
Share on other sites

Hey @arjen, thanks for the reply! I don't want to use them myself, I just need to make sure I don't included unpublished pages or drafts in my module (see link above). But I've added some additional checks for that purpose now, and I guess the draft module will surely add the correct status for unpublished drafts, so it should be ok. Anyway, thanks for your help!

  • Thanks 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...