Jonaskeutel has submitted this change and it was merged.

Change subject: escape sql and validate batchSize parameter
......................................................................


escape sql and validate batchSize parameter

Change-Id: I91b4a9859364f4f0b70e5167a5156748cb7449aa
---
M includes/ConstraintRepository.php
1 file changed, 18 insertions(+), 2 deletions(-)

Approvals:
  Jonaskeutel: Verified; Looks good to me, approved



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/215892
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I91b4a9859364f4f0b70e5167a5156748cb7449aa
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/WikidataQualityConstraints
Gerrit-Branch: v1
Gerrit-Owner: Jonaskeutel <[email protected]>
Gerrit-Reviewer: Jonaskeutel <[email protected]>
Gerrit-Reviewer: Soeren.oldag <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to