Skip to content

Commit

Permalink
Check YEAR_BASE key exists before using
Browse files Browse the repository at this point in the history
  • Loading branch information
Ant Brown committed Dec 13, 2019
1 parent f2cae85 commit 9aa23c6
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions src/Plugin/Field/FieldFormatter/EDTFFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -216,20 +216,22 @@ protected function formatDate($edtf_text) {

// Unspecified.
$unspecified = [];
if (strpos($parsed_date[EDTFUtils::YEAR_BASE], 'XXXX') !== FALSE) {
$unspecified[] = t('year');
}
elseif (strpos($parsed_date[EDTFUtils::YEAR_BASE], 'XXX') !== FALSE) {
$unspecified[] = t('century');
}
elseif (strpos($parsed_date[EDTFUtils::YEAR_BASE], 'XX') !== FALSE) {
$unspecified[] = t('decade');
}
elseif (strpos($parsed_date[EDTFUtils::YEAR_BASE], 'X') !== FALSE) {
$unspecified[] = t('year');
if (array_key_exists(EDTFUtils::YEAR_BASE, $parsed_date)) {
if (strpos($parsed_date[EDTFUtils::YEAR_BASE], 'XXXX') !== FALSE) {
$unspecified[] = t('year');
}
elseif (strpos($parsed_date[EDTFUtils::YEAR_BASE], 'XXX') !== FALSE) {
$unspecified[] = t('century');
}
elseif (strpos($parsed_date[EDTFUtils::YEAR_BASE], 'XX') !== FALSE) {
$unspecified[] = t('decade');
}
elseif (strpos($parsed_date[EDTFUtils::YEAR_BASE], 'X') !== FALSE) {
$unspecified[] = t('year');
}
// Clean-up unspecified year/decade.
$year = str_replace('X', '0', $parsed_date[EDTFUtils::YEAR_BASE]);
}
// Clean-up unspecified year/decade.
$year = str_replace('X', '0', $parsed_date[EDTFUtils::YEAR_BASE]);

if (array_key_exists(EDTFUtils::MONTH, $parsed_date)) {
if (strpos($parsed_date[EDTFUtils::MONTH], 'X') !== FALSE) {
Expand Down

1 comment on commit 9aa23c6

@xurizaemon
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unsure if this was MR'd but it looks like this change was superseded by Islandora#134

Please sign in to comment.