NatLibFi / RecordManager

A metadata record management system written in PHP, intended to be used in conjunction with VuFind or another Solr-based discovery interface. Provides import, export, harvesting (OAI-PMH), normalization, deduplication and Solr index update functionality with support for multiple metadata formats. Also includes an OAI-PMH provider that can be used to access the data stored in RecordManager database. Functionality driven by simple command line programs for easy automation.
GNU General Public License v2.0
47 stars 31 forks source link

Undefined array key "componentParts" in MetadataUtils::isHiddenComponentPart() #163

Open jschultze opened 3 months ago

jschultze commented 3 months ago

I have not yet fully understood the problem, and will create a pull request if I do. Until then, I just wanted to document it here.

When running the deduplication command, multiple errors of this kind appear in the logs:

PHP Warning:  Undefined array key "componentParts" in /opt/RecordManager/src/RecordManager/Base/Utils/MetadataUtils.php on line 1014
Warning: Undefined array key "componentParts" in /opt/RecordManager/src/RecordManager/Base/Utils/MetadataUtils.php on line 1014

PHP Warning:  Undefined array key "componentParts" in /opt/RecordManager/src/RecordManager/Base/Utils/MetadataUtils.php on line 1017
Warning: Undefined array key "componentParts" in /opt/RecordManager/src/RecordManager/Base/Utils/MetadataUtils.php on line 1017

PHP Warning:  Undefined array key "componentParts" in /opt/RecordManager/src/RecordManager/Base/Utils/MetadataUtils.php on line 1018
Warning: Undefined array key "componentParts" in /opt/RecordManager/src/RecordManager/Base/Utils/MetadataUtils.php on line 1018

The value for componentParts is not explicitly configured in datasources.ini. It should then be set to the default value "as_is" in initSourceSettings() of src/RecordManager/Base/Command/AbstractBase.php, but that does not seem to happen.

One solution would be to check for this array key in isHiddenComponentPart() of src/RecordManager/Base/Utils/MetadataUtils.php, but as far as I read the code, the default value should be set all right. So there might be an error lying underneath and such a direct check would not take that into consideration.

System: PHP 8.2.19 on Debian 11.

EreMaijala commented 2 months ago

It might provide some insight if you'd add this before the first attempt to access $settings['componentParts']:

            if (!isset($settings['componentParts'])) {
                echo "Missing componentParts setting for " . $record['source_id'] . ":\n";
                var_export($settings);
            }
EreMaijala commented 1 hour ago

@jschultze Did you try the suggestion above? Any results? Another option, if feasible, would be to run under debugger with it set to stop on all warnings.