mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-20 05:42:40 +01:00
Minor fix for lipsum generate
Summary: I was hitting the following error when attempting to use `./bin/lipsum generate`: ``` [2015-02-28 21:55:00] ERROR 2: array_rand(): Second argument has to be between 1 and the number of elements in the array at [/usr/src/phabricator/src/applications/pholio/lipsum/PhabricatorPholioMockTestDataGenerator.php:93] arcanist(head=master, ref.master=d8182cf55d50), phabricator(head=master, ref.master=658175925931), phutil(head=master, ref.master=260e6105dee5) #0 array_rand(array, integer) called at [<phabricator>/src/applications/pholio/lipsum/PhabricatorPholioMockTestDataGenerator.php:93] #1 PhabricatorPholioMockTestDataGenerator::generateImages() called at [<phabricator>/src/applications/pholio/lipsum/PhabricatorPholioMockTestDataGenerator.php:30] #2 PhabricatorPholioMockTestDataGenerator::generate() called at [<phabricator>/src/applications/lipsum/management/PhabricatorLipsumGenerateWorkflow.php:67] #3 PhabricatorLipsumGenerateWorkflow::infinitelyGenerate(array) called at [<phabricator>/src/applications/lipsum/management/PhabricatorLipsumGenerateWorkflow.php:36] #4 PhabricatorLipsumGenerateWorkflow::execute(PhutilArgumentParser) called at [<phutil>/src/parser/argument/PhutilArgumentParser.php:396] #5 PhutilArgumentParser::parseWorkflowsFull(array) called at [<phutil>/src/parser/argument/PhutilArgumentParser.php:292] #6 PhutilArgumentParser::parseWorkflows(array) called at [<phabricator>/scripts/lipsum/manage_lipsum.php:21] ``` Test Plan: Ran `./bin/lipsum generate` and received less errors. Reviewers: #blessed_reviewers, epriestley Reviewed By: #blessed_reviewers, epriestley Subscribers: Korvin, epriestley Differential Revision: https://secure.phabricator.com/D11908
This commit is contained in:
parent
96f6fb585e
commit
644b05ec08
1 changed files with 7 additions and 4 deletions
|
@ -90,11 +90,14 @@ final class PhabricatorPholioMockTestDataGenerator
|
||||||
$rand_images = array();
|
$rand_images = array();
|
||||||
$quantity = rand(2, 10);
|
$quantity = rand(2, 10);
|
||||||
$quantity = min($quantity, count($images));
|
$quantity = min($quantity, count($images));
|
||||||
|
|
||||||
|
if ($quantity) {
|
||||||
foreach (array_rand($images, $quantity) as $random) {
|
foreach (array_rand($images, $quantity) as $random) {
|
||||||
$rand_images[] = $images[$random]->getPHID();
|
$rand_images[] = $images[$random]->getPHID();
|
||||||
}
|
}
|
||||||
// this means you don't have any jpegs yet. we'll
|
}
|
||||||
// just use a builtin image
|
|
||||||
|
// This means you don't have any JPEGs yet. We'll just use a built-in image.
|
||||||
if (empty($rand_images)) {
|
if (empty($rand_images)) {
|
||||||
$default = PhabricatorFile::loadBuiltin(
|
$default = PhabricatorFile::loadBuiltin(
|
||||||
PhabricatorUser::getOmnipotentUser(),
|
PhabricatorUser::getOmnipotentUser(),
|
||||||
|
|
Loading…
Reference in a new issue