Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F13963396
D9213.id21881.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D9213.id21881.diff
View Options
diff --git a/src/utils/__tests__/PhutilUtilsTestCase.php b/src/utils/__tests__/PhutilUtilsTestCase.php
--- a/src/utils/__tests__/PhutilUtilsTestCase.php
+++ b/src/utils/__tests__/PhutilUtilsTestCase.php
@@ -168,6 +168,25 @@
array(),
array(4, 5),
)));
+
+ $not_valid = array(
+ 'scalar' => array(1),
+ 'array plus scalar' => array(array(), 1),
+ 'null' => array(null),
+ );
+
+ foreach ($not_valid as $key => $invalid_input) {
+ $caught = null;
+ try {
+ array_mergev($invalid_input);
+ } catch (InvalidArgumentException $ex) {
+ $caught = $ex;
+ }
+
+ $this->assertTrue(
+ ($caught instanceof InvalidArgumentException),
+ "array_mergev() invalid on {$key}");
+ }
}
public function testNonempty() {
diff --git a/src/utils/utils.php b/src/utils/utils.php
--- a/src/utils/utils.php
+++ b/src/utils/utils.php
@@ -732,6 +732,17 @@
return array();
}
+ foreach ($arrayv as $key => $item) {
+ if (!is_array($item)) {
+ throw new InvalidArgumentException(
+ pht(
+ 'Expected all items passed to array_mergev() to be arrays, but '.
+ 'argument with key "%s" has type "%s".',
+ $key,
+ gettype($item)));
+ }
+ }
+
return call_user_func_array('array_merge', $arrayv);
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Oct 16, 3:37 PM (2 w, 6 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6718077
Default Alt Text
D9213.id21881.diff (1 KB)
Attached To
Mode
D9213: Throw when passing array_mergev() non-array items
Attached
Detach File
Event Timeline
Log In to Comment