post_status and post_type

classic Classic list List threaded Threaded
20 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

post_status and post_type

Ryan Boren
Currently, post_status contains both type and status information.  A
status of 'publish', 'private', or 'draft' has an assumed type of
'post'.  A status of 'static' assumes a type of 'page' and a status of
'publish'.  There is currently no way to have a page that has a status
other than 'publish'.

No longer.  The attached patch provides for a post_type of 'post',
'page', or 'attachment' and a post_status of 'publish', 'private',
'draft', or 'inherit'.  This allows a 'page' to have any status, which
was previously not possible.  "Write->Page" and "Manage->Pages"  now
have a "Page Status" radio box.  The page queries need to be looked over
to make sure they are showing only published pages where appropriate.
wp_list_pages() already excludes non-published pages.

This will surely break some plugins.  We can write some compatibility
code that plugins can include to help them deal with the change.  While
doing that, I'd like to audit queries done by plugins and see which ones
would make good candidates for inclusion in WP core abstracted behind a
function call.

Ryan



_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: post_status and post_type

Choan Gálvez
On 08/02/06, Ryan Boren <[hidden email]> wrote:
> Currently, post_status contains both type and status information.  A
> status of 'publish', 'private', or 'draft' has an assumed type of
> 'post'.  A status of 'static' assumes a type of 'page' and a status of
> 'publish'.  There is currently no way to have a page that has a status
> other than 'publish'.
>
> No longer.  The attached patch provides for a post_type of 'post',
> 'page', or 'attachment' and a post_status of 'publish', 'private',
> 'draft', or 'inherit'.

That's great! The impossibility of creating unpublished pages has been
(for me) the great stopper to use WP as my clients' CMS.

Could it go into 2.0.2?

> This allows a 'page' to have any status, which
> was previously not possible.  "Write->Page" and "Manage->Pages"  now
> have a "Page Status" radio box.  The page queries need to be looked over
> to make sure they are showing only published pages where appropriate.
> wp_list_pages() already excludes non-published pages.
>
> This will surely break some plugins.  We can write some compatibility
> code that plugins can include to help them deal with the change.  While
> doing that, I'd like to audit queries done by plugins and see which ones
> would make good candidates for inclusion in WP core abstracted behind a
> function call.
Yep, that'll be good.

By the way, no attachment.

--
Choan

_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: post_status and post_type

Ryan Boren
On Wed, 2006-02-08 at 11:04 +0100, Choan C. Gálvez wrote:
> That's great! The impossibility of creating unpublished pages has been
> (for me) the great stopper to use WP as my clients' CMS.
>
> Could it go into 2.0.2?

It's too intrusive for 2.0.2.  Probably 2.1.

> By the way, no attachment.

I think it was scrubbed.  Try this.

http://boren.nu/downloads/post_type.diff.txt

Ryan

_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: post_status and post_type

Choan Gálvez
On 08/02/06, Ryan Boren <[hidden email]> wrote:

> On Wed, 2006-02-08 at 11:04 +0100, Choan C. Gálvez wrote:
> > That's great! The impossibility of creating unpublished pages has been
> > (for me) the great stopper to use WP as my clients' CMS.
> >
> > Could it go into 2.0.2?
>
> It's too intrusive for 2.0.2.  Probably 2.1.
>
> > By the way, no attachment.
>
> I think it was scrubbed.  Try this.
>
> http://boren.nu/downloads/post_type.diff.txt
Thanks, I'll try it.

--
Choan

_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: post_status and post_type

David House
In reply to this post by Ryan Boren
On 08/02/06, Ryan Boren <[hidden email]> wrote:
> I think it was scrubbed.  Try this.

Mailman seems to scrub attachments with 'malicious' extensions, and I
guess .diff is among them (actually, more likely, it whitelists).

If you rename it to a .txt it works.

--
-David House, [hidden email], http://xmouse.ithium.net
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: post_status and post_type

Ryan Boren
On Wed, 2006-02-08 at 14:08 +0000, David House wrote:
> On 08/02/06, Ryan Boren <[hidden email]> wrote:
> > I think it was scrubbed.  Try this.
>
> Mailman seems to scrub attachments with 'malicious' extensions, and I
> guess .diff is among them (actually, more likely, it whitelists).
>
> If you rename it to a .txt it works.

Let's try this then.

BTW, the link I sent earlier was the wrong diff.  This one should be the
right one.

Ryan

_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: post_status and post_type

Owen Winkler
Ryan Boren wrote:
> Let's try this then.

No workie.

Owen

_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: post_status and post_type

