[MediaWiki-commits] [Gerrit] operations...wikistats[master]: database queries, PDO, get rid of deprecated params
Dzahn has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/354377 ) Change subject: database queries, PDO, get rid of deprecated params .. database queries, PDO, get rid of deprecated params Change-Id: I2484474b9e5095b03efc6108c2a1a1f1c113d856 --- M var/www/wikistats/detail.php M var/www/wikistats/display.php M var/www/wikistats/displayw.php M var/www/wikistats/index.php M var/www/wikistats/wikimedias_html.php M var/www/wikistats/wikimedias_wiki.php M var/www/wikistats/wikipedias_wiki.php 7 files changed, 50 insertions(+), 74 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/operations/debs/wikistats refs/changes/77/354377/1 diff --git a/var/www/wikistats/detail.php b/var/www/wikistats/detail.php index 30e814f..c04aca0 100644 --- a/var/www/wikistats/detail.php +++ b/var/www/wikistats/detail.php @@ -183,7 +183,7 @@ $project_name="invalid"; $domain="localhost"; -$db_table=""; +$db_table="invalid"; print <prepare($query); $fnord -> execute(); @@ -238,7 +238,7 @@ $count++; } -$query = "select id from ${db_table} order by total desc,good desc"; +$query = "SELECT id FROM ${db_table} ORDER BY total desc,good desc"; $fnord = $wdb->prepare($query); $fnord -> execute(); $num_project=$wdb->query($query)->fetchColumn(); @@ -251,11 +251,11 @@ $count++; } -$query = "select id from ${db_table} order by edits desc"; +$query = "SELECT id FROM ${db_table} ORDER BY edits desc"; $fnord = $wdb->prepare($query); $fnord -> execute(); -$num_project=$wdb->query("select count(*) from ${db_table}")->fetchColumn(); +$num_project=$wdb->query("SELECT count(*) FROM ${db_table}")->fetchColumn(); $count=1; while ($row = $fnord->fetch()) { @@ -265,7 +265,7 @@ $count++; } -$query = "select id from ${db_table} order by users desc"; +$query = "SELECT id FROM ${db_table} ORDER by users desc"; $fnord = $wdb->prepare($query); $fnord -> execute(); $count=1; @@ -283,10 +283,9 @@ $rank_project_e=ordinal($rank_project_e); $rank_project_u=ordinal($rank_project_u); -# main -$query = "select *,good/total as ratio,TIMESTAMPDIFF(MINUTE, ts, now()) as oldness from ${db_table} where id=${wikiid}"; +$query = "SELECT *,good/total AS ratio,TIMESTAMPDIFF(MINUTE, ts, now()) AS oldness from ${db_table} WHERE id=:wikiid"; $fnord = $wdb->prepare($query); -$fnord -> execute(); +$fnord -> execute(['wikiid' => $wikiid]); #DEBUG# echo "Sent query: '$query'."; print <<↓"; -$uarr="↑"; -$nodeco="text-decoration:none;"; - require_once("/etc/wikistats/config.php"); require_once("$IP/functions.php"); require_once("$IP/http_status_codes.php"); - -if (isset($_GET['p']) && is_numeric($_GET['p']) && $_GET['p'] > 1 && $_GET['p'] < 100) { -$page=$_GET['p']; -$page=htmlspecialchars($page); -$offset=($page-1)*$page_size; -} else { -$page="1"; -$offset=0; -} # db connect try { @@ -232,7 +219,7 @@ } include("$IP/sortswitch.php"); -$query = "select *,good/total as ratio,TIMESTAMPDIFF(MINUTE, ts, now()) as oldness from ${db_table} order by ${msort} limit ${page_size} offset ${offset}"; +$query = "SELECT *,good/total AS ratio,TIMESTAMPDIFF(MINUTE, ts, now()) AS oldness FROM ${db_table} ORDER BY ${msort}"; #DEBUG# echo "sending query: '$query'."; $fnord = $wdb->prepare($query); $fnord -> execute(); diff --git a/var/www/wikistats/displayw.php b/var/www/wikistats/displayw.php index 9ce9119..7bc35ea 100644 --- a/var/www/wikistats/displayw.php +++ b/var/www/wikistats/displayw.php @@ -201,23 +201,9 @@ $listname="List of ${project_name}"; $phpself=$_SERVER['PHP_SELF']; -$darr="↓"; -$uarr="↑"; -$nodeco="text-decoration:none;"; - require_once("/etc/wikistats/config.php"); require_once("$IP/functions.php"); require_once("$IP/http_status_codes.php"); - -if (isset($_GET['p']) && is_numeric($_GET['p']) && $_GET['p'] > 1 && $_GET['p'] < 100) { -$page=$_GET['p']; -$offset=($page-1)*${page_size}; -} else { -$page="1"; -$offset=0; -} - -include("$IP/sortswitch.php"); # db connect try { @@ -227,11 +213,12 @@ die(); } -$query = "select *,good/total as ratio,TIMESTAMPDIFF(MINUTE, ts, now()) as oldness from ${db_table} order by ${msort} limit ${page_size} offset ${offset}"; +$query = "SELECT *,good/total AS ratio,TIMESTAMPDIFF(MINUTE, ts, now()) AS oldness FROM ${db_table} ORDER BY good desc,total desc"; #DEBUG# echo "sending query: '$query'."; $fnord = $wdb->prepare($query); $fnord -> execute(); + echo ""; print << -Wikistats 2.0 +Wikistats 2.2 [beta] @@ -79,7 +79,7 @@ } foreach ($listtables as $listtable) { -$quer
[MediaWiki-commits] [Gerrit] operations...wikistats[master]: database queries, PDO, get rid of deprecated params
Dzahn has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/354377 ) Change subject: database queries, PDO, get rid of deprecated params .. database queries, PDO, get rid of deprecated params Change-Id: I2484474b9e5095b03efc6108c2a1a1f1c113d856 --- M var/www/wikistats/detail.php M var/www/wikistats/display.php M var/www/wikistats/displayw.php M var/www/wikistats/index.php M var/www/wikistats/wikimedias_html.php M var/www/wikistats/wikimedias_wiki.php M var/www/wikistats/wikipedias_wiki.php 7 files changed, 50 insertions(+), 74 deletions(-) Approvals: jenkins-bot: Verified Dzahn: Looks good to me, approved diff --git a/var/www/wikistats/detail.php b/var/www/wikistats/detail.php index 30e814f..c04aca0 100644 --- a/var/www/wikistats/detail.php +++ b/var/www/wikistats/detail.php @@ -183,7 +183,7 @@ $project_name="invalid"; $domain="localhost"; -$db_table=""; +$db_table="invalid"; print <prepare($query); $fnord -> execute(); @@ -238,7 +238,7 @@ $count++; } -$query = "select id from ${db_table} order by total desc,good desc"; +$query = "SELECT id FROM ${db_table} ORDER BY total desc,good desc"; $fnord = $wdb->prepare($query); $fnord -> execute(); $num_project=$wdb->query($query)->fetchColumn(); @@ -251,11 +251,11 @@ $count++; } -$query = "select id from ${db_table} order by edits desc"; +$query = "SELECT id FROM ${db_table} ORDER BY edits desc"; $fnord = $wdb->prepare($query); $fnord -> execute(); -$num_project=$wdb->query("select count(*) from ${db_table}")->fetchColumn(); +$num_project=$wdb->query("SELECT count(*) FROM ${db_table}")->fetchColumn(); $count=1; while ($row = $fnord->fetch()) { @@ -265,7 +265,7 @@ $count++; } -$query = "select id from ${db_table} order by users desc"; +$query = "SELECT id FROM ${db_table} ORDER by users desc"; $fnord = $wdb->prepare($query); $fnord -> execute(); $count=1; @@ -283,10 +283,9 @@ $rank_project_e=ordinal($rank_project_e); $rank_project_u=ordinal($rank_project_u); -# main -$query = "select *,good/total as ratio,TIMESTAMPDIFF(MINUTE, ts, now()) as oldness from ${db_table} where id=${wikiid}"; +$query = "SELECT *,good/total AS ratio,TIMESTAMPDIFF(MINUTE, ts, now()) AS oldness from ${db_table} WHERE id=:wikiid"; $fnord = $wdb->prepare($query); -$fnord -> execute(); +$fnord -> execute(['wikiid' => $wikiid]); #DEBUG# echo "Sent query: '$query'."; print <<↓"; -$uarr="↑"; -$nodeco="text-decoration:none;"; - require_once("/etc/wikistats/config.php"); require_once("$IP/functions.php"); require_once("$IP/http_status_codes.php"); - -if (isset($_GET['p']) && is_numeric($_GET['p']) && $_GET['p'] > 1 && $_GET['p'] < 100) { -$page=$_GET['p']; -$page=htmlspecialchars($page); -$offset=($page-1)*$page_size; -} else { -$page="1"; -$offset=0; -} # db connect try { @@ -232,7 +219,7 @@ } include("$IP/sortswitch.php"); -$query = "select *,good/total as ratio,TIMESTAMPDIFF(MINUTE, ts, now()) as oldness from ${db_table} order by ${msort} limit ${page_size} offset ${offset}"; +$query = "SELECT *,good/total AS ratio,TIMESTAMPDIFF(MINUTE, ts, now()) AS oldness FROM ${db_table} ORDER BY ${msort}"; #DEBUG# echo "sending query: '$query'."; $fnord = $wdb->prepare($query); $fnord -> execute(); diff --git a/var/www/wikistats/displayw.php b/var/www/wikistats/displayw.php index 9ce9119..7bc35ea 100644 --- a/var/www/wikistats/displayw.php +++ b/var/www/wikistats/displayw.php @@ -201,23 +201,9 @@ $listname="List of ${project_name}"; $phpself=$_SERVER['PHP_SELF']; -$darr="↓"; -$uarr="↑"; -$nodeco="text-decoration:none;"; - require_once("/etc/wikistats/config.php"); require_once("$IP/functions.php"); require_once("$IP/http_status_codes.php"); - -if (isset($_GET['p']) && is_numeric($_GET['p']) && $_GET['p'] > 1 && $_GET['p'] < 100) { -$page=$_GET['p']; -$offset=($page-1)*${page_size}; -} else { -$page="1"; -$offset=0; -} - -include("$IP/sortswitch.php"); # db connect try { @@ -227,11 +213,12 @@ die(); } -$query = "select *,good/total as ratio,TIMESTAMPDIFF(MINUTE, ts, now()) as oldness from ${db_table} order by ${msort} limit ${page_size} offset ${offset}"; +$query = "SELECT *,good/total AS ratio,TIMESTAMPDIFF(MINUTE, ts, now()) AS oldness FROM ${db_table} ORDER BY good desc,total desc"; #DEBUG# echo "sending query: '$query'."; $fnord = $wdb->prepare($query); $fnord -> execute(); + echo ""; print << -Wikistats 2.0 +Wikistats 2.2 [beta] @@ -79,7 +79,7 @@ } foreach ($listtables as $listtable) { -$query = "select ts,T