berlindb / core

All of the required core code
MIT License
252 stars 27 forks source link

Query::delete_all_item_meta() may not be working correctly #84

Closed JJJ closed 3 years ago

JJJ commented 3 years ago

Needs confirmation.

This line specifically appears (visually, from my eyes) to not be correct: https://github.com/berlindb/core/blob/131a91f6c4d5d97445d1540c02153d00f74beae5/query.php#L2400

And probably should be something like:

    delete_metadata_by_mid( $this->apply_prefix( $this->item_name ), $mid );

This is because the metadata_by_mid() functions in WordPress call _get_meta_table() internally, so we are unable to use Query::get_meta_table_name() because it would double-suffix the table name resulting in something like sc_eventmetameta .

Sorry for the not-so-good format of this issue. Juggling a few things right now and wanted to jot this down before I forgot about it.

JJJ commented 3 years ago

If this is confirmed and you'd like to submit a PR, don't do exactly what I proposed above. I only did it that way to make the issue more simple to identify at a glance.

It would be best to create a variable from $this->apply_prefix( $this->item_name ) outside of the foreach loop, because it reduces the number of nested method calls for every row being deleted.