Fix array declaration

This commit is contained in:
Nicolas Le Goff
2014-03-16 06:50:18 +01:00
parent 1a528b5f5f
commit b99db80fef
2 changed files with 14 additions and 11 deletions

View File

@@ -61,10 +61,10 @@ class API_Webhook
VALUES (null, :type, :data, NOW())'; VALUES (null, :type, :data, NOW())';
$stmt = $appbox->get_connection()->prepare($sql); $stmt = $appbox->get_connection()->prepare($sql);
$stmt->execute([ $stmt->execute(array(
'type' => $type, 'type' => $type,
'data' => json_encode($data), 'data' => json_encode($data),
]); ));
$stmt->closeCursor(); $stmt->closeCursor();
return new API_Webhook($appbox, $appbox->get_connection()->lastInsertId()); return new API_Webhook($appbox, $appbox->get_connection()->lastInsertId());

View File

@@ -56,7 +56,11 @@ class task_period_apiwebhooks extends task_appboxAbstract
protected function getApplicationHookUrls(appbox $appbox) protected function getApplicationHookUrls(appbox $appbox)
{ {
$stmt = $appbox->get_connection()->prepare('SELECT webhook_url FROM api_applications WHERE webhook_url IS NOT NULL'); $stmt = $appbox->get_connection()->prepare('
SELECT webhook_url
FROM api_applications
WHERE webhook_url IS NOT NULL
');
$stmt->execute(); $stmt->execute();
$rows = $stmt->fetchAll(\PDO::FETCH_ASSOC); $rows = $stmt->fetchAll(\PDO::FETCH_ASSOC);
$stmt->closeCursor(); $stmt->closeCursor();
@@ -73,11 +77,11 @@ class task_period_apiwebhooks extends task_appboxAbstract
} }
$client = new GuzzleClient(); $client = new GuzzleClient();
$body = json_encode($data); $body = json_encode($data);
$requests = []; $requests = array();
foreach ($urls as $url) { foreach ($urls as $url) {
$requests[] = $client->createRequest('POST', $url, [ $requests[] = $client->createRequest('POST', $url, array(
'Content-Type' => 'application/json' 'Content-Type' => 'application/json'
], $body); ), $body);
} }
$client->send($requests); $client->send($requests);
} }
@@ -90,16 +94,15 @@ class task_period_apiwebhooks extends task_appboxAbstract
} }
$feed = new Feed_Adapter($this->dependencyContainer, $data->{"feed_id"}); $feed = new Feed_Adapter($this->dependencyContainer, $data->{"feed_id"});
$entry = new \Feed_Entry_Adapter($this->dependencyContainer, $feed, $data->{"entry_id"}); $entry = new \Feed_Entry_Adapter($this->dependencyContainer, $feed, $data->{"entry_id"});
$query = new \User_Query($this->dependencyContainer);
$Query = new \User_Query($this->dependencyContainer); $query->include_phantoms(true)
$Query->include_phantoms(true)
->include_invite(false) ->include_invite(false)
->include_templates(false) ->include_templates(false)
->email_not_null(true); ->email_not_null(true);
if ($entry->get_feed()->get_collection()) { if ($entry->get_feed()->get_collection()) {
$Query->on_base_ids(array($entry->get_feed()->get_collection()->get_base_id())); $query->on_base_ids(array($entry->get_feed()->get_collection()->get_base_id()));
} }
$start = 0; $start = 0;
@@ -107,7 +110,7 @@ class task_period_apiwebhooks extends task_appboxAbstract
$users = array(); $users = array();
do { do {
$results = $Query->limit($start, $perLoop)->execute()->get_results(); $results = $query->limit($start, $perLoop)->execute()->get_results();
foreach ($results as $user) { foreach ($results as $user) {
$users[] = array( $users[] = array(
'mail' => $user->get_email(), 'mail' => $user->get_email(),