xwp / stream

🗄️ Stream plugin for WordPress

Home Page:https://wordpress.org/plugins/stream/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

"Reset Stream Database" doesn't clear everything

powelski opened this issue · comments

In some way, I got empty records that can't be deleted with Reset Stream Database option. I figured out that it does INNER JOIN on stream_context and stream_meta tables, so if there are no relations in either of those, this record is being skipped. It should be changed, because custom connectors might save logs without meta.

empty records

What does type column in stream table keep by the way?

@powelski It is used by other extensions, similar to a "post type", such as notification_rule.

So we don't want to delete that data, only the stream type and meta/contexts for records of that type, which is why we used the INNER JOIN.

@powelski So I think the solution here will just be to add another DELETE statement immediately after the one we're already using, correct?

$wpdb->query( "DELETE from {$wpdb->stream} WHERE type = 'stream'" );

So we first delete stream rows with the contexts/meta tied to them, then go back through and do a cleanup in case there were any rows left that weren't tied to those other tables.

@fjarrett LEFT JOIN is even better idea.