aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmir Sarabadani <ladsgroup@gmail.com>2022-12-13 10:14:44 +0100
committerAmir Sarabadani <ladsgroup@gmail.com>2022-12-13 10:14:44 +0100
commit04c090de80d6ff7183bd43a76cb1a41d006ab584 (patch)
tree88669f86dfe70d1a76a9917c625163636d1ada07
parent30a893b6ff4daa649a91060c53081064bc387aad (diff)
downloadmediawikicore-04c090de80d6ff7183bd43a76cb1a41d006ab584.tar.gz
mediawikicore-04c090de80d6ff7183bd43a76cb1a41d006ab584.zip
upload: Migrate select queries to SelectQueryBuilder
Bug: T311866 Change-Id: I5308448d83ec16fa73602aedc172ce55bea3a6e1
-rw-r--r--includes/upload/UploadStash.php36
1 files changed, 16 insertions, 20 deletions
diff --git a/includes/upload/UploadStash.php b/includes/upload/UploadStash.php
index d4d071b1d717..371121779847 100644
--- a/includes/upload/UploadStash.php
+++ b/includes/upload/UploadStash.php
@@ -378,12 +378,11 @@ class UploadStash {
// this is a cheap query. it runs on the primary DB so that this function
// still works when there's lag. It won't be called all that often.
- $row = $dbw->selectRow(
- 'uploadstash',
- 'us_user',
- [ 'us_key' => $key ],
- __METHOD__
- );
+ $row = $dbw->newSelectQueryBuilder()
+ ->select( 'us_user' )
+ ->from( 'uploadstash' )
+ ->where( [ 'us_key' => $key ] )
+ ->caller( __METHOD__ )->fetchRow();
if ( !$row ) {
throw new UploadStashNoSuchKeyException(
@@ -444,13 +443,11 @@ class UploadStash {
);
}
- $dbr = $this->repo->getReplicaDB();
- $res = $dbr->select(
- 'uploadstash',
- 'us_key',
- [ 'us_user' => $this->user->getId() ],
- __METHOD__
- );
+ $res = $this->repo->getReplicaDB()->newSelectQueryBuilder()
+ ->select( 'us_key' )
+ ->from( 'uploadstash' )
+ ->where( [ 'us_user' => $this->user->getId() ] )
+ ->caller( __METHOD__ )->fetchResultSet();
if ( !is_object( $res ) || $res->numRows() == 0 ) {
// nothing to do.
@@ -518,17 +515,16 @@ class UploadStash {
$dbr = $this->repo->getReplicaDB();
}
- $row = $dbr->selectRow(
- 'uploadstash',
- [
+ $row = $dbr->newSelectQueryBuilder()
+ ->select( [
'us_user', 'us_key', 'us_orig_path', 'us_path', 'us_props',
'us_size', 'us_sha1', 'us_mime', 'us_media_type',
'us_image_width', 'us_image_height', 'us_image_bits',
'us_source_type', 'us_timestamp', 'us_status',
- ],
- [ 'us_key' => $key ],
- __METHOD__
- );
+ ] )
+ ->from( 'uploadstash' )
+ ->where( [ 'us_key' => $key ] )
+ ->caller( __METHOD__ )->fetchRow();
if ( !is_object( $row ) ) {
// key wasn't present in the database. this will happen sometimes.