: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
class Utility_MultisiteConfigurationExtractor {
private $prefix, $suffix;
public function __construct($prefix, $suffix) {
$this->prefix = new Utility_MeasuredString($prefix);
$this->suffix = new Utility_MeasuredString($suffix);
$this->suffixOffset = -$this->suffix->length;
* Parses a `get_user_meta` result array into a more usable format. The input array will be something similar to
* 'wp_capabilities' => '...',
* 'wp_3_capabilities' => '...',
* 'wp_4_capabilities' => '...',
* 'wp_10_capabilities' => '...',
private function parseBlogIds($values) {
foreach ($values as $key => $value) {
if (substr($key, $this->suffixOffset) === $this->suffix->string && strpos($key, (string) $this->prefix) === 0) {
$blogId = substr($key, $this->prefix->length, strlen($key) - $this->prefix->length + $this->suffixOffset);
else if (substr($blogId, -1) === '_') {
$parsed[(int) $blogId] = $value;
* Filters $values, which is the resulting array from `$this->parseBlogIds` so it contains only the values for the
private function filterValues($values, $sites) {
foreach ($sites as $site) {
$blogId = (int) $site->blog_id;
$filtered[$blogId] = $values[$blogId];
* Processes a `get_user_meta` result array to re-key it so the keys are the numerical ID of all multisite blog IDs
* in `$values` that are still in an active state.
public function extract($values) {
$parsed = $this->parseBlogIds($values);
$sites = Utility_Multisite::retrieve_active_sites(array_keys($parsed));
return $this->filterValues($parsed, $sites);