[wp-trac] [WordPress Trac] #38276: "Is thing public" API

WordPress Trac noreply at wordpress.org
Tue Oct 11 06:17:53 UTC 2016

#38276: "Is thing public" API
 Reporter:  jdgrimes         |       Owner:
     Type:  feature request  |      Status:  new
 Priority:  normal           |   Milestone:  Awaiting Review
Component:  Role/Capability  |     Version:  trunk
 Severity:  normal           |  Resolution:
 Keywords:                   |     Focuses:

Comment (by PieWP):

 In regards of combining the {{{WP_Query}}} and the

 Keeping the Query filter aligned with a custom callback as suggested is
 quite hard. You often have to modify the query in strange ways typing
 actual custom SQL; which in its turn might cause SQL errors for many
 reasons. In addition to that your callback gets modified by the entire
 codebase due to filters. So the callback you initially set up might easily
 dealign when installing other plugins who (unintentionally) dealign your
 {{{is_thing_accessable()}}} check.

 //these are the issues I encountered with our client for whom we build a
 similar extension//

 == Alternative approach ==

 An alternative approach would be to use a binary system similar to for
 instance your file system capabilities. Thing is that your check is way
 more complex so it would be more similar to the error_setting value in
 your php.ini. In this solution you would map every capability to a prime
 number, your current rights would be a sum of this prime number which you
 could compare against a new column within the database.

 Using these a binary tree you get a common divider shared within the
 meta_caps which you can use in your {{{is_thing_accessable}}} and in your
 {{{WP_Query}}}. This mapping from capability to a binary would obviously
 occure under 'under water' to keep it as user friendly as possible.

 The massive issue of this approach is: how do you build the binary tree?
 Your capability should **always** have the same binary value assigned to
 it; otherwise you would get a mismatch in your rights. That would hint
 towards storing a mapper in an option, which is fine until you try to
 transfer or import the posts from another system. How would you merge or
 handle capabilites whom are not known in the imported system? Or how would
 you handle the {{{'read'}}} capability which has a value of {{{'1'}}} in
 your system but a value of {{{'3'}}} in the imported system?  (although
 this ticket would effect importing in some way regardless of the chosen

 || Pro || Con ||
 || + Using binary comparisons your database queries will remain fast || -
 How to build up the binary tree in a stable way? ||
 || + compare issues between code and database solved || - not very human
 readable values ||
 || + Very easy in usage for new WP developers || ||

Ticket URL: <https://core.trac.wordpress.org/ticket/38276#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform

More information about the wp-trac mailing list