Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: sitemap command fails if pages table missing (resolves #1993) #1994

Merged
merged 1 commit into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .kube/app/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,7 @@ flock -n -E 0 /opt/data -c "php artisan deploy:global" # run exclusively on a si
## fix permissions after syncing to existing storage and cache https://github.com/accessibility-exchange/platform/issues/1236
chown -R www-data:root /app/bootstrap/cache $FILES_PATH # $CACHE_PATH removed per and added path to cache in the pod https://github.com/accessibility-exchange/platform/issues/1596

# Generate the robots.txt and sitemap.xml files
php artisan seo:generate

/usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.conf
1 change: 0 additions & 1 deletion app/Console/Commands/DeployLocal.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,5 @@ public function handle()
$this->call('icons:cache');
$this->call('event:cache');
$this->call('optimize');
$this->call('seo:generate');
}
}
4 changes: 3 additions & 1 deletion app/Console/Commands/GenerateSitemap.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Carbon\Carbon;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Route;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\Storage;

class GenerateSitemap extends Command
Expand Down Expand Up @@ -34,6 +35,7 @@ public function handle()
$routes = ['/' => ['en' => 'en', 'asl' => 'asl', 'fr' => 'fr', 'lsq' => 'lsq']];
// once deployed to the server, files have the same modified date, use README as a default last modified date
$lastmod = ['default' => Carbon::createFromTimestamp(filemtime('./README.md'))->toISOString()];
$hasPages = Schema::hasTable('pages'); // Check if the Pages table exists.
foreach (Route::getRoutes()->get('GET') as $route) {
if ($route->named(config('seo.sitemap.patterns'))) {
$routeURI = $route->uri();
Expand All @@ -42,7 +44,7 @@ public function handle()
$routes[$url][$locale] = $routeURI;
} else {
$routes[$url] = [$locale => $routeURI];
if ($route->named(config('seo.sitemap.pages'))) {
if ($route->named(config('seo.sitemap.pages')) && $hasPages) {
$routeName = explode('.', $route->getName());
/*
* TODO: come up with better query for the page, as slug may not follow the pattern in route name
Expand Down