{"action":"created","issue":{"url":"https://api.github.com/repos/wp-cli/core-command/issues/76","repository_url":"https://api.github.com/repos/wp-cli/core-command","labels_url":"https://api.github.com/repos/wp-cli/core-command/issues/76/labels{/name}","comments_url":"https://api.github.com/repos/wp-cli/core-command/issues/76/comments","events_url":"https://api.github.com/repos/wp-cli/core-command/issues/76/events","html_url":"https://github.com/wp-cli/core-command/pull/76","id":343036360,"node_id":"MDExOlB1bGxSZXF1ZXN0MjAyNzkzODgz","number":76,"title":"Sanitize database at the end of install to prevent duplicate data","user":{"login":"javorszky","id":1196299,"node_id":"MDQ6VXNlcjExOTYyOTk=","avatar_url":"https://avatars1.githubusercontent.com/u/1196299?v=4","gravatar_id":"","url":"https://api.github.com/users/javorszky","html_url":"https://github.com/javorszky","followers_url":"https://api.github.com/users/javorszky/followers","following_url":"https://api.github.com/users/javorszky/following{/other_user}","gists_url":"https://api.github.com/users/javorszky/gists{/gist_id}","starred_url":"https://api.github.com/users/javorszky/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/javorszky/subscriptions","organizations_url":"https://api.github.com/users/javorszky/orgs","repos_url":"https://api.github.com/users/javorszky/repos","events_url":"https://api.github.com/users/javorszky/events{/privacy}","received_events_url":"https://api.github.com/users/javorszky/received_events","type":"User","site_admin":false},"labels":[{"id":582373504,"node_id":"MDU6TGFiZWw1ODIzNzM1MDQ=","url":"https://api.github.com/repos/wp-cli/core-command/labels/bug","name":"bug","color":"fc2929","default":true},{"id":636371098,"node_id":"MDU6TGFiZWw2MzYzNzEwOTg=","url":"https://api.github.com/repos/wp-cli/core-command/labels/command:core-multisite-install","name":"command:core-multisite-install","color":"c5def5","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/wp-cli/core-command/milestones/11","html_url":"https://github.com/wp-cli/core-command/milestone/11","labels_url":"https://api.github.com/repos/wp-cli/core-command/milestones/11/labels","id":3511393,"node_id":"MDk6TWlsZXN0b25lMzUxMTM5Mw==","number":11,"title":"1.0.11","description":null,"creator":{"login":"schlessera","id":83631,"node_id":"MDQ6VXNlcjgzNjMx","avatar_url":"https://avatars1.githubusercontent.com/u/83631?v=4","gravatar_id":"","url":"https://api.github.com/users/schlessera","html_url":"https://github.com/schlessera","followers_url":"https://api.github.com/users/schlessera/followers","following_url":"https://api.github.com/users/schlessera/following{/other_user}","gists_url":"https://api.github.com/users/schlessera/gists{/gist_id}","starred_url":"https://api.github.com/users/schlessera/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/schlessera/subscriptions","organizations_url":"https://api.github.com/users/schlessera/orgs","repos_url":"https://api.github.com/users/schlessera/repos","events_url":"https://api.github.com/users/schlessera/events{/privacy}","received_events_url":"https://api.github.com/users/schlessera/received_events","type":"User","site_admin":false},"open_issues":0,"closed_issues":1,"state":"open","created_at":"2018-07-20T12:38:04Z","updated_at":"2018-07-20T12:38:11Z","due_on":null,"closed_at":null},"comments":3,"created_at":"2018-07-20T09:27:42Z","updated_at":"2018-07-20T12:38:23Z","closed_at":"2018-07-20T12:38:11Z","author_association":"CONTRIBUTOR","pull_request":{"url":"https://api.github.com/repos/wp-cli/core-command/pulls/76","html_url":"https://github.com/wp-cli/core-command/pull/76","diff_url":"https://github.com/wp-cli/core-command/pull/76.diff","patch_url":"https://github.com/wp-cli/core-command/pull/76.patch"},"body":"Closes #75 \r\n\r\nIf the multisite constants are already in `wp-config.php`, there's no way to stop `populate_network` to add an empty `site_admins` option when creating a new install.\r\n\r\nThis PR adds code that, at the end, would remove all empty `site_admins` options. Later `multisite-install` calls `add_site_admins` which checks whether a user is a super admin, which would fail because the option exists, but is empty, so it would add another entry to the sitemeta table.\r\n\r\nSo normally the `add_site_admins` would just update the site_admins, and that should work. Not in this case.\r\n\r\n`update_network_option` will check the existing value of the option, and if it's `false`, then it will use `add_network_option` [because `false` means the option doesn't exist in the database](https://github.com/WordPress/WordPress/blob/master/wp-includes/option.php#L1565-L1590).\r\n\r\n`get_network_option` will return whatever is stored in the cache. If that happens to be nothing, then the first time a query is ran, it will check in the database, and if it's not in the database, [it will store it in a `$notoptions` array, and store that in the cache](https://github.com/WordPress/WordPress/blob/master/wp-includes/option.php#L1275-L1290).\r\n\r\nThe first time `site_admins` is queried, the database is practically empty, so the `site_admins` key ends up being part of the `$notoptions` variable and cache.\r\n\r\nSubsequent query to `get_network_option` will [hit the part where it's a `notoption` and return the default value - which is `false`](https://github.com/WordPress/WordPress/blob/master/wp-includes/option.php#L1248-L1267).\r\n\r\nWhich means in order to get this working, we need to actually delete the empty `site_admins` option, because a new one will be added anyways."},"comment":{"url":"https://api.github.com/repos/wp-cli/core-command/issues/comments/406588369","html_url":"https://github.com/wp-cli/core-command/pull/76#issuecomment-406588369","issue_url":"https://api.github.com/repos/wp-cli/core-command/issues/76","id":406588369,"node_id":"MDEyOklzc3VlQ29tbWVudDQwNjU4ODM2OQ==","user":{"login":"schlessera","id":83631,"node_id":"MDQ6VXNlcjgzNjMx","avatar_url":"https://avatars1.githubusercontent.com/u/83631?v=4","gravatar_id":"","url":"https://api.github.com/users/schlessera","html_url":"https://github.com/schlessera","followers_url":"https://api.github.com/users/schlessera/followers","following_url":"https://api.github.com/users/schlessera/following{/other_user}","gists_url":"https://api.github.com/users/schlessera/gists{/gist_id}","starred_url":"https://api.github.com/users/schlessera/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/schlessera/subscriptions","organizations_url":"https://api.github.com/users/schlessera/orgs","repos_url":"https://api.github.com/users/schlessera/repos","events_url":"https://api.github.com/users/schlessera/events{/privacy}","received_events_url":"https://api.github.com/users/schlessera/received_events","type":"User","site_admin":false},"created_at":"2018-07-20T12:38:23Z","updated_at":"2018-07-20T12:38:23Z","author_association":"MEMBER","body":"Thanks for the pull-request, @javorszky !"}}
{"actor":{"display_login":"schlessera"}}