Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions src/includes/WikipediaBot.php
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ public function write_page(string $page, string $text, string $editSummary, int
return true;
}

public static function response2page(?object $response): ?object {
public static function response2page(?object $response): ?stdClass {
if ($response === null) {
report_warning("Write request failed");
return null;
Expand Down Expand Up @@ -411,10 +411,13 @@ public static function redirect_target(string $page): ?string {
private static function query_api(array $params): string {
try {
$params['format'] = 'json';
/** @psalm-suppress UnnecessaryVarAnnotation */
/** @var non-empty-string $api_root */
$api_root = API_ROOT;
curl_setopt_array(self::$ch_logout, [
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => http_build_query($params),
CURLOPT_URL => API_ROOT,
CURLOPT_URL => $api_root,
]);

$data = @curl_exec(self::$ch_logout);
Expand Down Expand Up @@ -520,7 +523,11 @@ public static function get_last_user(): string {
* @codeCoverageIgnore
*/
private function authenticate_user(): void {
@setcookie(session_name(), session_id(), time() + (7 * 24 * 3600), "", "", true, true); // 7 days
$session_name = session_name();
$session_id = session_id();
if ($session_name !== false && $session_id !== false) {
@setcookie($session_name, $session_id, time() + (7 * 24 * 3600), "", "", true, true); // 7 days
}
if (isset($_SESSION['citation_bot_user_id']) &&
isset($_SESSION['access_key']) &&
isset($_SESSION['access_secret']) &&
Expand Down Expand Up @@ -576,7 +583,7 @@ private function authenticate_user(): void {
exit(0);
}

private static function reset(object &$obj): object { // We use old php 7 style reset, so emulate
private static function reset(object &$obj): stdClass { // We use old php 7 style reset, so emulate
$arr = (array) $obj;
return (object) reset($arr);
}
Expand Down
Loading