From 4c51da7c0b44dfe59725f2772d32f93eb2b120e6 Mon Sep 17 00:00:00 2001 From: Zachary Luna Date: Tue, 27 Jul 2021 15:02:18 -0700 Subject: [PATCH 01/17] Update Exception type of UrlFetchStream --- src/Api/UrlFetch/UrlFetchStream.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Api/UrlFetch/UrlFetchStream.php b/src/Api/UrlFetch/UrlFetchStream.php index 32fb7cee..4d917c87 100644 --- a/src/Api/UrlFetch/UrlFetchStream.php +++ b/src/Api/UrlFetch/UrlFetchStream.php @@ -301,8 +301,8 @@ public function stream_open(string $url, string $mode, int $optionsStream, &$ope $this->urlFetchResponse = $resp; $this->stream = new CachingStream(Stream::factory($resp->getContent())); $this->responseHeaders = $this->buildHeaderArray($resp->getStatuscode(), $resp->getHeaderList()); - } catch (Exception $e) { - throw new Exception(sprintf("Caught UrlFetch Exception: %s", $e->getMessage())); + } catch (ApplicationError $e) { + throw new Exception(sprintf("Caught UrlFetch Exception: %s", $e->getApplicationError())); } if ($resp->getStatuscode() >= 400) { From 147747bdf4ac8795de5c45741896449f10d47e16 Mon Sep 17 00:00:00 2001 From: Zachary Luna Date: Tue, 27 Jul 2021 15:09:00 -0700 Subject: [PATCH 02/17] update exception --- src/Api/UrlFetch/UrlFetchStream.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Api/UrlFetch/UrlFetchStream.php b/src/Api/UrlFetch/UrlFetchStream.php index 4d917c87..401ec357 100644 --- a/src/Api/UrlFetch/UrlFetchStream.php +++ b/src/Api/UrlFetch/UrlFetchStream.php @@ -302,7 +302,8 @@ public function stream_open(string $url, string $mode, int $optionsStream, &$ope $this->stream = new CachingStream(Stream::factory($resp->getContent())); $this->responseHeaders = $this->buildHeaderArray($resp->getStatuscode(), $resp->getHeaderList()); } catch (ApplicationError $e) { - throw new Exception(sprintf("Caught UrlFetch Exception: %s", $e->getApplicationError())); + // throw new Exception(sprintf("Caught UrlFetch Exception: %s", $e->getApplicationError())); + throw $e; } if ($resp->getStatuscode() >= 400) { From 930cf167705f80e69bc7277ca0dc05e9d0dce432 Mon Sep 17 00:00:00 2001 From: Zachary Luna Date: Tue, 27 Jul 2021 18:02:38 -0700 Subject: [PATCH 03/17] update pushtask --- src/Api/TaskQueue/PushTask.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Api/TaskQueue/PushTask.php b/src/Api/TaskQueue/PushTask.php index e8d4f69e..3b0be8e5 100644 --- a/src/Api/TaskQueue/PushTask.php +++ b/src/Api/TaskQueue/PushTask.php @@ -66,13 +66,13 @@ final class PushTask { 'header' => '', ]; - private $url; + public $url; - private $query_data; + public $query_data; - private $options; + public $options; - private $headers = []; + public $headers = []; /** * Construct a PushTask. From 9a908918f0dc034d42f252faa2efc48201a3fc55 Mon Sep 17 00:00:00 2001 From: Zachary Luna Date: Tue, 27 Jul 2021 20:09:33 -0700 Subject: [PATCH 04/17] update pushtask --- src/Api/TaskQueue/PushTask.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Api/TaskQueue/PushTask.php b/src/Api/TaskQueue/PushTask.php index 3b0be8e5..6bc9e5c5 100644 --- a/src/Api/TaskQueue/PushTask.php +++ b/src/Api/TaskQueue/PushTask.php @@ -195,6 +195,9 @@ public function __construct($url_path, $query_data = [], $options = []) { $has_content_type = !empty($this->headers); $header_array = explode("\r\n", $header); + + echo "Header Array: " . print_r($header_array) . "\n"; + foreach ($header_array as $h) { $h = trim($h); if (empty($h)) { @@ -210,6 +213,7 @@ public function __construct($url_path, $query_data = [], $options = []) { throw new \InvalidArgumentException('Content-type header may not ' . 'be specified as it is set by the task.'); } + echo "Headerss: " . print_r($h) . "\n"; $this->headers[] = $h; } } From 541d18f44bc47abcd129c8dacf87d9a21ca18d47 Mon Sep 17 00:00:00 2001 From: Zachary Luna Date: Tue, 27 Jul 2021 20:13:53 -0700 Subject: [PATCH 05/17] update pushtask --- src/Api/TaskQueue/PushTask.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Api/TaskQueue/PushTask.php b/src/Api/TaskQueue/PushTask.php index 6bc9e5c5..9de4b459 100644 --- a/src/Api/TaskQueue/PushTask.php +++ b/src/Api/TaskQueue/PushTask.php @@ -214,7 +214,7 @@ public function __construct($url_path, $query_data = [], $options = []) { 'be specified as it is set by the task.'); } echo "Headerss: " . print_r($h) . "\n"; - $this->headers[] = $h; + $this->headers = $h; } } From 1c56530dda7759e3ec37e1b67ff85fb5cf73dcbe Mon Sep 17 00:00:00 2001 From: Zachary Luna Date: Tue, 27 Jul 2021 20:17:50 -0700 Subject: [PATCH 06/17] update pushtask --- src/Api/TaskQueue/PushTask.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Api/TaskQueue/PushTask.php b/src/Api/TaskQueue/PushTask.php index 9de4b459..61fa9de3 100644 --- a/src/Api/TaskQueue/PushTask.php +++ b/src/Api/TaskQueue/PushTask.php @@ -214,7 +214,7 @@ public function __construct($url_path, $query_data = [], $options = []) { 'be specified as it is set by the task.'); } echo "Headerss: " . print_r($h) . "\n"; - $this->headers = $h; + array_push($this->headers, $h); } } From ad17e37ed6c4455a95796283a69150afcf1c1f19 Mon Sep 17 00:00:00 2001 From: Zachary Luna Date: Tue, 27 Jul 2021 20:21:12 -0700 Subject: [PATCH 07/17] update pushtask --- src/Api/TaskQueue/PushTask.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Api/TaskQueue/PushTask.php b/src/Api/TaskQueue/PushTask.php index 61fa9de3..31234c7e 100644 --- a/src/Api/TaskQueue/PushTask.php +++ b/src/Api/TaskQueue/PushTask.php @@ -213,8 +213,8 @@ public function __construct($url_path, $query_data = [], $options = []) { throw new \InvalidArgumentException('Content-type header may not ' . 'be specified as it is set by the task.'); } - echo "Headerss: " . print_r($h) . "\n"; - array_push($this->headers, $h); + echo "\nHeaderss: " . print_r($h[0]) . "\n"; + array_push($this->headers, $h[0]); } } From 28a5c959b9f5f90ca7c07054141ccf70cf76cb65 Mon Sep 17 00:00:00 2001 From: Zachary Luna Date: Tue, 27 Jul 2021 20:24:08 -0700 Subject: [PATCH 08/17] update pushtask --- src/Api/TaskQueue/PushTask.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Api/TaskQueue/PushTask.php b/src/Api/TaskQueue/PushTask.php index 31234c7e..8a52750b 100644 --- a/src/Api/TaskQueue/PushTask.php +++ b/src/Api/TaskQueue/PushTask.php @@ -213,8 +213,8 @@ public function __construct($url_path, $query_data = [], $options = []) { throw new \InvalidArgumentException('Content-type header may not ' . 'be specified as it is set by the task.'); } - echo "\nHeaderss: " . print_r($h[0]) . "\n"; - array_push($this->headers, $h[0]); + echo "\nHeaderss: " . $h . "\n"; + array_push($this->headers, $h); } } From bf550f4c620795e1aa61b4b84f75e197c0b0a49a Mon Sep 17 00:00:00 2001 From: Zachary Luna Date: Tue, 27 Jul 2021 20:41:16 -0700 Subject: [PATCH 09/17] update pushtask --- src/Api/TaskQueue/PushTask.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Api/TaskQueue/PushTask.php b/src/Api/TaskQueue/PushTask.php index 8a52750b..87ffc6e5 100644 --- a/src/Api/TaskQueue/PushTask.php +++ b/src/Api/TaskQueue/PushTask.php @@ -213,7 +213,7 @@ public function __construct($url_path, $query_data = [], $options = []) { throw new \InvalidArgumentException('Content-type header may not ' . 'be specified as it is set by the task.'); } - echo "\nHeaderss: " . $h . "\n"; + echo "
Headerss: " . $h . "
"; array_push($this->headers, $h); } } From 5df0da4687a5ead6abe9852d5a561bd6e06ce162 Mon Sep 17 00:00:00 2001 From: Zachary Luna Date: Tue, 27 Jul 2021 20:51:33 -0700 Subject: [PATCH 10/17] update pushtask --- src/Api/TaskQueue/PushQueue.php | 2 +- src/Api/TaskQueue/PushTask.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Api/TaskQueue/PushQueue.php b/src/Api/TaskQueue/PushQueue.php index fdfa520f..ff3caa94 100644 --- a/src/Api/TaskQueue/PushQueue.php +++ b/src/Api/TaskQueue/PushQueue.php @@ -158,7 +158,7 @@ public function addTasks($tasks) { 'All values in $tasks must be instances of PushTask. ' . 'Actual type: ' . gettype($task)); } - $names[] = $task->getName(); + array_push($names, $task->getName()); $add = $req->addAddRequest(); $add->setQueueName($this->name); $add->setTaskName($task->getName()); diff --git a/src/Api/TaskQueue/PushTask.php b/src/Api/TaskQueue/PushTask.php index 87ffc6e5..b41fa226 100644 --- a/src/Api/TaskQueue/PushTask.php +++ b/src/Api/TaskQueue/PushTask.php @@ -177,7 +177,7 @@ public function __construct($url_path, $query_data = [], $options = []) { if (in_array($this->options['method'], ['GET', 'HEAD', 'DELETE'])) { $this->url = $url_path . '?' . http_build_query($query_data); } else { // PUT or POST - $this->headers[] = 'content-type: application/x-www-form-urlencoded'; + array_push($this->headers,'content-type: application/x-www-form-urlencoded'); } } if (strlen($this->url) > self::MAX_URL_LENGTH) { From 80e0e7ba38dc3168b2008ed07aa476f05b85d4d9 Mon Sep 17 00:00:00 2001 From: Zachary Luna Date: Tue, 27 Jul 2021 21:09:01 -0700 Subject: [PATCH 11/17] update pushtask --- src/Api/TaskQueue/PushTask.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Api/TaskQueue/PushTask.php b/src/Api/TaskQueue/PushTask.php index b41fa226..61369fd3 100644 --- a/src/Api/TaskQueue/PushTask.php +++ b/src/Api/TaskQueue/PushTask.php @@ -214,7 +214,8 @@ public function __construct($url_path, $query_data = [], $options = []) { 'be specified as it is set by the task.'); } echo "
Headerss: " . $h . "
"; - array_push($this->headers, $h); + // array_push($this->headers, $h); + $this->headers[] = $h; } } From be1b9dcfc953994cba5c4312a64c6a4f483e051d Mon Sep 17 00:00:00 2001 From: Zachary Luna Date: Tue, 27 Jul 2021 21:15:02 -0700 Subject: [PATCH 12/17] update pushtask --- src/Api/TaskQueue/PushQueue.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Api/TaskQueue/PushQueue.php b/src/Api/TaskQueue/PushQueue.php index ff3caa94..af29b0fc 100644 --- a/src/Api/TaskQueue/PushQueue.php +++ b/src/Api/TaskQueue/PushQueue.php @@ -170,6 +170,8 @@ public function addTasks($tasks) { $header_pb = $add->addHeader(); $header_pb->setKey(trim($pair[0])); $header_pb->setValue(trim($pair[1])); + echo "
ZACH KEY&VALUE: " . trim($pair[0]) . " " . trim($pair[1]); + } // TODO: Replace getQueryData() with getBody() and simplify the following // block. From 425ab0fb316f44095a5c46b6c8ef1d1718e8eb8d Mon Sep 17 00:00:00 2001 From: Zachary Luna Date: Wed, 28 Jul 2021 10:40:30 -0700 Subject: [PATCH 13/17] update pushtask --- src/Api/TaskQueue/PushQueue.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Api/TaskQueue/PushQueue.php b/src/Api/TaskQueue/PushQueue.php index af29b0fc..1f7db3a4 100644 --- a/src/Api/TaskQueue/PushQueue.php +++ b/src/Api/TaskQueue/PushQueue.php @@ -188,7 +188,7 @@ public function addTasks($tasks) { } try { - ApiProxy::makeSyncCall('taskqueue', 'BulkAdd', $req, $resp); + ApiProxy::makeSyncCall('taskqueue', 'Add', $req, $resp); } catch (ApplicationError $e) { throw self::errorCodeToException($e->getApplicationError()); } From 435041562e7e205e1ee48b6314aeb040d9f7e179 Mon Sep 17 00:00:00 2001 From: Zachary Luna Date: Wed, 28 Jul 2021 10:46:59 -0700 Subject: [PATCH 14/17] update pushtask --- src/Api/TaskQueue/PushQueue.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Api/TaskQueue/PushQueue.php b/src/Api/TaskQueue/PushQueue.php index 1f7db3a4..af29b0fc 100644 --- a/src/Api/TaskQueue/PushQueue.php +++ b/src/Api/TaskQueue/PushQueue.php @@ -188,7 +188,7 @@ public function addTasks($tasks) { } try { - ApiProxy::makeSyncCall('taskqueue', 'Add', $req, $resp); + ApiProxy::makeSyncCall('taskqueue', 'BulkAdd', $req, $resp); } catch (ApplicationError $e) { throw self::errorCodeToException($e->getApplicationError()); } From 9c271ac137643c5d1dcec0e671f761b33c526d63 Mon Sep 17 00:00:00 2001 From: Zachary Luna Date: Wed, 28 Jul 2021 15:43:55 -0700 Subject: [PATCH 15/17] update pushtask --- src/Api/TaskQueue/PushTask.php | 6 ++---- src/Api/TaskQueue/taskqueue_service_pb.php | 9 +++++++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/Api/TaskQueue/PushTask.php b/src/Api/TaskQueue/PushTask.php index 61369fd3..d699efa7 100644 --- a/src/Api/TaskQueue/PushTask.php +++ b/src/Api/TaskQueue/PushTask.php @@ -196,8 +196,6 @@ public function __construct($url_path, $query_data = [], $options = []) { $has_content_type = !empty($this->headers); $header_array = explode("\r\n", $header); - echo "Header Array: " . print_r($header_array) . "\n"; - foreach ($header_array as $h) { $h = trim($h); if (empty($h)) { @@ -214,8 +212,8 @@ public function __construct($url_path, $query_data = [], $options = []) { 'be specified as it is set by the task.'); } echo "
Headerss: " . $h . "
"; - // array_push($this->headers, $h); - $this->headers[] = $h; + array_push($this->headers, $h); + // $this->headers[] = $h; } } diff --git a/src/Api/TaskQueue/taskqueue_service_pb.php b/src/Api/TaskQueue/taskqueue_service_pb.php index 65dda23e..53b2cc14 100644 --- a/src/Api/TaskQueue/taskqueue_service_pb.php +++ b/src/Api/TaskQueue/taskqueue_service_pb.php @@ -895,6 +895,15 @@ public function shortDebugString($prefix = "") { namespace google\appengine { class TaskQueueAddRequest extends \google\net\ProtocolMessage { private $header = array(); + + public function header_size() { + return sizeof($header); + } + + public function header($idx) { + return $header[$idx]; + } + public function getQueueName() { if (!isset($this->queue_name)) { return ''; From 7aebea54dd3b7a9ea1c127568e14a76ea50bee0b Mon Sep 17 00:00:00 2001 From: Zachary Luna Date: Wed, 28 Jul 2021 16:33:01 -0700 Subject: [PATCH 16/17] update pushtask --- src/Api/TaskQueue/taskqueue_service_pb.php | 38 +++++++++------------- 1 file changed, 15 insertions(+), 23 deletions(-) diff --git a/src/Api/TaskQueue/taskqueue_service_pb.php b/src/Api/TaskQueue/taskqueue_service_pb.php index 53b2cc14..4f92ede5 100644 --- a/src/Api/TaskQueue/taskqueue_service_pb.php +++ b/src/Api/TaskQueue/taskqueue_service_pb.php @@ -369,7 +369,7 @@ public function setUserEmail($idx, $val) { return $this; } public function addUserEmail($val) { - $this->user_email[] = $val; + array_push($this->user_email, $val); return $this; } public function clearUserEmail() { @@ -389,7 +389,7 @@ public function setWriterEmail($idx, $val) { return $this; } public function addWriterEmail($val) { - $this->writer_email[] = $val; + array_push($this->writer_email, $val); return $this; } public function clearWriterEmail() { @@ -896,14 +896,6 @@ public function shortDebugString($prefix = "") { class TaskQueueAddRequest extends \google\net\ProtocolMessage { private $header = array(); - public function header_size() { - return sizeof($header); - } - - public function header($idx) { - return $header[$idx]; - } - public function getQueueName() { if (!isset($this->queue_name)) { return ''; @@ -1018,7 +1010,7 @@ public function getHeader($idx) { } public function addHeader() { $val = new \google\appengine\TaskQueueAddRequest\Header(); - $this->header[] = $val; + array_push($this->header, $val); return $val; } public function clearHeader() { @@ -1766,7 +1758,7 @@ public function getAddRequest($idx) { } public function addAddRequest() { $val = new \google\appengine\TaskQueueAddRequest(); - $this->add_request[] = $val; + array_push($this->add_request, $val); return $val; } public function clearAddRequest() { @@ -1983,7 +1975,7 @@ public function getTaskResult($idx) { } public function addTaskResult() { $val = new \google\appengine\TaskQueueBulkAddResponse\TaskResult(); - $this->taskresult[] = $val; + array_push($this->taskresult, $val); return $val; } public function clearTaskResult() { @@ -2087,7 +2079,7 @@ public function setTaskName($idx, $val) { return $this; } public function addTaskName($val) { - $this->task_name[] = $val; + array_push($this->task_name, $val); return $this; } public function clearTaskName() { @@ -2234,7 +2226,7 @@ public function setResult($idx, $val) { return $this; } public function addResult($val) { - $this->result[] = $val; + array_push($this->result, $val); return $this; } public function clearResult() { @@ -2724,7 +2716,7 @@ public function getHeaderOverride($idx) { } public function addHeaderOverride() { $val = new \google\appengine\TaskQueueHttpHeader(); - $this->header_override[] = $val; + array_push($this->header_override, $val); return $val; } public function clearHeaderOverride() { @@ -3339,7 +3331,7 @@ public function getHeaderOverride($idx) { } public function addHeaderOverride() { $val = new \google\appengine\TaskQueueHttpHeader(); - $this->header_override[] = $val; + array_push($this->header_override, $val); return $val; } public function clearHeaderOverride() { @@ -3675,7 +3667,7 @@ public function getQueue($idx) { } public function addQueue() { $val = new \google\appengine\TaskQueueFetchQueuesResponse\Queue(); - $this->queue[] = $val; + array_push($this->queue, $val); return $val; } public function clearQueue() { @@ -3779,7 +3771,7 @@ public function setQueueName($idx, $val) { return $this; } public function addQueueName($val) { - $this->queue_name[] = $val; + array_push($this->queue_name, $val); return $this; } public function clearQueueName() { @@ -4332,7 +4324,7 @@ public function getQueueStats($idx) { } public function addQueueStats() { $val = new \google\appengine\TaskQueueFetchQueueStatsResponse\QueueStats(); - $this->queuestats[] = $val; + array_push($this->queuestats, $val); return $val; } public function clearQueueStats() { @@ -5904,7 +5896,7 @@ public function getHeader($idx) { } public function addHeader() { $val = new \google\appengine\TaskQueueQueryTasksResponse\Task\Header(); - $this->header[] = $val; + array_push($this->header, $val); return $val; } public function clearHeader() { @@ -6565,7 +6557,7 @@ public function getTask($idx) { } public function addTask() { $val = new \google\appengine\TaskQueueQueryTasksResponse\Task(); - $this->task[] = $val; + array_push($this->task, $val); return $val; } public function clearTask() { @@ -7573,7 +7565,7 @@ public function getTask($idx) { } public function addTask() { $val = new \google\appengine\TaskQueueQueryAndOwnTasksResponse\Task(); - $this->task[] = $val; + array_push($this->task, $val); return $val; } public function clearTask() { From 0a19581c71c6af8ff36da007ccb91f32f94b24a0 Mon Sep 17 00:00:00 2001 From: Zachary Luna Date: Wed, 28 Jul 2021 19:29:33 -0700 Subject: [PATCH 17/17] update pushtask --- src/Api/TaskQueue/PushTask.php | 4 ++-- src/Api/UrlFetch/UrlFetchStream.php | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Api/TaskQueue/PushTask.php b/src/Api/TaskQueue/PushTask.php index d699efa7..bed0fbe7 100644 --- a/src/Api/TaskQueue/PushTask.php +++ b/src/Api/TaskQueue/PushTask.php @@ -212,8 +212,8 @@ public function __construct($url_path, $query_data = [], $options = []) { 'be specified as it is set by the task.'); } echo "
Headerss: " . $h . "
"; - array_push($this->headers, $h); - // $this->headers[] = $h; + // array_push($this->headers, $h); + $this->headers[] = $h; } } diff --git a/src/Api/UrlFetch/UrlFetchStream.php b/src/Api/UrlFetch/UrlFetchStream.php index 401ec357..4d917c87 100644 --- a/src/Api/UrlFetch/UrlFetchStream.php +++ b/src/Api/UrlFetch/UrlFetchStream.php @@ -302,8 +302,7 @@ public function stream_open(string $url, string $mode, int $optionsStream, &$ope $this->stream = new CachingStream(Stream::factory($resp->getContent())); $this->responseHeaders = $this->buildHeaderArray($resp->getStatuscode(), $resp->getHeaderList()); } catch (ApplicationError $e) { - // throw new Exception(sprintf("Caught UrlFetch Exception: %s", $e->getApplicationError())); - throw $e; + throw new Exception(sprintf("Caught UrlFetch Exception: %s", $e->getApplicationError())); } if ($resp->getStatuscode() >= 400) {