致命错误:非抽象方法 NF_Handlers_FieldsetRepeater::isFieldsetData() 必须包含正文

Posted

技术标签:

【中文标题】致命错误:非抽象方法 NF_Handlers_FieldsetRepeater::isFieldsetData() 必须包含正文【英文标题】:Fatal error: Non-abstract method NF_Handlers_FieldsetRepeater::isFieldsetData() must contain body in 【发布时间】:2021-09-13 14:07:43 【问题描述】:

真的很需要帮助!我尝试删除分号但仍然收到此错误:

致命错误:非抽象方法 NF_Handlers_FieldsetRepeater::isFieldsetData() 必须在第 173 行的 /home/warstdam/public_html/wp-content/plugins/ninja-forms/includes/Handlers/FieldsetRepeater.php 中包含正文

/**
 * Determine if data matches fieldset repeater construct
 *
 * When given only a submission value without any meta data, check the
 * construct of the value to asssert with some level of confidence that
 * the value is from a fieldset repeater.
 *
 * Logic: 
 *  - is submission empty? then NO, we don't assert is fieldset repeater data
 *  - can the array key be parsed as a fieldset repeater key?  If not, then NO…
 *  - is each value an array with 'id' and 'value' keys,
 *    and the `id` matches the id of its parent?  If not, then NO...
 *
 * If all the above conditions are met for every entry in the submission,
 * we assert that the submission value is that of a fieldset repeater.
 * 
 *  
 * @param array $submission
 * @return boolean
 */
public function isFieldsetData(array $submission); bool

    $return = true;

    // If not array containing data, not fieldset repeater
    if (empty($submission)) 
        $return = false;
    

    foreach($submission as $key=>$submissionValueArray)
        $submissionReference = $this->parseFieldsetFieldReference($key);

        if(-1===$submissionReference)
            $return = false;
        

        if(!isset($submissionValueArray['id'])
           || $key!==$submissionValueArray['id']
           || !isset($submissionValueArray['value']))
            $return = false;
        
    

代码到此结束


    $return = [];

    if (!is_array($fieldSubmissionValue)) 
        return $return;
    

    if(''!==$fieldId and []!== $fieldSettings)

        $fieldsetLabelLookup = $this->getFieldsetLabels($fieldId, $fieldSettings);
        $fieldsetTypeLookup = $this->getFieldsetTypes($fieldId,$fieldSettings);
    else
        
        $fieldsetLabelLookup = null;
        $fieldsetTypeLookup = null;
    


    // $completeFieldsetID is in format fieldsetRepeaterFieldIdfieldsetDelimiterfieldsetFieldIdsubmissionIndexDelimitersubmissionIndex
    foreach ($fieldSubmissionValue as $completeFieldsetId => $incomingValueArray) 

        // value is expected to be keyed inside incoming value array
        if (isset($incomingValueArray['value'])) 
            $value = $incomingValueArray['value'];
         else 
            $value = $incomingValueArray;
        

        // attempt parsing of fielsetField; if any fail, exit as data is corrupt
        $fieldsetWithSubmissionIndex = $this->parseFieldsetFieldReference($completeFieldsetId);

        if (0 == $fieldsetWithSubmissionIndex['fieldsetFieldId']) 

            return $return;
        

        $parsedSubmissionIds = $this->parseSubmissionIndex($fieldsetWithSubmissionIndex['fieldsetFieldId']);

        if (-1 === $parsedSubmissionIds['submissionIndex']) 
            return $return;
        

        $fieldsetFieldId = $parsedSubmissionIds['fieldsetFieldId'];


        $submissionIndex = $parsedSubmissionIds['submissionIndex'];

        $idKey = $fieldId . $this->fieldsetDelimiter . $fieldsetFieldId;

        if(is_null($fieldsetTypeLookup))
            $fieldsetFieldType='';
        else
            $fieldsetFieldType = $fieldsetTypeLookup[$idKey];
        
        
        if(is_null($fieldsetLabelLookup))
            $fieldsetFieldLabel='';
        else
            $fieldsetFieldLabel = $fieldsetLabelLookup[$idKey];
        


        $array = [];
        $array['value'] = $value;
        $array['type'] = $fieldsetFieldType;
        $array['label'] = $fieldsetFieldLabel;

        $return[$submissionIndex][$fieldsetFieldId] = $array;
    

    return $return;

【问题讨论】:

这是我需要添加其他内容的部分吗?公共函数 isFieldsetData(array $submission); bool $return = true; (作为代码结尾引入的代码块已损坏:查看它下面的孤立。)我发现将代码包含在其中最不容易出错仅包含 ~~~ 的行。 $return 在第一个块中是布尔值,在第二个块中订阅:我觉得很混乱的状态。 【参考方案1】:

看起来像语法错误。 将; bool 更改为: bool

public function isFieldsetData(array $submission): bool

【讨论】:

当我这样做时,它会说:解析错误:语法错误,意外':',期待';'或 '' 在 /home/warstdam/public_html/wp-content/plugins/ninja-forms/includes/Handlers/FieldsetRepeater.php 第 207 行 @Lou。好的,第 207 行是什么?您能否更新显示该部分的问题? No It is sayihng: Parse error: syntax error, unexpected end of file in /home/warstdam/public_html/wp-content/plugins/ninja-forms/includes/Handlers/FieldsetRepeater.php 在线第454章 我设法修复了第 173 行的语法,但现在它说它没有文件结尾?抱歉,我对此很陌生,只是想帮助一位朋友使用她的网站。 @Lou。好的,第 454 行是什么?您能否更新显示该部分的问题?

以上是关于致命错误:非抽象方法 NF_Handlers_FieldsetRepeater::isFieldsetData() 必须包含正文的主要内容,如果未能解决你的问题,请参考以下文章

在 Crashlytics 上记录非致命错误

Drupal - 致命错误sessionhandler

完成未停用或关闭的游标非致命错误

致命错误:在非对象上调用成员函数 fetch()?

使命召唤14致命错误怎么解决?

致命错误:在第 7 行调用非对象上的成员函数 prepare()。我想不通,为啥会出现此错误?