Ryan Boren
On Wed, 2006-02-08 at 15:22 -0500, Owen Winkler wrote:
> Ryan Boren wrote:
> > Let's try this then.
>
> No workie.

Is this thing on?

http://boren.nu/downloads/status_type.diff.txt


Ryan

_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: post_status and post_type

Ryan Boren
Behold the changeset of destruction.

http://trac.wordpress.org/changeset/3510

Feed trac with fixes for any broken bits.

Ryan
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: post_status and post_type

Mark Jaquith
On Feb 9, 2006, at 5:09 AM, Ryan Boren wrote:

> Behold the changeset of destruction.

::quiver::

What about post_status="future"?  That still on the table?

* Would require pseudo cron
* Would make post queries much faster as well as make them cacheable,  
as the dynamic $now would be eliminated
--
Mark Jaquith
http://txfx.net/


_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: post_status and post_type

Ryan Boren
Mark Jaquith wrote:

> On Feb 9, 2006, at 5:09 AM, Ryan Boren wrote:
>
>> Behold the changeset of destruction.
>
>
> ::quiver::
>
> What about post_status="future"?  That still on the table?
>
> * Would require pseudo cron
> * Would make post queries much faster as well as make them cacheable,  
> as the dynamic $now would be eliminated

Would be nice.  I haven't looked at any of the pseudo cron
implementations that were suggested?  Any preferences?  Want to work up
a patch?

Ryan
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: post_status and post_type

Mark Jaquith
On Feb 9, 2006, at 5:21 AM, Ryan Boren wrote:

> Would be nice.  I haven't looked at any of the pseudo cron  
> implementations that were suggested?  Any preferences?  Want to  
> work up a patch?

My thoughts (many of which are not original... just condensing):

* Specificity of fewer than 5 minutes might be overkill
* Create wp-cron.php?key=[uniquemd5] so power users with real cron  
can set it to wget that file so that pseudo cron is never fired on a  
user-requested load
* Hooks for arbitrary time increments would be cool.  
"every_X_minutes" ... "every_X_hours" ... "every_X_days"
* WordPress would use it to
        # publish "future" posts
        # do periodic (weekly?) cleanup operations like:
                + Recalculate category/comment/post counts that may be off because  
of plugins not using the API
                + Perform misc checks for problems, and notify the admin
        # clean out old "spam" comments
        # check for plugin/WP updates
        # download Dashboard feeds
        # send pings/trackbacks for future posts when they are published

--
Mark Jaquith
http://txfx.net/


_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: post_status and post_type

Owen Winkler
In reply to this post by Ryan Boren
Ryan Boren wrote:
> Behold the changeset of destruction.
>
> http://trac.wordpress.org/changeset/3510
>

Curious on this one point:

Why is post_type a varchar(100) and not an enum('post','page',
'attachment')?  Wouldn't that be faster?

Owen





_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: post_status and post_type

David Chait
I can give a personal opinion on why I'd prefer it as-is.  While enums may
be faster, varchars are extensible on-the-fly (i.e. plugins).  It was a pain
when I found comment tagging as an enum with ('0','1','spam') -- which means
my anti-spam plugin can't use the existing moderation field for tagging
'potential spam' in grades without a secondary table.  Maybe I might come up
with a plugin that manages a new post type, new content type.  I find
varchars useful for more open expansion, while enums are good if you really
have a fixed field and want the code and db to be more readable ('string'
rathing than 'index').  Of course, varchars are just as readable. ;)  It's
that an index field (say 1-3) is less readable than an enum
('do','re','mi').

I would assume by the nature of an enum it should be faster -- there is
still some kind of conversion going on matching input in a query to the enum
'slots' and converting to the corresponding index then doing the
select/insert, versus no conversion just a string select/insert.  If it's
really a numeric field under the covers, should be somewhat faster -- though
string compares on exact matches can be pretty fast (4 chars at a time on a
32-bit system, assuming no hash or anything to further accelerate).

Anyhow, I'd like to see more things pop out of enums unless critically
needed to prevent coding errors (which could also be done by defining an
array of possible values in the code, and allowing plugins to 'add'
potential values to match, then doing a sanity-compare against the array as
needed... slower, but infinitely extensible without changing the DB schema).

-d

----- Original Message -----
From: "Owen Winkler" <[hidden email]>
To: <[hidden email]>
Sent: Thursday, February 09, 2006 9:18 AM
Subject: Re: [wp-hackers] post_status and post_type


