Skip to content

Undefined var in exception handling #200

Description

@eby

Mostly a bot issue but with the various things we might remove over time I'm sure some patrons run into the server error

When a bib doesn't exist it tries to deal with the exception but $bib_record i don't think exists

PHP message: Uncaught PHP Exception Error: "Attempt to assign property "_id" on null" at /var/www/aadlorg/web/modules/custom/arborcat/src/Controller/DefaultController.php line 67"

// Get Bib Record from API
$guzzle = \Drupal::httpClient();
try {
$json = json_decode($guzzle->get($get_url)->getBody()->getContents());
if ($get_record_selector == 'harvest') {
$bib_record = $json->bib;
$bib_record->_id = $json->_id;
}
else {
$bib_record = $json;
}
// Copy from Elasticsearch record id to same format as CouchDB _id
//$bib_record->_id = $bib_record->id;
$bib_record->id = $bib_record->_id;
} catch (\Exception $e) {
$bib_record->_id = NULL;
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions