Requests for Sitemaps that don't exist return 404 error messages #105

Open
wants to merge 23 commits into
from

Projects

None yet

2 participants

@mdbitz
Contributor
mdbitz commented Jan 9, 2017

Resolution of #79. Sitemap template is updated so that wp_die explicitly returns a 404 response code. In addition when building individual sitemap xml we explicitly return false when no data exists for the requested date. This ensures that 404 is returned instead of empty XML.

Matthew Denton and others added some commits Jan 3, 2017
Matthew Denton Updated Proccessing logic in Test Suite to directly call SiteMap gene…
…ration logic instead of iterating over cron jobs.

Logic from calling cron was taking between 40s and 125secs per test accounting for the majority of the execution time of the test suite. Investigation showed that the cron logic was creating cron jobs for every day of the year vs calling only the days with the generated posts. Bypassing cron for sake of unit tests reduced setup time to milliseconds.

Additionally updated timestamp format created when comparing generated xml format to resolve inconsistency.
Cleaned up unused logic in Tests
Ran code through phpcs to align with Coding Standards. Note there are some left over errors due to -1 variable and direct db sql usage. However these are required for proper testing.
2272223
Matthew Denton Updated Date manipulation in the Unit Tests to use date() function in…
…stead of subtracting directly from the current date. Resolves issue where test suite fails out on the 1-3 of the month
d20ee21
Matthew Denton removal of debug statement bdafdf6
Matthew Denton Removal of unused variable that was added during updates to the Test …
…Suite for bypassing cron events
090300e
Matthew Denton Modified Travis CI to reference PHP 5.4 instead of 5.2 as 5.2 is not …
…installed on the test environment
6d7c21c
Matthew Denton Additional Tests created for core MetroSitemap Functions.
get_recent_sitemap_url_count
get_posts_year_range
check_year_has_posts
get_date_stamp
date_range_has_posts
get_post_ids_for_date

To faciliate testing added 'create_dummy_post' method to MSM_Sitemap_Test class to allow easy creation of differnt post types and statuses for diverse testing. create_dummy_posts updated to use create_dummy_post.
5af81af
Matthew Denton Updated Unit Tests to verify that Custom Post Types are supported pro…
…perly by Metro_Sitemap

- validate CPTs are ignored by default
- validate that if CPT is added via filter they are supported
d12bd88
Matthew Denton PHPCS Code Standard Cleanup of Tests b25c9a4
Matthew Denton Cron Test Script to validate that events are properly schedule to han…
…dle Sitemap Generation
765abdb
Matthew Denton Execute Cron Test furst as subsequent generation of maps can cause is…
…sues with jobs existing in the schedule even after cleanup on teardown
57477cf
Matthew Denton Update Unit Test so that it checks that get_post_year_range returns a…
…n empty array
89d65d8
Matthew Denton Specify Title and explicit response code in wp_die 9b64f8b
Matthew Denton Move Header into the return statement so not set when WP_Die is called 77ef20a
@mdbitz mdbitz Return false from build_individual_sitemap_xml when no Sitemap exists
Previously when a sitemap was requested for a date with no sitemap data
an empty xml string was returned. This change will now return false so
that a 404 response is sent back instead of empty xml.
2237713
mdbitz and others added some commits Jan 9, 2017
@mdbitz mdbitz Rebase of Fork from Master msm-sitemap repo.
Several Issues have been resolved in the main repo. Pulling changes into
our fork allows verification of Unit Tests prior to merge.
bf4137a
@mdbitz mdbitz Unit Test updated to use date format
Pull Request #101 updated the date format to  requiring test update to remain in sync
3ce71f9
@mjangda mjangda Merge pull request #97 from mdbitz/master
Unit Test update to resolve run time and concerns with current logic
ffefe7b
@mjangda
Member
mjangda commented Jan 9, 2017

This probably needs to be rebased against master as well.

@mjangda

Minor change to remove unnecessary else clauses, but otherwise looks good!

msm-sitemap.php
@@ -673,8 +673,7 @@ public static function build_individual_sitemap_xml( $year, $month, $day ) {
return $sitemap_content;
} else {
@mjangda
mjangda Jan 9, 2017 Member

We can kill the else clause here.

templates/full-sitemaps.php
+ __( 'Sorry, no sitemap available here.', 'msm-sitemap' ),
+ __( 'Sitemap Not Available', 'msm-sitemap' ),
+ array ( 'response' => 404 )
+ );
} else {
@mjangda
mjangda Jan 9, 2017 Member

Let's kill the else clause here too.

@mdbitz
mdbitz Jan 11, 2017 Contributor

Thanks Mo. getting these updated to conform to standards.

Matthew Denton and others added some commits Jan 7, 2017
@mdbitz
Contributor
mdbitz commented Jan 11, 2017

Hi Mo: I've updated those else statements per your feedback and did a rebase. However after a rebase git has me re pull the branch from my fork, so I might be doing something wrong there.

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