Hi, I have an old custom WP site that was working fine running PHP 7.3.9 and WP 4.9.18 and since upgrading to PHP 7.4.21 and WP 5.6.10 the archive links by year to access older data are no longer doing anything other than reloading the same page. I was wondering if someone might be able to take a look and see if they see anything obvious that could be causing the issue on the PHP side? I added a few comments of some errors WP was logging but they seem fairly inconsequential in regard to this problem but maybe there is something there. Much appreciated thanks!
PHP:
<!-- Was working PHP 7.3.9, WP 4.9.18
Not working PHP 7.4.21, WP 5.6.10 -->
<div>
<h3>Newsletter</h3>
<ul>
<?php $urlSplits = explode('/', $_SERVER['REQUEST_URI']); ?>
<?php $counter = 0; ?>
<?php
while(the_repeater_field('external-links')):
$tempDate = explode(',', get_sub_field('date'));
$mediaYears[] = $tempDate['1']; // *** Notice: Undefined offset: 1
$data[$counter]['year'] = $tempDate['1']; // *** Notice: Undefined offset: 1
$data[$counter]['date'] = get_sub_field('date');
$data[$counter]['link'] = get_sub_field('link');
$data[$counter]['title'] = get_sub_field('title');
$counter++;
endwhile;
?>
<?php
$keys = 0;
$mediaYears = array_unique($mediaYears);
foreach ($mediaYears as $value) {
if ($value != '') {
$uniqueYears[$keys] = $value;
$keys++;
}
}
rsort($uniqueYears);
$data = array_reverse($data, true);
if ($urlSplits[3] != '') {
$currentYear = str_replace(' ', '', $urlSplits[3]);
} else {
$currentYear = str_replace(' ', '', $uniqueYears[0]);
}
?>
<?php for($i = count($data); $i >= 0; $i--) { ?>
<?php if ($currentYear == $data[$i]['year']) {
// *** Notice: Undefined offset: 135
// *** Notice: Trying to access array offset on value of type null
?>
<li>
<em><?php echo $data[$i]['date'] ?></em>
<strong><a href="<?php echo $data[$i]['link'] ?>" rel="bookmark"><?php echo $data[$i]['title'] ?></a></strong>
</li>
<?php } ?>
<?php } ?>
</ul>
<?php for ($i = 0; $i < count($uniqueYears); $i++) { ?>
<!-- THIS IS THE LINE THAT CREATES THE YEAR LINKS TO GO TO ARCHIVE PAGES -->
<a href="https://www.domain.org/news/newsletter/<?php echo str_replace(' ', '', $uniqueYears[$i]); ?>"><?php echo $uniqueYears[$i]; ?></a>
<!-- Permalink set to Custom Structure: /news/%category%/%year%/%monthnum%/%postname%/ (Not sure if this is relevant) -->
<?php } ?>
</div>