Resources

My Agape try

Your Agape try


Support Forum

You must be logged in to post Login Register

Search 
Search Forums:


 




Category data being stripped by RS during programmatic post creation

UserPost

5:21 pm
May 16, 2011


Jpadie

Member

posts 6

1

I am using RS 1.3.7 and WP 3.1

I know that neither of these are up to date. It's a test cycle thing - the site is highly complex and very sensitive and i am loathe to change either version number without good reason.

I have a script that is run from the command line that programmatically inserts about 15000 posts and attachments.  the category for each post is ascertained via a keyword matching algorithm.

the first 3000 or so posts all landed in WP with no category.  eventually I narrowed this down to rolescoper. turning it off fixed the problem.

the posts are being loaded with an author = the super user (userID = 1) and full rights are given to the admin to do anything.  

is this a known bug fixed in a later release?  or is this perhaps deliberate behaviour (in which case workaround advice would be very welcome)?

I believe that it is the function cr_get_posted_object_terms( $taxonomy ) that causes the problem but I am not certain.  I tried to spoof it by manually setting the $_POST['post_category'] superglobal but this had no effect.


4:59 am
May 17, 2011


Kevin

Admin

posts 2503

2

Jpadie said:

I have a script that is run from the command line that programmatically inserts about 15000 posts and attachments.



Does that mean you are using wget or some other command line app to retrieve http directly? If so, how is your login cookie stored/retrieved? Are you sure the resulting WP instance is recognizing the current user as your super admin?

If the issue is with your login recognition, you can probably work around Role Scoper's intended limiting of category selection for new posts by editing role-scoper/admin/filters-admin-save_rs.php, function scoper_flt_pre_object_terms(), as follows:

change:

if ( is_content_administrator_rs() || defined('DISABLE_QUERYFILTERS_RS') )
   return $selected_terms;

to:

if ( is_content_administrator_rs() || defined('DISABLE_QUERYFILTERS_RS') || ! empty( $_REQUEST['my_secret_uri_variable'] ) )
   return $selected_terms;

5:20 am
May 17, 2011


Jpadie

Member

posts 6

3

Hi Kevin

no - this is a direct command line call.  php -f /path/to/script.

and then in the app the core stuff is bootstrapped via wp-load.php.

no user is being set.  The post author is being set programmatically.

might it be enough just to set the current user programmatically through wp_set_current_user()?

thanks

Justin

7:23 am
May 17, 2011


Kevin

Admin

posts 2503

4

Jpadie said:

might it be enough just to set the current user programmatically through wp_set_current_user()?


Yes, you'll have to either set the current user to an Administrator or implement a workaround along the lines of what I posted above.


About the Agapetry forum

Currently Online:

10 Guests

Maximum Online: 150

Forums:

Groups: 2

Forums: 7

Topics: 1245

Posts: 5653

Members:

There are 1255 members

There are 1 guests


Kevin has made 2503 posts

Top Posters:

metal450 - 178

Ragnar - 108

YikYak - 70

whiteorb - 49

Daisy - 35

Administrator: Kevin | Moderators: Kevin