Skip to content
This repository has been archived by the owner on Aug 8, 2022. It is now read-only.

Commit

Permalink
Added expire date for sitemap (table definition, garbage collection)
Browse files Browse the repository at this point in the history
  • Loading branch information
Markus Blaschke committed Mar 4, 2015
1 parent 52019d4 commit 598e3f6
Show file tree
Hide file tree
Showing 2 changed files with 106 additions and 97 deletions.
23 changes: 15 additions & 8 deletions Classes/Utility/SitemapUtility.php
Expand Up @@ -56,8 +56,8 @@ public static function index($pageData) {
return;
}

// Trim url
$pageData['page_url'] = trim($pageData['page_url']);
// Trim url
$pageData['page_url'] = trim($pageData['page_url']);

// calc page hash
$pageData['page_hash'] = md5($pageData['page_url']);
Expand Down Expand Up @@ -88,7 +88,7 @@ public static function index($pageData) {

// $pageData is already quoted

// TODO: INSERT INTO ... ON DUPLICATE KEY UPDATE?
// TODO: INSERT INTO ... ON DUPLICATE KEY UPDATE?
$query = 'SELECT uid
FROM tx_metaseo_sitemap
Expand All @@ -106,7 +106,8 @@ public static function index($pageData) {
page_url = ' . $pageData['page_url'] . ',
page_depth = ' . $pageData['page_depth'] . ',
page_change_frequency = ' . $pageData['page_change_frequency'] . ',
page_type = ' . $pageData['page_type'] . '
page_type = ' . $pageData['page_type'] . ',
expire = ' . $pageData['expire'] . '
WHERE uid = ' . (int)$sitemapUid;
DatabaseUtility::exec($query);
} else {
Expand Down Expand Up @@ -136,14 +137,20 @@ public static function expire() {
$expireDays = 60;
}

// No negative days allowed
$expireDays = abs($expireDays);
// No negative days allowed
$expireDays = abs($expireDays);

// tstamp for too old indexed sitemap url
$tstamp = time() - $expireDays * 24 * 60 * 60;

// special expire time
$expire = time();

$query = 'DELETE FROM tx_metaseo_sitemap
WHERE tstamp <= ' . (int)$tstamp . '
AND is_blacklisted = 0';
WHERE is_blacklisted = 0
AND ( tstamp <= ' . (int)$tstamp . '
OR expire <= ' . (int)$expire . '
) ';
DatabaseUtility::exec($query);

// #####################
Expand Down
180 changes: 91 additions & 89 deletions ext_tables.sql
Expand Up @@ -2,124 +2,126 @@
# Table structure for table 'pages'
#
CREATE TABLE pages (
tx_metaseo_pagetitle varchar(255) DEFAULT '' NOT NULL,
tx_metaseo_pagetitle_rel varchar(255) DEFAULT '' NOT NULL,
tx_metaseo_pagetitle_prefix varchar(255) DEFAULT '' NOT NULL,
tx_metaseo_pagetitle_suffix varchar(255) DEFAULT '' NOT NULL,
tx_metaseo_is_exclude int(1) DEFAULT '0' NOT NULL,
tx_metaseo_inheritance int(11) DEFAULT '0' NOT NULL,
tx_metaseo_canonicalurl varchar(255) DEFAULT '' NOT NULL,
tx_metaseo_priority int(11) DEFAULT '0' NOT NULL,
tx_metaseo_change_frequency int(4) DEFAULT '0' NOT NULL,
tx_metaseo_geo_lat varchar(255) DEFAULT '' NOT NULL,
tx_metaseo_geo_long varchar(255) DEFAULT '' NOT NULL,
tx_metaseo_geo_place varchar(255) DEFAULT '' NOT NULL,
tx_metaseo_geo_region varchar(255) DEFAULT '' NOT NULL
tx_metaseo_pagetitle varchar(255) DEFAULT '' NOT NULL,
tx_metaseo_pagetitle_rel varchar(255) DEFAULT '' NOT NULL,
tx_metaseo_pagetitle_prefix varchar(255) DEFAULT '' NOT NULL,
tx_metaseo_pagetitle_suffix varchar(255) DEFAULT '' NOT NULL,
tx_metaseo_is_exclude int(1) DEFAULT '0' NOT NULL,
tx_metaseo_inheritance int(11) DEFAULT '0' NOT NULL,
tx_metaseo_canonicalurl varchar(255) DEFAULT '' NOT NULL,
tx_metaseo_priority int(11) DEFAULT '0' NOT NULL,
tx_metaseo_change_frequency int(4) DEFAULT '0' NOT NULL,
tx_metaseo_geo_lat varchar(255) DEFAULT '' NOT NULL,
tx_metaseo_geo_long varchar(255) DEFAULT '' NOT NULL,
tx_metaseo_geo_place varchar(255) DEFAULT '' NOT NULL,
tx_metaseo_geo_region varchar(255) DEFAULT '' NOT NULL
);

#
# Table structure for table 'pages_language_overlay'
#
CREATE TABLE pages_language_overlay (
tx_metaseo_pagetitle varchar(255) DEFAULT '' NOT NULL,
tx_metaseo_pagetitle_rel varchar(255) DEFAULT '' NOT NULL,
tx_metaseo_pagetitle_prefix varchar(255) DEFAULT '' NOT NULL,
tx_metaseo_pagetitle_suffix varchar(255) DEFAULT '' NOT NULL,
tx_metaseo_canonicalurl varchar(255) DEFAULT '' NOT NULL,
tx_metaseo_pagetitle varchar(255) DEFAULT '' NOT NULL,
tx_metaseo_pagetitle_rel varchar(255) DEFAULT '' NOT NULL,
tx_metaseo_pagetitle_prefix varchar(255) DEFAULT '' NOT NULL,
tx_metaseo_pagetitle_suffix varchar(255) DEFAULT '' NOT NULL,
tx_metaseo_canonicalurl varchar(255) DEFAULT '' NOT NULL
);

#
# Table structure for table 'tx_metaseo_cache'
#
CREATE TABLE tx_metaseo_cache (
uid int(11) NOT NULL auto_increment,
tstamp int(11) DEFAULT '0' NOT NULL,
page_uid int(11) DEFAULT '0' NOT NULL,
cache_section varchar(10) DEFAULT '' NOT NULL,
cache_identifier varchar(10) DEFAULT '' NOT NULL,
cache_content blob,
PRIMARY KEY (uid),
UNIQUE cache_key (page_uid,cache_section,cache_identifier),
KEY cache_sect_id (cache_section,cache_identifier)
uid int(11) NOT NULL auto_increment,
tstamp int(11) DEFAULT '0' NOT NULL,
page_uid int(11) DEFAULT '0' NOT NULL,
cache_section varchar(10) DEFAULT '' NOT NULL,
cache_identifier varchar(10) DEFAULT '' NOT NULL,
cache_content blob,
PRIMARY KEY (uid),
UNIQUE cache_key (page_uid,cache_section,cache_identifier),
KEY cache_sect_id (cache_section,cache_identifier)
) ENGINE=InnoDB;

#
# Table structure for table 'tx_metaseo_sitemap'
#
CREATE TABLE tx_metaseo_sitemap (
uid int(11) NOT NULL auto_increment,
tstamp int(11) DEFAULT '0' NOT NULL,
crdate int(11) DEFAULT '0' NOT NULL,
page_rootpid int(11) DEFAULT '0' NOT NULL,
page_uid int(11) DEFAULT '0' NOT NULL,
page_language int(11) DEFAULT '0' NOT NULL,
page_url varchar(500) DEFAULT '' NOT NULL,
page_hash varchar(32) DEFAULT '' NOT NULL,
page_depth int(4) DEFAULT '0' NOT NULL,
page_change_frequency int(4) DEFAULT '0' NOT NULL,
page_type int(11) DEFAULT '0' NOT NULL,

is_blacklisted int(1) DEFAULT '0' NOT NULL,

PRIMARY KEY (uid),

UNIQUE page_identification (page_uid,page_language,page_hash),
KEY language_path (page_rootpid,page_language,page_depth),
KEY page_depth (page_depth),
KEY blacklisted (is_blacklisted)
uid int(11) NOT NULL auto_increment,
tstamp int(11) DEFAULT '0' NOT NULL,
crdate int(11) DEFAULT '0' NOT NULL,
expire int(11) DEFAULT '0' NOT NULL,

page_rootpid int(11) DEFAULT '0' NOT NULL,
page_uid int(11) DEFAULT '0' NOT NULL,
page_language int(11) DEFAULT '0' NOT NULL,
page_url varchar(500) DEFAULT '' NOT NULL,
page_hash varchar(32) DEFAULT '' NOT NULL,
page_depth int(4) DEFAULT '0' NOT NULL,
page_change_frequency int(4) DEFAULT '0' NOT NULL,
page_type int(11) DEFAULT '0' NOT NULL,

is_blacklisted int(1) DEFAULT '0' NOT NULL,

PRIMARY KEY (uid),

UNIQUE page_identification (page_uid,page_language,page_hash),
KEY language_path (page_rootpid,page_language,page_depth),
KEY page_depth (page_depth),
KEY blacklisted (is_blacklisted)
) ENGINE=InnoDB;


#
# Table structure for table 'tx_metaseo_setting_root'
#
CREATE TABLE tx_metaseo_setting_root (
uid int(11) NOT NULL auto_increment,
pid int(11) DEFAULT '0' NOT NULL,
tstamp int(11) DEFAULT '0' NOT NULL,
crdate int(11) DEFAULT '0' NOT NULL,
cruser_id int(11) DEFAULT '0' NOT NULL,

is_sitemap int(1) DEFAULT '1' NOT NULL,
is_sitemap_page_indexer int(1) DEFAULT '1' NOT NULL,
is_sitemap_typolink_indexer int(1) DEFAULT '1' NOT NULL,
is_sitemap_language_lock int(1) DEFAULT '0' NOT NULL,
sitemap_page_limit int(11) DEFAULT '0' NOT NULL,
sitemap_priorty float DEFAULT '1' NOT NULL,
sitemap_priorty_depth_multiplier float DEFAULT '1' NOT NULL,
sitemap_priorty_depth_modificator float DEFAULT '1' NOT NULL,

is_robotstxt int(1) DEFAULT '1' NOT NULL,
is_robotstxt_sitemap_static int(1) DEFAULT '0' NOT NULL,
robotstxt text,
robotstxt_additional text,

deleted int(1) DEFAULT '0' NOT NULL,
PRIMARY KEY (uid),
KEY pid (pid),
KEY deleted (deleted)
uid int(11) NOT NULL auto_increment,
pid int(11) DEFAULT '0' NOT NULL,
tstamp int(11) DEFAULT '0' NOT NULL,
crdate int(11) DEFAULT '0' NOT NULL,
cruser_id int(11) DEFAULT '0' NOT NULL,

is_sitemap int(1) DEFAULT '1' NOT NULL,
is_sitemap_page_indexer int(1) DEFAULT '1' NOT NULL,
is_sitemap_typolink_indexer int(1) DEFAULT '1' NOT NULL,
is_sitemap_language_lock int(1) DEFAULT '0' NOT NULL,
sitemap_page_limit int(11) DEFAULT '0' NOT NULL,
sitemap_priorty float DEFAULT '1' NOT NULL,
sitemap_priorty_depth_multiplier float DEFAULT '1' NOT NULL,
sitemap_priorty_depth_modificator float DEFAULT '1' NOT NULL,

is_robotstxt int(1) DEFAULT '1' NOT NULL,
is_robotstxt_sitemap_static int(1) DEFAULT '0' NOT NULL,
robotstxt text,
robotstxt_additional text,

deleted int(1) DEFAULT '0' NOT NULL,
PRIMARY KEY (uid),
KEY pid (pid),
KEY deleted (deleted)
) ENGINE=InnoDB;

#
# Table structure for table 'tx_metaseo_tag'
#
CREATE TABLE tx_metaseo_metatag (
uid int(11) NOT NULL auto_increment,
pid int(11) DEFAULT '0' NOT NULL,
tstamp int(11) DEFAULT '0' NOT NULL,
crdate int(11) DEFAULT '0' NOT NULL,
cruser_id int(11) DEFAULT '0' NOT NULL,

sys_language_uid int(11) DEFAULT '0' NOT NULL,

tag_name varchar(50) DEFAULT '' NOT NULL,
tag_subname varchar(50) DEFAULT '' NOT NULL,
tag_value text,
tag_group int(11) DEFAULT '0' NOT NULL,

PRIMARY KEY (uid),
UNIQUE metatag (pid,sys_language_uid,tag_name,tag_group,tag_subname),
KEY tag_group (tag_group),
KEY sys_language_uid (sys_language_uid),
KEY pid (pid)
uid int(11) NOT NULL auto_increment,
pid int(11) DEFAULT '0' NOT NULL,
tstamp int(11) DEFAULT '0' NOT NULL,
crdate int(11) DEFAULT '0' NOT NULL,
cruser_id int(11) DEFAULT '0' NOT NULL,

sys_language_uid int(11) DEFAULT '0' NOT NULL,

tag_name varchar(50) DEFAULT '' NOT NULL,
tag_subname varchar(50) DEFAULT '' NOT NULL,
tag_value text,
tag_group int(11) DEFAULT '0' NOT NULL,

PRIMARY KEY (uid),
UNIQUE metatag (pid,sys_language_uid,tag_name,tag_group,tag_subname),
KEY tag_group (tag_group),
KEY sys_language_uid (sys_language_uid),
KEY pid (pid)
) ENGINE=InnoDB;

0 comments on commit 598e3f6

Please sign in to comment.