尝试在 google api (php) 中为 app_ad 创建 AdGroupAd 时如何解决分段错误

How to solve segmentation fault when trying to mutate create AdGroupAd for app_ad in google api (php)

我正在尝试使用现有的 groupAd 创建 AdGroupAd,但收到“分段错误”错误消息 我已经处理这个问题超过一天了,但是由于缺少有关错误的详细信息,这让我无法理解问题所在

运行 在 docker

客户端库:v5.0.0

Google 广告 API:v5.0

PHP 7.4.12 (cli)(建成时间:2020 年 11 月 5 日 20:24:10)(NTS)

Zend Engine v3.4.0,

ionCube PHP 加载器 + ionCube24 v10.4.4

Zend OPcache v7.4.12

protobuff 3.14.0

grpc 1.33.1

我的代码:假设使用 $adGroup 参数中广告组的有效资源名称调用 createAdGroupAd() 在这种情况下类型是 CreativeType_Asset::TYPE_YOUTUBE (虽然我尝试了两种类型并且都给出了错误)

public function createAdGroupAd($adGroup, $data) {
        $service = $this->client->getAdGroupAdServiceClient();

        $ad = $this->createAd($data, $data['asset']->type);

        $adGroupAd = new AdGroupAd([
            'ad' => $ad,
            'status' => AdGroupAdStatus::PAUSED,
            'ad_group' =>  $adGroup
        ]);

        $adGroupAdOperation = new AdGroupAdOperation();
        $adGroupAdOperation->setCreate($adGroupAd);

        //this is the call causing the error
        $response = $service->mutateAdGroupAds(
            $this->customerId,
            [$adGroupAdOperation]
        );

        return $response->getResults()->count() > 0 ? $response->getResults()[0]->getResourceName() : null;
    }

    public function createAd($data, $adType = null) {
        $service = $this->client->getAdServiceClient();
        $appAdInfo = new AppAdInfo([
            'headlines' => array_map(function ($headline) {
                new AdTextAsset(['text' => $headline]);
            }, [$data['creative']->title1, $data['creative']->title2]),
            'descriptions' => array_map(function ($description) {
                new AdTextAsset(['text' => $description]);
            }, [$data['creative']->description1, $data['creative']->description2])
        ]);

        switch ($adType) {
            case CreativeType_Asset::TYPE_IMAGE:
                $appAdInfo->setImages([new AdImageAsset(['asset' => $data['assetResourceName']])]);
                break;
            case CreativeType_Asset::TYPE_YOUTUBE:
                $appAdInfo->setYoutubeVideos([new AdVideoAsset(['asset' => $data['assetResourceName']])]);
                break;
            default:
                break;
        }

        return new Ad([
            'app_ad' => $appAdInfo,
            'type' => AdType::APP_AD]);
    }

问题是 AppAdInfo 构建部分的 array_map 函数中缺少“return”语句。