Jonaskeutel has uploaded a new change for review.
https://gerrit.wikimedia.org/r/216066
Change subject: escape sql and validate batchSize parameter
......................................................................
escape sql and validate batchSize parameter
Change-Id: I91b4a9859364f4f0b70e5167a5156748cb7449aa
(cherry picked from commit 90409d3a373f3b2fd9113eff3b18d63959d10168)
---
M includes/ConstraintRepository.php
1 file changed, 18 insertions(+), 2 deletions(-)
git pull
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikidataQualityConstraints
refs/changes/66/216066/1
diff --git a/includes/ConstraintRepository.php
b/includes/ConstraintRepository.php
index c3ce38c..ee811ac 100644
--- a/includes/ConstraintRepository.php
+++ b/includes/ConstraintRepository.php
@@ -2,6 +2,14 @@
namespace WikibaseQuality\ConstraintReport;
+use InvalidArgumentException;
+
+/**
+ * Class ConstraintRepository
+ * @package WikibaseQuality\ConstraintReport
+ * @author BP2014N1
+ * @license GNU GPL v2+
+ */
class ConstraintRepository {
/**
@@ -11,10 +19,11 @@
*/
public function queryConstraintsForProperty( $prop ) {
$db = wfGetDB( DB_SLAVE );
+
$results = $db->select(
CONSTRAINT_TABLE,
'*',
- "pid = $prop"
+ array( 'pid' => $prop )
);
return $this->convertToConstraints( $results );
@@ -46,8 +55,15 @@
return $db->insert( CONSTRAINT_TABLE, $accumulator );
}
-
+ /**
+ * @param int $batchSize
+ *
+ * @throws \DBUnexpectedError
+ */
public function deleteAll( $batchSize = 1000 ) {
+ if ( !is_int( $batchSize ) ) {
+ throw new InvalidArgumentException();
+ }
$db = wfGetDB( DB_MASTER );
if ( $db->getType() === 'sqlite' ) {
$db->delete( CONSTRAINT_TABLE, '*' );
--
To view, visit https://gerrit.wikimedia.org/r/216066
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I91b4a9859364f4f0b70e5167a5156748cb7449aa
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/WikidataQualityConstraints
Gerrit-Branch: master
Gerrit-Owner: Jonaskeutel <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits