{"action":"created","comment":{"url":"https://api.github.com/repos/Yoast/wordpress-seo/pulls/comments/54898085","id":54898085,"diff_hunk":"@@ -41,6 +47,190 @@ public function is_enabled() {\n \t}\n \n \t/**\n+\t * Get the cache key for a certain type and page\n+\t *\n+\t * Example key format for type \"post\", page 1: wpseo_sitemap_post_1:akfw3e_23azBa\n+\t *\n+\t * @param null|string $type The type to get the key for. Null or self::SITEMAP_INDEX_TYPE for index cache.\n+\t * @param int         $page The page of cache to get the key for.\n+\t *\n+\t * @return string The key where the cache is stored on.\n+\t */\n+\tpublic static function get_storage_key( $type = null, $page = 1 ) {\n+\n+\t\t// Using SITEMAP_INDEX_TYPE for sitemap index cache.\n+\t\t$type = is_null( $type ) ? self::SITEMAP_INDEX_TYPE : $type;\n+\n+\t\t$global_cache_validator = self::get_validator();\n+\t\t$type_cache_validator   = self::get_validator( $type );\n+\n+\t\t$prefix  = self::$storage_key_prefix;\n+\t\t$postfix = sprintf( '_%d:%s_%s', $page, $global_cache_validator, $type_cache_validator );\n+\n+\t\t$type = self::get_safe_type( $type, $prefix, $postfix );\n+\n+\t\t// Build key.\n+\t\t$full_key = $prefix . $type . $postfix;\n+\n+\t\treturn $full_key;\n+\t}\n+\n+\t/**\n+\t * If the type is over length make sure we compact it so we don't have any database problems\n+\t *\n+\t * When there are more 'extremely long' post types, changes are they have variations in either the start or ending.\n+\t * Because of this, we cut out the excess in the middle which should result in less chance of collision.\n+\t *\n+\t * @param string $type    The type of sitemap to be used.\n+\t * @param string $prefix  The part before the type in the cache key. Only the length is used.\n+\t * @param string $postfix The part after the type in the cache key. Only the length is used.\n+\t *\n+\t * @return string The type with a safe length to use\n+\t *\n+\t * @throws OutOfRangeException When there is less than 15 characters of space for a key that is originally longer.\n+\t */\n+\tpublic static function get_safe_type( $type, $prefix = '', $postfix = '' ) {\n+\t\t// Length of key should not be over 53.\n+\t\t$max_length = 53;\n+\t\t$max_length -= strlen( 'timeout_' );\n+\t\t$max_length -= strlen( $prefix );\n+\t\t$max_length -= strlen( $postfix );\n+\n+\t\tif ( strlen( $type ) > $max_length ) {\n+\n+\t\t\tif ( $max_length < 15 ) {\n+\t\t\t\t/**\n+\t\t\t\t * If this happens the most likely cause is a 'page' that is too big.\n+\t\t\t\t * \"Normally\" the max_length is 24 + strlen( page ), which is unlikely to go above 10 in the first place.\n+\t\t\t\t *\n+\t\t\t\t * So this would not happen unintentionally..\n+\t\t\t\t * Either by trying to cause a high server load, finding backdoors or misconfiguration.\n+\t\t\t\t */\n+\t\t\t\tthrow new OutOfRangeException(\n+\t\t\t\t\t__(\n+\t\t\t\t\t\t'Trying to build a safe sitemap cache key, but the postfix and prefix combination leaves too little room to do this. You are probably requesting a page that is way out of the expected range.',\n+\t\t\t\t\t\t'wordpress-seo'\n+\t\t\t\t\t)\n+\t\t\t\t);\n+\t\t\t}\n+\n+\t\t\t$half = ( $max_length / 2 );\n+\n+\t\t\t$first_part = substr( $type, 0, ( ceil( $half ) - 1 ) );\n+\t\t\t$last_part  = substr( $type, ( 1 - floor( $half ) ) );\n+\n+\t\t\t$type = $first_part . '..' . $last_part;\n+\t\t}\n+\n+\t\treturn $type;\n+\t}\n+\n+\t/**\n+\t * Get the cache validator for the specified type","path":"inc/sitemaps/class-sitemaps-cache.php","position":96,"original_position":96,"commit_id":"8d3a788baa0abd67161d6492204a08a9a458da7f","original_commit_id":"8d3a788baa0abd67161d6492204a08a9a458da7f","user":{"login":"atimmer","id":584693,"avatar_url":"https://avatars.githubusercontent.com/u/584693?v=3","gravatar_id":"","url":"https://api.github.com/users/atimmer","html_url":"https://github.com/atimmer","followers_url":"https://api.github.com/users/atimmer/followers","following_url":"https://api.github.com/users/atimmer/following{/other_user}","gists_url":"https://api.github.com/users/atimmer/gists{/gist_id}","starred_url":"https://api.github.com/users/atimmer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/atimmer/subscriptions","organizations_url":"https://api.github.com/users/atimmer/orgs","repos_url":"https://api.github.com/users/atimmer/repos","events_url":"https://api.github.com/users/atimmer/events{/privacy}","received_events_url":"https://api.github.com/users/atimmer/received_events","type":"User","site_admin":false},"body":"I miss the word `option` here.","created_at":"2016-03-03T15:45:38Z","updated_at":"2016-03-03T15:45:38Z","html_url":"https://github.com/Yoast/wordpress-seo/pull/4079#discussion_r54898085","pull_request_url":"https://api.github.com/repos/Yoast/wordpress-seo/pulls/4079","_links":{"self":{"href":"https://api.github.com/repos/Yoast/wordpress-seo/pulls/comments/54898085"},"html":{"href":"https://github.com/Yoast/wordpress-seo/pull/4079#discussion_r54898085"},"pull_request":{"href":"https://api.github.com/repos/Yoast/wordpress-seo/pulls/4079"}}},"pull_request":{"url":"https://api.github.com/repos/Yoast/wordpress-seo/pulls/4079","id":61557816,"html_url":"https://github.com/Yoast/wordpress-seo/pull/4079","diff_url":"https://github.com/Yoast/wordpress-seo/pull/4079.diff","patch_url":"https://github.com/Yoast/wordpress-seo/pull/4079.patch","issue_url":"https://api.github.com/repos/Yoast/wordpress-seo/issues/4079","number":4079,"state":"open","locked":false,"title":"Reapply sitemap validator changes from 3.1","user":{"login":"moorscode","id":2005352,"avatar_url":"https://avatars.githubusercontent.com/u/2005352?v=3","gravatar_id":"","url":"https://api.github.com/users/moorscode","html_url":"https://github.com/moorscode","followers_url":"https://api.github.com/users/moorscode/followers","following_url":"https://api.github.com/users/moorscode/following{/other_user}","gists_url":"https://api.github.com/users/moorscode/gists{/gist_id}","starred_url":"https://api.github.com/users/moorscode/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/moorscode/subscriptions","organizations_url":"https://api.github.com/users/moorscode/orgs","repos_url":"https://api.github.com/users/moorscode/repos","events_url":"https://api.github.com/users/moorscode/events{/privacy}","received_events_url":"https://api.github.com/users/moorscode/received_events","type":"User","site_admin":false},"body":"Because of the code in the big 'Rarst Sitemaps rewrite' PR, changes made in 3.1 invalidating sitemaps cache could not be merged easily.\r\n\r\nThis PR re-introduces the functionality from https://github.com/Yoast/wordpress-seo/pull/3577/ into trunk.","created_at":"2016-03-03T13:20:43Z","updated_at":"2016-03-03T15:45:39Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3b0f8c6f95861ceb48a0c739f8e696ffba20568e","assignee":{"login":"atimmer","id":584693,"avatar_url":"https://avatars.githubusercontent.com/u/584693?v=3","gravatar_id":"","url":"https://api.github.com/users/atimmer","html_url":"https://github.com/atimmer","followers_url":"https://api.github.com/users/atimmer/followers","following_url":"https://api.github.com/users/atimmer/following{/other_user}","gists_url":"https://api.github.com/users/atimmer/gists{/gist_id}","starred_url":"https://api.github.com/users/atimmer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/atimmer/subscriptions","organizations_url":"https://api.github.com/users/atimmer/orgs","repos_url":"https://api.github.com/users/atimmer/repos","events_url":"https://api.github.com/users/atimmer/events{/privacy}","received_events_url":"https://api.github.com/users/atimmer/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/Yoast/wordpress-seo/milestones/20","html_url":"https://github.com/Yoast/wordpress-seo/milestones/3.2","labels_url":"https://api.github.com/repos/Yoast/wordpress-seo/milestones/20/labels","id":1404115,"number":20,"title":"3.2","description":"Theme: Social","creator":{"login":"omarreiss","id":1488816,"avatar_url":"https://avatars.githubusercontent.com/u/1488816?v=3","gravatar_id":"","url":"https://api.github.com/users/omarreiss","html_url":"https://github.com/omarreiss","followers_url":"https://api.github.com/users/omarreiss/followers","following_url":"https://api.github.com/users/omarreiss/following{/other_user}","gists_url":"https://api.github.com/users/omarreiss/gists{/gist_id}","starred_url":"https://api.github.com/users/omarreiss/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/omarreiss/subscriptions","organizations_url":"https://api.github.com/users/omarreiss/orgs","repos_url":"https://api.github.com/users/omarreiss/repos","events_url":"https://api.github.com/users/omarreiss/events{/privacy}","received_events_url":"https://api.github.com/users/omarreiss/received_events","type":"User","site_admin":false},"open_issues":34,"closed_issues":28,"state":"open","created_at":"2015-11-10T10:15:34Z","updated_at":"2016-03-03T15:06:40Z","due_on":"2016-04-11T22:00:00Z","closed_at":null},"commits_url":"https://api.github.com/repos/Yoast/wordpress-seo/pulls/4079/commits","review_comments_url":"https://api.github.com/repos/Yoast/wordpress-seo/pulls/4079/comments","review_comment_url":"https://api.github.com/repos/Yoast/wordpress-seo/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Yoast/wordpress-seo/issues/4079/comments","statuses_url":"https://api.github.com/repos/Yoast/wordpress-seo/statuses/8d3a788baa0abd67161d6492204a08a9a458da7f","head":{"label":"Yoast:stories/JM/reapply_sitemap_validator_changes_from_31","ref":"stories/JM/reapply_sitemap_validator_changes_from_31","sha":"8d3a788baa0abd67161d6492204a08a9a458da7f","user":{"login":"Yoast","id":4690436,"avatar_url":"https://avatars.githubusercontent.com/u/4690436?v=3","gravatar_id":"","url":"https://api.github.com/users/Yoast","html_url":"https://github.com/Yoast","followers_url":"https://api.github.com/users/Yoast/followers","following_url":"https://api.github.com/users/Yoast/following{/other_user}","gists_url":"https://api.github.com/users/Yoast/gists{/gist_id}","starred_url":"https://api.github.com/users/Yoast/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Yoast/subscriptions","organizations_url":"https://api.github.com/users/Yoast/orgs","repos_url":"https://api.github.com/users/Yoast/repos","events_url":"https://api.github.com/users/Yoast/events{/privacy}","received_events_url":"https://api.github.com/users/Yoast/received_events","type":"Organization","site_admin":false},"repo":{"id":6723399,"name":"wordpress-seo","full_name":"Yoast/wordpress-seo","owner":{"login":"Yoast","id":4690436,"avatar_url":"https://avatars.githubusercontent.com/u/4690436?v=3","gravatar_id":"","url":"https://api.github.com/users/Yoast","html_url":"https://github.com/Yoast","followers_url":"https://api.github.com/users/Yoast/followers","following_url":"https://api.github.com/users/Yoast/following{/other_user}","gists_url":"https://api.github.com/users/Yoast/gists{/gist_id}","starred_url":"https://api.github.com/users/Yoast/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Yoast/subscriptions","organizations_url":"https://api.github.com/users/Yoast/orgs","repos_url":"https://api.github.com/users/Yoast/repos","events_url":"https://api.github.com/users/Yoast/events{/privacy}","received_events_url":"https://api.github.com/users/Yoast/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Yoast/wordpress-seo","description":"Yoast SEO for WordPress","fork":false,"url":"https://api.github.com/repos/Yoast/wordpress-seo","forks_url":"https://api.github.com/repos/Yoast/wordpress-seo/forks","keys_url":"https://api.github.com/repos/Yoast/wordpress-seo/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Yoast/wordpress-seo/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Yoast/wordpress-seo/teams","hooks_url":"https://api.github.com/repos/Yoast/wordpress-seo/hooks","issue_events_url":"https://api.github.com/repos/Yoast/wordpress-seo/issues/events{/number}","events_url":"https://api.github.com/repos/Yoast/wordpress-seo/events","assignees_url":"https://api.github.com/repos/Yoast/wordpress-seo/assignees{/user}","branches_url":"https://api.github.com/repos/Yoast/wordpress-seo/branches{/branch}","tags_url":"https://api.github.com/repos/Yoast/wordpress-seo/tags","blobs_url":"https://api.github.com/repos/Yoast/wordpress-seo/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Yoast/wordpress-seo/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Yoast/wordpress-seo/git/refs{/sha}","trees_url":"https://api.github.com/repos/Yoast/wordpress-seo/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Yoast/wordpress-seo/statuses/{sha}","languages_url":"https://api.github.com/repos/Yoast/wordpress-seo/languages","stargazers_url":"https://api.github.com/repos/Yoast/wordpress-seo/stargazers","contributors_url":"https://api.github.com/repos/Yoast/wordpress-seo/contributors","subscribers_url":"https://api.github.com/repos/Yoast/wordpress-seo/subscribers","subscription_url":"https://api.github.com/repos/Yoast/wordpress-seo/subscription","commits_url":"https://api.github.com/repos/Yoast/wordpress-seo/commits{/sha}","git_commits_url":"https://api.github.com/repos/Yoast/wordpress-seo/git/commits{/sha}","comments_url":"https://api.github.com/repos/Yoast/wordpress-seo/comments{/number}","issue_comment_url":"https://api.github.com/repos/Yoast/wordpress-seo/issues/comments{/number}","contents_url":"https://api.github.com/repos/Yoast/wordpress-seo/contents/{+path}","compare_url":"https://api.github.com/repos/Yoast/wordpress-seo/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Yoast/wordpress-seo/merges","archive_url":"https://api.github.com/repos/Yoast/wordpress-seo/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Yoast/wordpress-seo/downloads","issues_url":"https://api.github.com/repos/Yoast/wordpress-seo/issues{/number}","pulls_url":"https://api.github.com/repos/Yoast/wordpress-seo/pulls{/number}","milestones_url":"https://api.github.com/repos/Yoast/wordpress-seo/milestones{/number}","notifications_url":"https://api.github.com/repos/Yoast/wordpress-seo/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Yoast/wordpress-seo/labels{/name}","releases_url":"https://api.github.com/repos/Yoast/wordpress-seo/releases{/id}","deployments_url":"https://api.github.com/repos/Yoast/wordpress-seo/deployments","created_at":"2012-11-16T15:16:29Z","updated_at":"2016-03-02T16:02:11Z","pushed_at":"2016-03-03T15:30:56Z","git_url":"git://github.com/Yoast/wordpress-seo.git","ssh_url":"git@github.com:Yoast/wordpress-seo.git","clone_url":"https://github.com/Yoast/wordpress-seo.git","svn_url":"https://github.com/Yoast/wordpress-seo","homepage":"http://yoast.com/wordpress/seo/","size":25326,"stargazers_count":608,"watchers_count":608,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":362,"mirror_url":null,"open_issues_count":564,"forks":362,"open_issues":564,"watchers":608,"default_branch":"trunk"}},"base":{"label":"Yoast:trunk","ref":"trunk","sha":"fa1e55d4160ae3aa9bcf434e19f9d5d5df3da2ce","user":{"login":"Yoast","id":4690436,"avatar_url":"https://avatars.githubusercontent.com/u/4690436?v=3","gravatar_id":"","url":"https://api.github.com/users/Yoast","html_url":"https://github.com/Yoast","followers_url":"https://api.github.com/users/Yoast/followers","following_url":"https://api.github.com/users/Yoast/following{/other_user}","gists_url":"https://api.github.com/users/Yoast/gists{/gist_id}","starred_url":"https://api.github.com/users/Yoast/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Yoast/subscriptions","organizations_url":"https://api.github.com/users/Yoast/orgs","repos_url":"https://api.github.com/users/Yoast/repos","events_url":"https://api.github.com/users/Yoast/events{/privacy}","received_events_url":"https://api.github.com/users/Yoast/received_events","type":"Organization","site_admin":false},"repo":{"id":6723399,"name":"wordpress-seo","full_name":"Yoast/wordpress-seo","owner":{"login":"Yoast","id":4690436,"avatar_url":"https://avatars.githubusercontent.com/u/4690436?v=3","gravatar_id":"","url":"https://api.github.com/users/Yoast","html_url":"https://github.com/Yoast","followers_url":"https://api.github.com/users/Yoast/followers","following_url":"https://api.github.com/users/Yoast/following{/other_user}","gists_url":"https://api.github.com/users/Yoast/gists{/gist_id}","starred_url":"https://api.github.com/users/Yoast/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Yoast/subscriptions","organizations_url":"https://api.github.com/users/Yoast/orgs","repos_url":"https://api.github.com/users/Yoast/repos","events_url":"https://api.github.com/users/Yoast/events{/privacy}","received_events_url":"https://api.github.com/users/Yoast/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Yoast/wordpress-seo","description":"Yoast SEO for WordPress","fork":false,"url":"https://api.github.com/repos/Yoast/wordpress-seo","forks_url":"https://api.github.com/repos/Yoast/wordpress-seo/forks","keys_url":"https://api.github.com/repos/Yoast/wordpress-seo/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Yoast/wordpress-seo/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Yoast/wordpress-seo/teams","hooks_url":"https://api.github.com/repos/Yoast/wordpress-seo/hooks","issue_events_url":"https://api.github.com/repos/Yoast/wordpress-seo/issues/events{/number}","events_url":"https://api.github.com/repos/Yoast/wordpress-seo/events","assignees_url":"https://api.github.com/repos/Yoast/wordpress-seo/assignees{/user}","branches_url":"https://api.github.com/repos/Yoast/wordpress-seo/branches{/branch}","tags_url":"https://api.github.com/repos/Yoast/wordpress-seo/tags","blobs_url":"https://api.github.com/repos/Yoast/wordpress-seo/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Yoast/wordpress-seo/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Yoast/wordpress-seo/git/refs{/sha}","trees_url":"https://api.github.com/repos/Yoast/wordpress-seo/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Yoast/wordpress-seo/statuses/{sha}","languages_url":"https://api.github.com/repos/Yoast/wordpress-seo/languages","stargazers_url":"https://api.github.com/repos/Yoast/wordpress-seo/stargazers","contributors_url":"https://api.github.com/repos/Yoast/wordpress-seo/contributors","subscribers_url":"https://api.github.com/repos/Yoast/wordpress-seo/subscribers","subscription_url":"https://api.github.com/repos/Yoast/wordpress-seo/subscription","commits_url":"https://api.github.com/repos/Yoast/wordpress-seo/commits{/sha}","git_commits_url":"https://api.github.com/repos/Yoast/wordpress-seo/git/commits{/sha}","comments_url":"https://api.github.com/repos/Yoast/wordpress-seo/comments{/number}","issue_comment_url":"https://api.github.com/repos/Yoast/wordpress-seo/issues/comments{/number}","contents_url":"https://api.github.com/repos/Yoast/wordpress-seo/contents/{+path}","compare_url":"https://api.github.com/repos/Yoast/wordpress-seo/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Yoast/wordpress-seo/merges","archive_url":"https://api.github.com/repos/Yoast/wordpress-seo/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Yoast/wordpress-seo/downloads","issues_url":"https://api.github.com/repos/Yoast/wordpress-seo/issues{/number}","pulls_url":"https://api.github.com/repos/Yoast/wordpress-seo/pulls{/number}","milestones_url":"https://api.github.com/repos/Yoast/wordpress-seo/milestones{/number}","notifications_url":"https://api.github.com/repos/Yoast/wordpress-seo/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Yoast/wordpress-seo/labels{/name}","releases_url":"https://api.github.com/repos/Yoast/wordpress-seo/releases{/id}","deployments_url":"https://api.github.com/repos/Yoast/wordpress-seo/deployments","created_at":"2012-11-16T15:16:29Z","updated_at":"2016-03-02T16:02:11Z","pushed_at":"2016-03-03T15:30:56Z","git_url":"git://github.com/Yoast/wordpress-seo.git","ssh_url":"git@github.com:Yoast/wordpress-seo.git","clone_url":"https://github.com/Yoast/wordpress-seo.git","svn_url":"https://github.com/Yoast/wordpress-seo","homepage":"http://yoast.com/wordpress/seo/","size":25326,"stargazers_count":608,"watchers_count":608,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":362,"mirror_url":null,"open_issues_count":564,"forks":362,"open_issues":564,"watchers":608,"default_branch":"trunk"}},"_links":{"self":{"href":"https://api.github.com/repos/Yoast/wordpress-seo/pulls/4079"},"html":{"href":"https://github.com/Yoast/wordpress-seo/pull/4079"},"issue":{"href":"https://api.github.com/repos/Yoast/wordpress-seo/issues/4079"},"comments":{"href":"https://api.github.com/repos/Yoast/wordpress-seo/issues/4079/comments"},"review_comments":{"href":"https://api.github.com/repos/Yoast/wordpress-seo/pulls/4079/comments"},"review_comment":{"href":"https://api.github.com/repos/Yoast/wordpress-seo/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Yoast/wordpress-seo/pulls/4079/commits"},"statuses":{"href":"https://api.github.com/repos/Yoast/wordpress-seo/statuses/8d3a788baa0abd67161d6492204a08a9a458da7f"}}}}