Skip to content

Commit 190c1a6

Browse files
committed
Fixed edit skipping on sandbox and added user@wiki search to logs
1 parent b603979 commit 190c1a6

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

js/swv.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -976,7 +976,7 @@ angular.module("swv", ["ui.directives", "ui.filters"])
976976
}
977977
function addSandbox(sbList, wiki, page) {
978978
if (sbList.hasOwnProperty(wiki))
979-
sbList[wiki] = sbList[wiki] + ", " + page;
979+
sbList[wiki] = sbList[wiki] + "," + page;
980980
}
981981
addSandbox(window.sandboxlist, "eswiki", "Wikipedia:Zona_de_pruebas/1");
982982
addSandbox(window.sandboxlist, "eswiki", "Wikipedia:Zona_de_pruebas/2");
@@ -990,7 +990,6 @@ angular.module("swv", ["ui.directives", "ui.filters"])
990990
addSandbox(window.sandboxlist, "eswiki", "Wikipedia:Zona_de_pruebas/10");
991991
addSandbox(window.sandboxlist, "mediawikiwiki", "VisualEditor:Test");
992992
addSandbox(window.sandboxlist, "simplewiki", "Wikipedia:Introduction");
993-
addSandbox(window.sandboxlist, "wikidatawiki", "Wikidata:Sandbox");
994993
addSandbox(window.sandboxlist, "wikidatawiki", "Q4115189");
995994
addSandbox(window.sandboxlist, "wikidatawiki", "Q13406268");
996995
addSandbox(window.sandboxlist, "wikidatawiki", "Q15397819");
@@ -1573,6 +1572,7 @@ function getDiff(serverUrl, scriptPath, wiki, newId, oldId) {
15731572
if (data.error.code === "nosuchrevid") reject(useLang["error-del"]);
15741573
reject(useLang["error-opening-del-spec"].replace("$1", escapeXSS(data.error.info)));
15751574
}
1575+
if (typeof data.compare === 'undefined') reject(`Please report this error to developer. ERROR: Unable to get difference. Info: ${url}`);
15761576
if (data.compare['*'] === "" || data.compare['*'].indexOf("<tr>") === -1) {
15771577
if (typeof oldId !== 'undefined') reject(useLang["error-already-reverted"]);
15781578
var newPageDiff = startstring + data.compare['*'] + endstring;

php/logs.php

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,31 @@
1111

1212
$_POST = json_decode(file_get_contents('php://input'), true);
1313
$searchPhrase = $_POST['sp'] . '%';
14+
$userPhrase = $searchPhrase;
15+
$wikiPhrase = $searchPhrase;
1416
$searchType = $_POST['st'] . '%';
1517
$limit = $_POST['li'];
1618
$offset = $_POST['of'];
1719
if ((!is_numeric($limit) && !is_null($limit) && !isset($limit)))
1820
exit();
1921

22+
$separatorPos = strpos($searchPhrase, '@');
23+
24+
if ($separatorPos !== false) {
25+
$userPhrase = substr($searchPhrase, 0, $separatorPos);
26+
$wikiPhrase = substr($searchPhrase, $separatorPos + 1);
27+
}
28+
2029
$ts_pw = posix_getpwuid(posix_getuid());
2130
$ts_mycnf = parse_ini_file("/data/project/swviewer/security/replica.my.cnf");
2231
$db = new PDO("mysql:host=tools.labsdb;dbname=s53950__SWViewer;charset=utf8", $ts_mycnf['user'], $ts_mycnf['password']);
2332
unset($ts_mycnf, $ts_pw);
2433

2534
$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
26-
$q = $db->prepare('SELECT * FROM logs WHERE (user LIKE :searchUser OR wiki LIKE :searchWiki) AND (type LIKE :searchType) ORDER BY date DESC LIMIT :limit OFFSET :offset');
27-
$q->bindParam(':searchUser', $searchPhrase, PDO::PARAM_STR);
28-
$q->bindParam(':searchWiki', $searchPhrase, PDO::PARAM_STR);
35+
if ($separatorPos === false) $q = $db->prepare('SELECT * FROM logs WHERE (user LIKE :searchUser OR wiki LIKE :searchWiki) AND (type LIKE :searchType) ORDER BY date DESC LIMIT :limit OFFSET :offset');
36+
else $q = $db->prepare('SELECT * FROM logs WHERE (user LIKE :searchUser AND wiki LIKE :searchWiki) AND (type LIKE :searchType) ORDER BY date DESC LIMIT :limit OFFSET :offset');
37+
$q->bindParam(':searchUser', $userPhrase, PDO::PARAM_STR);
38+
$q->bindParam(':searchWiki', $wikiPhrase, PDO::PARAM_STR);
2939
$q->bindParam(':searchType', $searchType, PDO::PARAM_STR);
3040
$q->bindParam(':limit', $limit, PDO::PARAM_INT);
3141
$q->bindParam(':offset', $offset, PDO::PARAM_INT);

0 commit comments

Comments
 (0)