Make WordPress Core

Opened 5 years ago

Closed 8 months ago

Last modified 7 months ago

#54006 closed defect (bug) (worksforme)

Wp Multisite Get, Add, Update and Delete Site Meta Issue.

Reported by: leeml's profile leeml Owned by:
Milestone: Priority: normal
Severity: normal Version: 5.8
Component: Options, Meta APIs Keywords: dev-feedback
Focuses: multisite Cc:

Description

Just working on some code to help with WP Multisite integration...

I have noticed that the add_site_meta function is currently not working.

I had a look through the functions in wp-includes/ms-site.php and found that the first parameter in the 'add_metadata' function called by add_site_meta (line 1012) is 'blog'.

I figured since you changed the blogmeta table to sitemeta that something might be amiss. If the metadata is added thus:

add_metadata( 'site', 1, 'test_site_feta', 'cheese', false );

All appears to work okay, however this does not;

add_metadata( 'blog', 1, 'test_site_feta', 'cheese', false );

Think its a bug...until I had a closer look I had to use MySQL queries to add the site meta.

Change History (5)

#1 @leeml
5 years ago

To be honest 'add_site_meta' is working for the blog meta table, I was looking at an instance where site meta needed to be set via a frontend extension for what is usually a user profile specific action. Hence the need to update the site meta table, in this case anyway.

Which is doable given the use of add_metadata.

It would be useful I guess if the site meta functions could work with the site meta table allowing for then existing site meta functions being renamed to blog meta. i.e. update_blogmeta and so on...

Hence the initial confusion I guess...everything else seems to be table specific i.e. post meta,term meta, user meta and so on.

#2 @SergeyBiryukov
5 years ago

  • Component changed from Database to Options, Meta APIs

#3 @leeml
5 years ago

I found the network option functions in the end, oh boy!

#4 @callumbw95
8 months ago

  • Resolution set to worksforme
  • Status changed from new to closed

Hi @leeml,

I have taken a quick look into this and can confirm that the mentioned function is working correctly on the latest version. I am not sure if potentially there was an issue in the past that has been solved, but I cannot find any mention of this, or any other issues? One thing I did test out is that when the site is not a multisite this function "fails" correctly. However in a multisite environment this function does work as intended. As of such I don't believe this is an issue, and I will close this ticket. But if you do have anything else to add please reopen the ticket and we can continue the discussion! 😃

#5 @peterwilsoncc
7 months ago

  • Milestone Awaiting Review deleted

Related: #61467.

The network options populate the wp_sitemeta table which can cause confusion.

There's also the confusion of referring to sites in the admin as blogs in code, and networks in the admin as sites in code for legacy and back-compat reasons.

Note: See TracTickets for help on using tickets.