| Ryan Boren wrote:
| > Behold the changeset of destruction.
| >
| > http://trac.wordpress.org/changeset/3510
| >
|
| Curious on this one point:
|
| Why is post_type a varchar(100) and not an enum('post','page',
| 'attachment')?  Wouldn't that be faster?

_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: post_status and post_type

Choan Gálvez
In reply to this post by Owen Winkler
On 2/9/06, Owen Winkler <[hidden email]> wrote:

> Ryan Boren wrote:
> > Behold the changeset of destruction.
> >
> > http://trac.wordpress.org/changeset/3510
> >
>
> Curious on this one point:
>
> Why is post_type a varchar(100) and not an enum('post','page',
> 'attachment')?  Wouldn't that be faster?
Faster, probably.

I've been playing recently with Drupal, and do you know what? The
`nodes` table (more or less equivalent to WP `wp_posts`) contains a
`type` field.

This allows programmers to define new content types. Why should WP
restrict "types" to `post` and `page`?

--
Choan

_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: post_status and post_type

Craig-16
Choan said:
"This allows programmers to define new content types. Why should WP
restrict "types" to `post` and `page`?"

This is an especially valid point given the recent interest in WP-as-a-CMS
thread. I'd be willing to guess that this is something that will soon
change! :^)

Craig.
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: post_status and post_type

Jeff Minard
In reply to this post by Owen Winkler
Owen Winkler wrote:
> Why is post_type a varchar(100) and not an enum('post','page',
> 'attachment')?  Wouldn't that be faster?

Yes, enums are faster.

1) enums are a psuedo look-up table. MySQL stores a smallint val for
each enum and uses that when doing lookups. It's kind of like having a
lookup table and doing a join across them, except that mysql does it all
for you.

2) this means enums are compared, internally, as ints -- a much faster
query for mysql

3) it also means smaller storage space

4) it, consequently, means smaller index size

So, yes, enums *are* faster -- but by how much at the cost of locking
the "post types" down, is the real question. Probably not enough for the
vast majority of wordpress installs.

(Flip side of this arguement is: authors, have your plugins modify the
DB upon run to check for the enum def, if not there modify to add it.
SUPER problematic, but possible.)


I like the ideas stated later in the thread of leaving it a varchar to
allow others to make up their own post types. The only complication this
involves is whether or not WP would edit non-standard post_types or not.
Lot's of queries would be needing some updating to make sure they're
only pulling "post" post_types and so forth.

Also...

Mark Jaquith wrote:
> What about post_status="future"?  That still on the table?

+145,000,000

As otherwise stated, death to all "< $now" clauses.

Jeff
_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: post_status and post_type

Ryan Boren
In reply to this post by Owen Winkler
Owen Winkler wrote:

> Ryan Boren wrote:
>
>> Behold the changeset of destruction.
>>
>> http://trac.wordpress.org/changeset/3510
>>
>
> Curious on this one point:
>
> Why is post_type a varchar(100) and not an enum('post','page',
> 'attachment')?  Wouldn't that be faster?

The varchar is used for portability and flexibility.  We might change
all occurences of enums to varchars.  Those porting WordPress to other
DBs curse our use of enums.

Ryan

_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: post_status and post_type

Evan Broder
Ryan Boren wrote:
> Owen Winkler wrote:
> The varchar is used for portability and flexibility.  We might change
> all occurences of enums to varchars.  Those porting WordPress to other
> DBs curse our use of enums.
>
> Ryan
In theory, should this not just be a change of the database schema,
since code and queries will always compare values to strings anyway?

Doesn't seem like it should be that big of a deal (other than the whole
inertia issue)

Of course, I'm new to this, and more or less an idiot, so I may not know
what I'm talking about.

_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: post_status and post_type

Rob-67
In reply to this post by Ryan Boren
Ryan Boren wrote:

> Owen Winkler wrote:
>> Ryan Boren wrote:
>>
>>> Behold the changeset of destruction.
>>>
>>> http://trac.wordpress.org/changeset/3510
>>>
>>
>> Curious on this one point:
>>
>> Why is post_type a varchar(100) and not an enum('post','page',
>> 'attachment')?  Wouldn't that be faster?
>
> The varchar is used for portability and flexibility.  We might change
> all occurences of enums to varchars.  Those porting WordPress to other
> DBs curse our use of enums.
>
> Ryan
>
> _______________________________________________
> wp-hackers mailing list
> [hidden email]
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>
Is this general advice, to be applied to plugins as well?

--
Rob Miller
http://robm.me.uk/ | http://kantian.co.uk/

_______________________________________________
wp-hackers mailing list
[hidden email]
http://lists.automattic.com/mailman/listinfo/wp-hackers
Loading...