Skip to content

Commit

Permalink
A few small fixes so sitemaps would be patched
Browse files Browse the repository at this point in the history
Fixes for feature #1050
  • Loading branch information
eSilverStrike committed Jan 31, 2022
1 parent 848a983 commit c84df60
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
15 changes: 9 additions & 6 deletions plugins/xmlsitemap/functions.inc
Original file line number Diff line number Diff line change
Expand Up @@ -418,9 +418,9 @@ function XMLSMAP_update($type = null, $include = null, $exclude = null)
function plugin_itemsaved_xmlsitemap($id, $type, $old_id, $sub_type)
{
global $_XMLSMAP_CONF;

// Make sure type is setup in the arrays and $id is set
if (empty($type) || empty($_XMLSMAP_CONF['types'][$type]) || empty($id)) {
// Make sure type is setup in the arrays and $id is set
if (empty($type) || !in_array($type, $_XMLSMAP_CONF['types']) || empty($id)) {
return;
}

Expand All @@ -429,10 +429,13 @@ function plugin_itemsaved_xmlsitemap($id, $type, $old_id, $sub_type)
require_once __DIR__ . '/xmlsitemap.class.php';

$sitemap = new XMLSitemap(COM_getCharset());
$sitemap_file = isset($_XMLSMAP_CONF['sitemap_file']) ? $_XMLSMAP_CONF['sitemap_file'] : '';
$mobile_sitemap_file = isset($_XMLSMAP_CONF['mobile_sitemap_file']) ? $_XMLSMAP_CONF['mobile_sitemap_file'] : '';
$news_sitemap_file = isset($_XMLSMAP_CONF['news_sitemap_file']) ? $_XMLSMAP_CONF['news_sitemap_file'] : '';
$sitemap->setFileNames(
@$_XMLSMAP_CONF['sitemap_file'],
@$_XMLSMAP_CONF['mobile_sitemap_file'],
@$_XMLSMAP_CONF['news_sitemap_file']
$sitemap_file,
$mobile_sitemap_file,
$news_sitemap_file
);
$newItem = PLG_getItemInfo($type, $id, 'url,date-modified', 1);

Expand Down
12 changes: 10 additions & 2 deletions plugins/xmlsitemap/xmlsitemap.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,7 @@ public function create()
// Title
$sitemap .= ' <news:title>' . $entry['title'] . '</news:title>' . self::LB;

$sitemap .= ' </news:news>';
$sitemap .= ' </news:news>' . self::LB;

$sitemap .= ' </url>' . self::LB;
$numEntries++;
Expand Down Expand Up @@ -920,7 +920,7 @@ public function endUpdate()
}

// Get file names
list ($filename, $mobileFilename,) = $this->getFileNames();
list ($filename, $mobileFilename, $newsFilename) = $this->getFileNames();

if (!empty($filename)) {
$retval = $retval && $this->patchFile($filename, $this->items);
Expand All @@ -937,6 +937,14 @@ public function endUpdate()
$this->sendPing($pingTargets, $mobileFilename);
}
}

if (!empty($newsFilename)) {
$retval = $retval && $this->patchFile($newsFilename, $this->items);

if ($retval) {
$this->sendPing($pingTargets, $newsFilename);
}
}

// Empty the queue
$this->items = [];
Expand Down

0 comments on commit c84df60

Please sign in to comment.