# Product Updates Individual Pages Troubleshooting Guide


**Last Updated:** 2025-11-20

## Overview

This document provides comprehensive troubleshooting steps for individual product update pages (e.g., `/produkt-updates/november-2025`).

## Common Issues and Solutions

### Issue 1: Page Returns 404 or Redirects to Main Page

**Symptoms:**

- Accessing `/produkt-updates/november-2025` redirects to `/produkt-updates`
- Browser shows 404 error
- URL appears correct but page doesn't load

**Possible Causes:**

1. **.htaccess Routing Issue**

   - Check that `.htaccess` contains the correct rewrite rule:
     ```apache
     RewriteRule ^produkt-updates\/([^\/]+)\/?$ v2/pages/produkt_updates_month.php?month=$1 [L,QSA]
     ```
   - Verify Apache mod_rewrite is enabled
   - Check that `.htaccess` files are allowed in Apache configuration

2. **Month Slug Not Found**

   - Verify the month slug exists in `v2/data/produkt_updates.json`
   - Check that the slug matches exactly (case-sensitive, no extra spaces)
   - Example: `november-2025` should exist in `months` object

3. **Invalid Month Slug Format**
   - Month slugs are sanitized to only allow: lowercase letters, numbers, hyphens, underscores
   - Invalid characters are automatically removed
   - Check browser console for redirects

**Solution Steps:**

1. Test .htaccess routing:

   ```bash
   curl -I https://www.ordio.com/produkt-updates/november-2025
   ```

2. Verify month exists in JSON:

   ```bash
   php -r "require 'v2/data/produkt_updates.json'; \$data = json_decode(file_get_contents('v2/data/produkt_updates.json'), true); echo isset(\$data['months']['november-2025']) ? 'Found' : 'Not found';"
   ```

3. Check Apache error logs for rewrite rule failures

### Issue 2: PHP Errors on Page Load

**Symptoms:**

- Page shows PHP warnings or errors
- White screen or partial page load
- Error messages in browser console

**Common PHP Errors:**

1. **Array Access on Non-Array**

   ```
   Warning: usort() expects parameter 1 to be array
   ```

   - **Fix:** Already handled in code with `is_array()` checks
   - **Verify:** Check that `big_features` and `small_improvements` are arrays in JSON

2. **Undefined Index**

   ```
   Notice: Undefined index: month
   ```

   - **Fix:** Already handled with `??` null coalescing operator
   - **Verify:** Check JSON structure matches expected format

3. **Include Path Errors**
   ```
   Warning: include(../base/head.php): Failed to open stream
   ```
   - **Fix:** Paths are correct relative to `v2/pages/`
   - **Verify:** Check that `v2/base/head.php` exists
   - **Note:** This error only occurs when running PHP from command line with wrong working directory

**Solution Steps:**

1. Enable error reporting temporarily:

   ```php
   error_reporting(E_ALL);
   ini_set('display_errors', 1);
   ```

2. Check PHP error logs:

   ```bash
   tail -f /var/log/apache2/error.log
   # or
   tail -f /var/log/php/error.log
   ```

3. Validate JSON structure:
   ```bash
   php -r "json_decode(file_get_contents('v2/data/produkt_updates.json'), true) ?: exit(1); echo 'Valid JSON';"
   ```

### Issue 3: JSON-LD Schema Errors

**Symptoms:**

- Google Rich Results Test shows errors
- Schema validation fails
- Browser console shows JSON parsing errors

**Common Schema Errors:**

1. **Trailing Comma**

   - **Fix:** Already handled with conditional comma placement
   - **Verify:** Check schema output with JSON validator

2. **Invalid Date Format**

   - **Fix:** Dates use ISO 8601 format
   - **Verify:** Check `datePublished` and `dateModified` formats

3. **Missing Required Fields**
   - **Fix:** All required BlogPosting fields are present
   - **Verify:** Use Google Rich Results Test

**Solution Steps:**

1. Extract and validate JSON-LD:

   ```bash
   curl -s https://www.ordio.com/produkt-updates/november-2025 | grep -o '<script type="application/ld+json">.*</script>' | sed 's/<script[^>]*>//;s/<\/script>//' | python -m json.tool
   ```

2. Test with Google Rich Results Test:
   - Visit: https://search.google.com/test/rich-results
   - Enter URL: `https://www.ordio.com/produkt-updates/november-2025`
   - Review errors and warnings

### Issue 4: Images Not Displaying

**Symptoms:**

- Feature images don't appear
- Broken image icons
- 404 errors for image paths

**Possible Causes:**

1. **Incorrect Image Paths**

   - Images should be relative to web root (start with `/`)
   - Example: `/v2/img/produkt-updates/image.png`

2. **Missing Image Files**

   - Verify images exist at specified paths
   - Check file permissions (should be readable)

3. **Image Array Structure**
   - Features: `images` is an array
   - Improvements: `image` is a string

**Solution Steps:**

1. Verify image paths in JSON:

   ```bash
   php -r "\$data = json_decode(file_get_contents('v2/data/produkt_updates.json'), true); foreach(\$data['months']['november-2025']['big_features'] as \$f) { if(!empty(\$f['images'])) print_r(\$f['images']); }"
   ```

2. Check if images exist:

   ```bash
   ls -la v2/img/produkt-updates/
   ```

