Page MenuHomePhabricator

D19784.id47290.diff
No OneTemporary

D19784.id47290.diff

diff --git a/resources/sql/autopatches/20140805.boardcol.2.php b/resources/sql/autopatches/20140805.boardcol.2.php
--- a/resources/sql/autopatches/20140805.boardcol.2.php
+++ b/resources/sql/autopatches/20140805.boardcol.2.php
@@ -45,7 +45,7 @@
queryfx(
$conn_w,
'INSERT INTO %T (boardPHID, columnPHID, objectPHID, sequence)
- VALUES %Q',
+ VALUES %LQ',
id(new PhabricatorProjectColumnPosition())->getTableName(),
$chunk);
}
diff --git a/resources/sql/patches/20130820.file-mailkey-populate.php b/resources/sql/patches/20130820.file-mailkey-populate.php
--- a/resources/sql/patches/20130820.file-mailkey-populate.php
+++ b/resources/sql/patches/20130820.file-mailkey-populate.php
@@ -22,12 +22,12 @@
}
if ($sql) {
- foreach (PhabricatorLiskDAO::chunkSQL($sql, ', ') as $chunk) {
+ foreach (PhabricatorLiskDAO::chunkSQL($sql) as $chunk) {
queryfx(
$conn_w,
'INSERT INTO %T
(id, mailKey, phid, byteSize, storageEngine, storageFormat,
- storageHandle, dateCreated, dateModified, metadata) VALUES %Q '.
+ storageHandle, dateCreated, dateModified, metadata) VALUES %LQ '.
'ON DUPLICATE KEY UPDATE mailKey = VALUES(mailKey)',
$table_name,
$chunk);
diff --git a/resources/sql/patches/20131106.diffphid.2.mig.php b/resources/sql/patches/20131106.diffphid.2.mig.php
--- a/resources/sql/patches/20131106.diffphid.2.mig.php
+++ b/resources/sql/patches/20131106.diffphid.2.mig.php
@@ -34,10 +34,10 @@
continue;
}
- foreach (PhabricatorLiskDAO::chunkSQL($sql, ', ') as $sql_chunk) {
+ foreach (PhabricatorLiskDAO::chunkSQL($sql) as $sql_chunk) {
queryfx(
$conn_w,
- 'INSERT IGNORE INTO %T (id, phid) VALUES %Q
+ 'INSERT IGNORE INTO %T (id, phid) VALUES %LQ
ON DUPLICATE KEY UPDATE phid = VALUES(phid)',
$diff_table->getTableName(),
$sql_chunk);
diff --git a/src/applications/cache/PhabricatorKeyValueDatabaseCache.php b/src/applications/cache/PhabricatorKeyValueDatabaseCache.php
--- a/src/applications/cache/PhabricatorKeyValueDatabaseCache.php
+++ b/src/applications/cache/PhabricatorKeyValueDatabaseCache.php
@@ -38,7 +38,7 @@
$conn_w,
'INSERT INTO %T
(cacheKeyHash, cacheKey, cacheFormat, cacheData,
- cacheCreated, cacheExpires) VALUES %Q
+ cacheCreated, cacheExpires) VALUES %LQ
ON DUPLICATE KEY UPDATE
cacheKey = VALUES(cacheKey),
cacheFormat = VALUES(cacheFormat),
diff --git a/src/applications/calendar/notifications/PhabricatorCalendarNotificationEngine.php b/src/applications/calendar/notifications/PhabricatorCalendarNotificationEngine.php
--- a/src/applications/calendar/notifications/PhabricatorCalendarNotificationEngine.php
+++ b/src/applications/calendar/notifications/PhabricatorCalendarNotificationEngine.php
@@ -245,7 +245,7 @@
$conn,
'INSERT IGNORE INTO %T
(eventPHID, targetPHID, utcInitialEpoch, didNotifyEpoch)
- VALUES %Q',
+ VALUES %LQ',
$table->getTableName(),
$chunk);
}
diff --git a/src/applications/diffusion/conduit/DiffusionUpdateCoverageConduitAPIMethod.php b/src/applications/diffusion/conduit/DiffusionUpdateCoverageConduitAPIMethod.php
--- a/src/applications/diffusion/conduit/DiffusionUpdateCoverageConduitAPIMethod.php
+++ b/src/applications/diffusion/conduit/DiffusionUpdateCoverageConduitAPIMethod.php
@@ -106,8 +106,8 @@
foreach (PhabricatorLiskDAO::chunkSQL($sql) as $chunk) {
queryfx(
$conn,
- 'INSERT INTO %T (branchID, pathID, commitID, coverage) VALUES %Q'.
- ' ON DUPLICATE KEY UPDATE coverage=VALUES(coverage)',
+ 'INSERT INTO %T (branchID, pathID, commitID, coverage) VALUES %LQ'.
+ ' ON DUPLICATE KEY UPDATE coverage = VALUES(coverage)',
$table_name,
$chunk);
}
diff --git a/src/applications/diviner/publisher/DivinerLivePublisher.php b/src/applications/diviner/publisher/DivinerLivePublisher.php
--- a/src/applications/diviner/publisher/DivinerLivePublisher.php
+++ b/src/applications/diviner/publisher/DivinerLivePublisher.php
@@ -101,11 +101,11 @@
$strings[] = qsprintf($conn_w, '%s', $hash);
}
- foreach (PhabricatorLiskDAO::chunkSQL($strings, ', ') as $chunk) {
+ foreach (PhabricatorLiskDAO::chunkSQL($strings) as $chunk) {
queryfx(
$conn_w,
'UPDATE %T SET graphHash = NULL, nodeHash = NULL
- WHERE graphHash IN (%Q)',
+ WHERE graphHash IN (%LQ)',
$symbol_table->getTableName(),
$chunk);
}
diff --git a/src/applications/fact/daemon/PhabricatorFactDaemon.php b/src/applications/fact/daemon/PhabricatorFactDaemon.php
--- a/src/applications/fact/daemon/PhabricatorFactDaemon.php
+++ b/src/applications/fact/daemon/PhabricatorFactDaemon.php
@@ -189,7 +189,7 @@
$conn,
'INSERT INTO %T
(keyID, objectID, dimensionID, value, epoch)
- VALUES %Q',
+ VALUES %LQ',
$table_name,
$chunk);
}
diff --git a/src/applications/fact/storage/PhabricatorFactDimension.php b/src/applications/fact/storage/PhabricatorFactDimension.php
--- a/src/applications/fact/storage/PhabricatorFactDimension.php
+++ b/src/applications/fact/storage/PhabricatorFactDimension.php
@@ -75,7 +75,7 @@
foreach (PhabricatorLiskDAO::chunkSQL($sql) as $chunk) {
queryfx(
$conn,
- 'INSERT IGNORE INTO %T (%C) VALUES %Q',
+ 'INSERT IGNORE INTO %T (%C) VALUES %LQ',
$this->getTableName(),
$column,
$chunk);
diff --git a/src/applications/maniphest/editor/ManiphestTransactionEditor.php b/src/applications/maniphest/editor/ManiphestTransactionEditor.php
--- a/src/applications/maniphest/editor/ManiphestTransactionEditor.php
+++ b/src/applications/maniphest/editor/ManiphestTransactionEditor.php
@@ -531,7 +531,7 @@
foreach (PhabricatorLiskDAO::chunkSQL($sql) as $chunk) {
queryfx(
$conn,
- 'INSERT INTO %T (id, %Q, subpriority) VALUES %Q
+ 'INSERT INTO %T (id, %Q, subpriority) VALUES %LQ
ON DUPLICATE KEY UPDATE subpriority = VALUES(subpriority)',
$task->getTableName(),
implode(', ', array_keys($extra_columns)),
diff --git a/src/applications/people/storage/PhabricatorUserCache.php b/src/applications/people/storage/PhabricatorUserCache.php
--- a/src/applications/people/storage/PhabricatorUserCache.php
+++ b/src/applications/people/storage/PhabricatorUserCache.php
@@ -85,7 +85,7 @@
queryfx(
$conn_w,
'INSERT INTO %T (userPHID, cacheIndex, cacheKey, cacheData, cacheType)
- VALUES %Q
+ VALUES %LQ
ON DUPLICATE KEY UPDATE
cacheData = VALUES(cacheData),
cacheType = VALUES(cacheType)',
diff --git a/src/applications/project/storage/PhabricatorProject.php b/src/applications/project/storage/PhabricatorProject.php
--- a/src/applications/project/storage/PhabricatorProject.php
+++ b/src/applications/project/storage/PhabricatorProject.php
@@ -467,7 +467,7 @@
foreach (PhabricatorLiskDAO::chunkSQL($sql) as $chunk) {
queryfx(
$conn_w,
- 'INSERT INTO %T (projectID, token) VALUES %Q',
+ 'INSERT INTO %T (projectID, token) VALUES %LQ',
$table,
$chunk);
}
diff --git a/src/applications/repository/management/PhabricatorRepositoryManagementParentsWorkflow.php b/src/applications/repository/management/PhabricatorRepositoryManagementParentsWorkflow.php
--- a/src/applications/repository/management/PhabricatorRepositoryManagementParentsWorkflow.php
+++ b/src/applications/repository/management/PhabricatorRepositoryManagementParentsWorkflow.php
@@ -161,7 +161,7 @@
foreach (PhabricatorLiskDAO::chunkSQL($delete_sql) as $chunk) {
queryfx(
$conn_w,
- 'DELETE FROM %T WHERE childCommitID IN (%Q)',
+ 'DELETE FROM %T WHERE childCommitID IN (%LQ)',
PhabricatorRepository::TABLE_PARENTS,
$chunk);
}
@@ -169,7 +169,7 @@
foreach (PhabricatorLiskDAO::chunkSQL($insert_sql) as $chunk) {
queryfx(
$conn_w,
- 'INSERT INTO %T (childCommitID, parentCommitID) VALUES %Q',
+ 'INSERT INTO %T (childCommitID, parentCommitID) VALUES %LQ',
PhabricatorRepository::TABLE_PARENTS,
$chunk);
}
diff --git a/src/applications/repository/worker/commitchangeparser/PhabricatorRepositoryCommitChangeParserWorker.php b/src/applications/repository/worker/commitchangeparser/PhabricatorRepositoryCommitChangeParserWorker.php
--- a/src/applications/repository/worker/commitchangeparser/PhabricatorRepositoryCommitChangeParserWorker.php
+++ b/src/applications/repository/worker/commitchangeparser/PhabricatorRepositoryCommitChangeParserWorker.php
@@ -151,7 +151,7 @@
'INSERT INTO %T
(repositoryID, pathID, commitID, targetPathID, targetCommitID,
changeType, fileType, isDirect, commitSequence)
- VALUES %Q',
+ VALUES %LQ',
PhabricatorRepository::TABLE_PATHCHANGE,
$chunk);
}
diff --git a/src/applications/search/engineextension/PhabricatorFerretFulltextEngineExtension.php b/src/applications/search/engineextension/PhabricatorFerretFulltextEngineExtension.php
--- a/src/applications/search/engineextension/PhabricatorFerretFulltextEngineExtension.php
+++ b/src/applications/search/engineextension/PhabricatorFerretFulltextEngineExtension.php
@@ -201,7 +201,7 @@
foreach (PhabricatorLiskDAO::chunkSQL($sql) as $chunk) {
queryfx(
$conn,
- 'INSERT INTO %T (documentID, ngram) VALUES %Q',
+ 'INSERT INTO %T (documentID, ngram) VALUES %LQ',
$engine->getNgramsTableName(),
$chunk);
}
diff --git a/src/applications/search/management/PhabricatorSearchManagementNgramsWorkflow.php b/src/applications/search/management/PhabricatorSearchManagementNgramsWorkflow.php
--- a/src/applications/search/management/PhabricatorSearchManagementNgramsWorkflow.php
+++ b/src/applications/search/management/PhabricatorSearchManagementNgramsWorkflow.php
@@ -123,7 +123,7 @@
queryfx(
$conn,
'INSERT IGNORE INTO %T (ngram, needsCollection)
- VALUES %Q',
+ VALUES %LQ',
$engine->getCommonNgramsTableName(),
$chunk);
}
diff --git a/src/applications/system/engine/PhabricatorSystemActionEngine.php b/src/applications/system/engine/PhabricatorSystemActionEngine.php
--- a/src/applications/system/engine/PhabricatorSystemActionEngine.php
+++ b/src/applications/system/engine/PhabricatorSystemActionEngine.php
@@ -153,7 +153,7 @@
queryfx(
$conn_w,
'INSERT INTO %T (actorHash, actorIdentity, action, score, epoch)
- VALUES %Q',
+ VALUES %LQ',
$log->getTableName(),
$chunk);
}
diff --git a/src/infrastructure/customfield/field/PhabricatorCustomFieldList.php b/src/infrastructure/customfield/field/PhabricatorCustomFieldList.php
--- a/src/infrastructure/customfield/field/PhabricatorCustomFieldList.php
+++ b/src/infrastructure/customfield/field/PhabricatorCustomFieldList.php
@@ -303,7 +303,7 @@
foreach (PhabricatorLiskDAO::chunkSQL($sql_list) as $chunk) {
queryfx(
$conn_w,
- 'INSERT INTO %T (objectPHID, indexKey, indexValue) VALUES %Q',
+ 'INSERT INTO %T (objectPHID, indexKey, indexValue) VALUES %LQ',
$table,
$chunk);
}
diff --git a/src/infrastructure/storage/__tests__/QueryFormattingTestCase.php b/src/infrastructure/storage/__tests__/QueryFormattingTestCase.php
--- a/src/infrastructure/storage/__tests__/QueryFormattingTestCase.php
+++ b/src/infrastructure/storage/__tests__/QueryFormattingTestCase.php
@@ -7,15 +7,15 @@
$this->assertEqual(
'NULL',
- qsprintf($conn, '%nd', null));
+ (string)qsprintf($conn, '%nd', null));
$this->assertEqual(
'0',
- qsprintf($conn, '%nd', 0));
+ (string)qsprintf($conn, '%nd', 0));
$this->assertEqual(
'0',
- qsprintf($conn, '%d', 0));
+ (string)qsprintf($conn, '%d', 0));
$raised = null;
try {
@@ -29,39 +29,39 @@
$this->assertEqual(
"'<S>'",
- qsprintf($conn, '%s', null));
+ (string)qsprintf($conn, '%s', null));
$this->assertEqual(
'NULL',
- qsprintf($conn, '%ns', null));
+ (string)qsprintf($conn, '%ns', null));
$this->assertEqual(
"'<S>', '<S>'",
- qsprintf($conn, '%Ls', array('x', 'y')));
+ (string)qsprintf($conn, '%Ls', array('x', 'y')));
$this->assertEqual(
"'<B>'",
- qsprintf($conn, '%B', null));
+ (string)qsprintf($conn, '%B', null));
$this->assertEqual(
'NULL',
- qsprintf($conn, '%nB', null));
+ (string)qsprintf($conn, '%nB', null));
$this->assertEqual(
"'<B>', '<B>'",
- qsprintf($conn, '%LB', array('x', 'y')));
+ (string)qsprintf($conn, '%LB', array('x', 'y')));
$this->assertEqual(
'<C>',
- qsprintf($conn, '%T', 'x'));
+ (string)qsprintf($conn, '%T', 'x'));
$this->assertEqual(
'<C>',
- qsprintf($conn, '%C', 'y'));
+ (string)qsprintf($conn, '%C', 'y'));
$this->assertEqual(
'<C>.<C>',
- qsprintf($conn, '%R', new AphrontDatabaseTableRef('x', 'y')));
+ (string)qsprintf($conn, '%R', new AphrontDatabaseTableRef('x', 'y')));
}
diff --git a/src/infrastructure/storage/lisk/PhabricatorLiskDAO.php b/src/infrastructure/storage/lisk/PhabricatorLiskDAO.php
--- a/src/infrastructure/storage/lisk/PhabricatorLiskDAO.php
+++ b/src/infrastructure/storage/lisk/PhabricatorLiskDAO.php
@@ -196,14 +196,11 @@
* INSERT, previously built with @{function:qsprintf}) into chunks which will
* fit under the MySQL 'max_allowed_packet' limit.
*
- * Chunks are glued together with `$glue`, by default ", ".
- *
* If a statement is too large to fit within the limit, it is broken into
* its own chunk (but might fail when the query executes).
*/
public static function chunkSQL(
array $fragments,
- $glue = ', ',
$limit = null) {
if ($limit === null) {
@@ -216,9 +213,13 @@
$chunk = array();
$len = 0;
- $glue_len = strlen($glue);
+ $glue_len = strlen(', ');
foreach ($fragments as $fragment) {
- $this_len = strlen($fragment);
+ if ($fragment instanceof PhutilQueryString) {
+ $this_len = strlen($fragment->getUnmaskedString());
+ } else {
+ $this_len = strlen($fragment);
+ }
if ($chunk) {
// Chunks after the first also imply glue.
@@ -232,7 +233,7 @@
if ($chunk) {
$result[] = $chunk;
}
- $len = strlen($fragment);
+ $len = ($this_len - $glue_len);
$chunk = array($fragment);
}
}
@@ -241,10 +242,6 @@
$result[] = $chunk;
}
- foreach ($result as $key => $fragment_list) {
- $result[$key] = implode($glue, $fragment_list);
- }
-
return $result;
}
diff --git a/src/infrastructure/storage/lisk/__tests__/LiskChunkTestCase.php b/src/infrastructure/storage/lisk/__tests__/LiskChunkTestCase.php
--- a/src/infrastructure/storage/lisk/__tests__/LiskChunkTestCase.php
+++ b/src/infrastructure/storage/lisk/__tests__/LiskChunkTestCase.php
@@ -15,13 +15,15 @@
$this->assertEqual(
array(
- 'aa',
- 'bb',
- 'ccc',
- 'dd',
- 'e',
+ array('a'),
+ array('a'),
+ array('b'),
+ array('b'),
+ array('ccc'),
+ array('dd'),
+ array('e'),
),
- PhabricatorLiskDAO::chunkSQL($fragments, '', 2));
+ PhabricatorLiskDAO::chunkSQL($fragments, 2));
$fragments = array(
@@ -37,11 +39,11 @@
$this->assertEqual(
array(
- 'a, a, a',
- 'XX, a, a',
- 'a, a',
+ array('a', 'a', 'a'),
+ array('XX', 'a', 'a'),
+ array('a', 'a'),
),
- PhabricatorLiskDAO::chunkSQL($fragments, ', ', 8));
+ PhabricatorLiskDAO::chunkSQL($fragments, 8));
$fragments = array(
@@ -55,12 +57,12 @@
$this->assertEqual(
array(
- 'xxxxxxxxxx',
- 'yyyyyyyyyy',
- 'a, b, c',
- 'zzzzzzzzzz',
+ array('xxxxxxxxxx'),
+ array('yyyyyyyyyy'),
+ array('a', 'b', 'c'),
+ array('zzzzzzzzzz'),
),
- PhabricatorLiskDAO::chunkSQL($fragments, ', ', 8));
+ PhabricatorLiskDAO::chunkSQL($fragments, 8));
}
}

File Metadata

Mime Type
text/plain
Expires
Sun, Dec 15, 12:23 AM (18 h, 31 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6884323
Default Alt Text
D19784.id47290.diff (16 KB)

Event Timeline