googleapis/google-cloud-php

[16384] text_styles is deprecated. Fatal error on line 307 in /shared/libs/vendor/google/cloud-document-ai/src/V1/Document.php

ethan1141 opened this issue · 1 comments

I encountered a fatal error due to the deprecation of text_styles while working with Google Cloud Document AI on my PHP application.

System Information
Library Version: 2.1.0
PHP Version: PHP 8.3.12 (cli) (built: Sep 27 2024 04:03:16) (NTS)
Environment:Debian GNU/Linux 11 (bullseye)

Steps to Reproduce
Initialize the Google Cloud Document AI library.
im calling

          $documentProcessor = new GoogleDocumentAIProcessor(GoogleDocumentAIProcessors::INVOICE);
          $document = $documentProcessor->processDocument($file->getPath() . "/" . $file->getFileName());
          $documentText = GoogleDocumentAIProcessor::processInvoiceDocument($document);

The following error is displayed:
SYSTEM ERROR - [16384] text_styles is deprecated. Fatal error on line 307 in file /shared/libs/vendor/google/cloud-document-ai/src/V1/Document.php

Expected Behavior
The text_styles deprecation should ideally trigger a deprecation warning without causing a fatal error, or a recommended alternative should be provided.

Actual Behavior
The method triggers a fatal error, halting the application. Additionally, commenting out trigger_error() results in another error:
SYSTEM EXCEPTION - Uncaught Exception: Call to undefined function Google\Protobuf\Internal\bccomp() in /shared/api.myjourneymaker.au-www/libs/vendor/google/protobuf/src/Google/Protobuf/Internal/Message.php on line 939

stack trace:

SYSTEM ERROR - [16384] text_styles is deprecated. Fatal error on line 307 in file /shared/libs/vendor/google/cloud-document-ai/src/V1/Document.php
#0 /shared/secure/classes/Init.php(456):Init->getStackTrace()
#1 unknown(0):Init->myErrorHandler()
#2 /shared/libs/vendor/google/cloud-document-ai/src/V1/Document.php(307): trigger_error()
#3 /shared/libs/vendor/google/protobuf/src/Google/Protobuf/Internal/Message.php(114): Google\Cloud\DocumentAI\V1\Document->setTextStyles()
#4 /shared/libs/vendor/google/protobuf/src/Google/Protobuf/Internal/Message.php(55): Google\Protobuf\Internal\Message->initWithGeneratedPool()
#5 /shared/libs/vendor/google/cloud-document-ai/src/V1/Document.php(155): Google\Protobuf\Internal\Message->__construct()
#6 /shared/libs/vendor/google/protobuf/src/Google/Protobuf/Internal/Message.php(804): Google\Cloud\DocumentAI\V1\Document->__construct()
#7 /shared/libs/vendor/google/protobuf/src/Google/Protobuf/Internal/Message.php(1277): Google\Protobuf\Internal\Message->convertJsonValueToProtoValue()
#8 /shared/libs/vendor/google/protobuf/src/Google/Protobuf/Internal/Message.php(1219): Google\Protobuf\Internal\Message->mergeFromArrayJsonImpl()
#9 /shared/libs/vendor/google/protobuf/src/Google/Protobuf/Internal/Message.php(1316): Google\Protobuf\Internal\Message->mergeFromJsonArray()
#10 /shared/libs/vendor/google/protobuf/src/Google/Protobuf/Internal/Message.php(773): Google\Protobuf\Internal\Message->parseFromJsonStream()
#11 /shared/libs/vendor/google/gax/src/Transport/RestTransport.php(136): Google\Protobuf\Internal\Message->mergeFromJsonString()
#12 /shared/libs/vendor/guzzlehttp/promises/src/Promise.php(209): Google\ApiCore\Transport\RestTransport->Google\ApiCore\Transport\{closure}()
#13 /shared/libs/vendor/guzzlehttp/promises/src/Promise.php(158): GuzzleHttp\Promise\Promise->callHandler()
#14 /shared/libs/vendor/guzzlehttp/promises/src/TaskQueue.php(52): GuzzleHttp\Promise\Promise->GuzzleHttp\Promise\{closure}()
#15 /shared/libs/vendor/guzzlehttp/guzzle/src/Handler/CurlMultiHandler.php(167): GuzzleHttp\Promise\TaskQueue->run()
#16 /shared/libs/vendor/guzzlehttp/guzzle/src/Handler/CurlMultiHandler.php(206): GuzzleHttp\Handler\CurlMultiHandler->tick()
#17 /shared/libs/vendor/guzzlehttp/promises/src/Promise.php(251): GuzzleHttp\Handler\CurlMultiHandler->execute()
#18 /shared/libs/vendor/guzzlehttp/promises/src/Promise.php(227): GuzzleHttp\Promise\Promise->invokeWaitFn()
#19 /shared/libs/vendor/guzzlehttp/promises/src/Promise.php(272): GuzzleHttp\Promise\Promise->waitIfPending()
#20 /shared/libs/vendor/guzzlehttp/promises/src/Promise.php(229): GuzzleHttp\Promise\Promise->invokeWaitList()
#21 /shared/libs/vendor/guzzlehttp/promises/src/Promise.php(69): GuzzleHttp\Promise\Promise->waitIfPending()
#22 /shared/libs/vendor/google/cloud-document-ai/src/V1/Gapic/DocumentProcessorServiceGapicClient.php(1883): GuzzleHttp\Promise\Promise->wait()
#23 /shared/secure/classes/helpers/services/ai/GoogleDocumentAIProcessor.php(165): Google\Cloud\DocumentAI\V1\Gapic\DocumentProcessorServiceGapicClient->processDocument()
#24 /shared/secure/classes/Invoice.php(341):services\AI\DocumentAI\GoogleDocumentAIProcessor->processDocument()
#25 /shared/secure/api/ai/document.php(28):Invoice->runAI()


as no activity, i have moved to node.js Google documentai SDK