3. Test image URLs:
   ```bash
   curl -I https://www.ordio.com/v2/img/produkt-updates/image.png
   ```

### Issue 5: Content Not Displaying

**Symptoms:**

- Features or improvements don't show
- Empty sections
- Content appears but is incorrect

**Possible Causes:**

1. **Empty Arrays**

   - Features or improvements arrays are empty
   - Arrays don't exist in JSON

2. **Missing Required Fields**

   - `title` or `description` missing
   - `number` field missing or invalid

3. **Sorting Issues**
   - Features not sorted by number
   - Missing `number` field causes sorting errors

**Solution Steps:**

1. Check data structure:

   ```bash
   php -r "\$data = json_decode(file_get_contents('v2/data/produkt_updates.json'), true); \$month = \$data['months']['november-2025']; echo 'Features: ' . count(\$month['big_features'] ?? []) . PHP_EOL; echo 'Improvements: ' . count(\$month['small_improvements'] ?? []) . PHP_EOL;"
   ```

2. Validate feature structure:
   ```bash
   php -r "\$data = json_decode(file_get_contents('v2/data/produkt_updates.json'), true); \$feature = \$data['months']['november-2025']['big_features'][0] ?? null; if(\$feature) { echo 'Has title: ' . (isset(\$feature['title']) ? 'Yes' : 'No') . PHP_EOL; echo 'Has number: ' . (isset(\$feature['number']) ? 'Yes' : 'No') . PHP_EOL; }"
   ```

## Testing Checklist

### Pre-Deployment Testing

- [ ] Test valid month slug: `/produkt-updates/november-2025`
- [ ] Test invalid month slug: `/produkt-updates/invalid-month` (should redirect)
- [ ] Test empty month slug: `/produkt-updates/` (should redirect)
- [ ] Test SQL injection attempt: `/produkt-updates/test'; DROP TABLE--`
- [ ] Test XSS attempt: `/produkt-updates/<script>alert(1)</script>test`
- [ ] Verify JSON-LD is valid
- [ ] Verify images load correctly
- [ ] Verify features display correctly
- [ ] Verify improvements display correctly
- [ ] Verify back link works
- [ ] Verify breadcrumbs are correct
- [ ] Test on mobile devices
- [ ] Test in different browsers

### Validation Tools

1. **JSON-LD Validator:**

   - Google Rich Results Test: https://search.google.com/test/rich-results
   - JSON-LD Playground: https://json-ld.org/playground/

2. **HTML Validator:**

   - W3C Markup Validator: https://validator.w3.org/

3. **PHP Syntax Check:**

   ```bash
   php -l v2/pages/produkt_updates_month.php
   ```

4. **Test Scripts:**
   - `v2/test/test-produkt-updates-month.php` - Unit tests
   - `v2/test/validate-month-page.php` - Page validation

## Debugging Steps

### Step 1: Enable Error Reporting

Add to top of `produkt_updates_month.php` (temporarily):

```php
error_reporting(E_ALL);
ini_set('display_errors', 1);
ini_set('log_errors', 1);
```

### Step 2: Check Server Logs

```bash
# Apache error log
tail -f /var/log/apache2/error.log

# PHP error log
tail -f /var/log/php/error.log

# Or check PHP-FPM logs
tail -f /var/log/php-fpm/error.log
```

### Step 3: Test Direct Access

```bash
# Test PHP execution directly
php -r "\$_GET['month'] = 'november-2025'; include 'v2/pages/produkt_updates_month.php';"
```

### Step 4: Verify File Permissions

```bash
# Check file permissions
ls -la v2/pages/produkt_updates_month.php
ls -la v2/data/produkt_updates.json
ls -la v2/base/head.php

# Should be readable by web server user
```

### Step 5: Test .htaccess Routing

```bash
# Test rewrite rule
curl -I http://localhost/produkt-updates/november-2025

# Check if rewrite is working
# Should return 200, not 404
```

## Code Fixes Applied

### 1. Array Safety Checks

- Added `is_array()` checks before `usort()`
- Initialize empty arrays if missing
- Use null coalescing operator (`??`) for optional fields

### 2. Input Sanitization

- Sanitize month slug: only allow `a-z0-9\-_`
- Convert to lowercase for consistency
- Remove dangerous characters

### 3. Schema Markup Fixes

- Fixed comma placement in JSON-LD
- Conditional property addition
- Proper escaping of special characters

### 4. Error Handling

- Graceful handling of missing data
- Redirects for invalid month slugs
- Safe array access with null coalescing

## Still Having Issues?

If problems persist:

1. **Check Apache Configuration:**

   - Verify `AllowOverride All` is set for the directory
   - Ensure `mod_rewrite` is enabled

2. **Check PHP Configuration:**

   - Verify `display_errors` is off in production
   - Check `error_log` is configured
   - Verify `include_path` includes current directory

3. **Check File Structure:**

   - Verify all files exist at expected paths
   - Check file permissions (644 for files, 755 for directories)
   - Ensure web server user can read files

4. **Contact Support:**
   - Provide error messages from logs
   - Include test results from validation scripts
   - Share relevant configuration details

## Related Documentation

- [Product Updates Automation Guide](product-updates-automation.md)
- [Admin Interface Guide](guides/PRODUCT_UPDATES_ADMIN.md) (if exists)
- [.htaccess Configuration](../development//setup/HTACCESS_ANALYSIS.md)
