protected function fetch_standard_tokens() { if ($this->info->wiki_version_number() < 12400) { $title = $this->info->site_mainpage(); $query = new API_Module_Query_With_Modules($this->exchanger, $this->info, $this->hooks, $this->settings->get("setparams")); $query->set_titles($title); if ($query->is_property_paramvalue_ok("info", 'token', "edit")) { $query->set_property_param("info", 'token', "edit"); } if ($query->is_property_paramvalue_ok("info", 'token', "watch")) { $query->set_property_param("info", 'token', "watch"); } $query->xfer(); if (isset($query->data['query']['pages'])) { $page = reset($query->data['query']['pages']); if (isset($page['edittoken'])) { $this->tokens['edit'] = $page['edittoken']; } else { if ($query->is_property_paramvalue_ok("info", 'token', "edit")) { $this->log("Edit token not supplied - editing may be impossible", LL_WARNING); } } if (isset($page['watchtoken'])) { $this->tokens['watch'] = $page['watchtoken']; } else { if ($query->is_property_paramvalue_ok("info", 'token', "watch")) { $this->log("Watch token not supplied - watching may be impossible", LL_WARNING); } } return true; } else { $this->log("Could not fetch standard tokens - changing wiki info may be impossible", LL_WARNING); return false; } } else { $token_names = array("csrf", "watch", "patrol", "rollback", "userrights"); $query = new API_Module_Query_With_Modules($this->exchanger, $this->info, $this->hooks, $this->settings->get("setparams")); $query->set_meta_param("tokens", 'type', $token_names); $query->xfer(); if (isset($query->data['query']['tokens']['csrftoken'])) { $this->tokens['edit'] = $query->data['query']['tokens']['csrftoken']; } if (isset($query->data['query']['tokens']['patroltoken'])) { $this->tokens['patrol'] = $query->data['query']['tokens']['patroltoken']; } if (isset($query->data['query']['tokens']['rollbacktoken'])) { $this->tokens['rollback'] = $query->data['query']['tokens']['rollbacktoken']; } if (isset($query->data['query']['tokens']['userrightstoken'])) { $this->tokens['userrights'] = $query->data['query']['tokens']['userrightstoken']; } if (isset($query->data['query']['tokens']['watchtoken'])) { $this->tokens['watch'] = $query->data['query']['tokens']['watchtoken']; } return true; } }