亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Google Cloud Vision - 解析期間發生 PHP 錯誤

Google Cloud Vision - 解析期間發生 PHP 錯誤

PHP
婷婷同學_ 2022-10-09 19:51:53
我正在使用適用于 PHP 的 Vision API 客戶端庫。這是我的代碼:use Google\Cloud\Vision\V1\ImageAnnotatorClient;putenv("GOOGLE_APPLICATION_CREDENTIALS=/json.json");$imageAnnotator = new ImageAnnotatorClient();$fileName = 'textinjpeg.jpg';$image = file_get_contents($fileName);$response = $imageAnnotator->labelDetection($image);$labels = $response->getLabelAnnotations();if ($labels) {    echo("Labels:" . PHP_EOL);    foreach ($labels as $label) {        echo($label->getDescription() . PHP_EOL);    }} else {    echo('No label found' . PHP_EOL);}我收到這個錯誤:Error occurred during parsing: Fail to push limit. (0)/srv/www/site.ru/htdocs/vendor/google/protobuf/src/Google/Protobuf/Internal/CodedInputStream.php:345#0: Google\Protobuf\Internal\CodedInputStream-&gt;pushLimit(integer)    /srv/www/site.ru/htdocs/vendor/google/protobuf/src/Google/Protobuf/Internal/CodedInputStream.php:368#1: Google\Protobuf\Internal\CodedInputStream-&gt;incrementRecursionDepthAndPushLimit(integer, integer, integer)............#15: Google\Cloud\Vision\V1\ImageAnnotatorClient-&gt;labelDetection(string)/srv/www/site.ru/htdocs/local/php_interface/GoogleCloud.php:41這是異常來自的地方:public function pushLimit($byte_limit){    // Current position relative to the beginning of the stream.    $current_position = $this->current();    $old_limit = $this->current_limit;    // security: byte_limit is possibly evil, so check for negative values    // and overflow.    if ($byte_limit >= 0 &&        $byte_limit <= PHP_INT_MAX - $current_position &&        $byte_limit <= $this->current_limit - $current_position) {        $this->current_limit = $current_position + $byte_limit;        $this->recomputeBufferLimits();    } else {        throw new GPBDecodeException("Fail to push limit.");    }    return $old_limit;}$byte_limit <= $this->current_limit - $current_position是真的我應該增加 current_position 嗎?如果我應該,我該怎么做?在服務器或 PHP 配置中更改某些內容?
查看完整描述

3 回答

?
青春有我

TA貢獻1784條經驗 獲得超8個贊

這是一件很瘋狂的事情!

論壇中不時出現“無法推送限制”錯誤。關于問題可能出在哪里,那里給出了各種想法。一個原因可能是源代碼通過 Composer 在本地 PC 上編寫,然后通過 (S)FTP 傳輸到服務器。FTP 程序根據文件擴展名決定將數據以 ASCII 格式還是二進制格式保存在服務器上。

在 vendor/google/protobuf/src/Google/Protobuf/ 中,有各種生成的文件具有 .php 擴展名,但實際上是二進制文件!(如果您打開文件,您可以立即看到它,例如:vendor/google/protobuf/src/GPBMetadata/Google/Protobuf/Any.php)在我的案例中,通過二進制文件將這些文件顯式傳輸到服務器的解決方案有效!如果有疑問,請將 Google/protobuf 中的完整模塊作為二進制文件傳輸...


查看完整回答
反對 回復 2022-10-09
?
慕碼人8056858

TA貢獻1803條經驗 獲得超6個贊

mbstring.func_overload 為 2 這是錯誤的原因 更改為 0 并且有效



查看完整回答
反對 回復 2022-10-09
?
暮色呼如

TA貢獻1853條經驗 獲得超9個贊

你提到那$byte_limit <= $this->current_limit - $current_position是真的,所以要么$byte_limit >= 0或要么$byte_limit <= PHP_INT_MAX - $current_position是假的。

如果$byte_limit <= PHP_INT_MAX - $current_position是假的,那么增加$current_position,不會變成真的。如果要調整值,使表達式被評估為真,則需要增加 PHP_INT_MAX 的值。

如果$byte_limit >= 0為假,則修改$current_limit不會避免異常。

無論哪種方式,錯誤似乎都是protobufphp 庫的問題,所以我建議您在那里報告問題,而不是嘗試直接修改值。


查看完整回答
反對 回復 2022-10-09
  • 3 回答
  • 0 關注
  • 220 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號