From bc31a67e80d6960d155254c546d1e1db7eb5a477 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Daniele=20Vigan=C3=B2?=
<86785881+daniele-vigano@users.noreply.github.com>
Date: Tue, 29 Oct 2024 01:22:18 +0100
Subject: [PATCH 01/13] ### Updated Test Classes for Compatibility with PHPUnit
11.4
- **Updated annotations and assertion methods** to align with changes introduced in PHPUnit 11.4.
- **Modified `setUp()`** to adhere to new best practices.
- **Aligned `phpunit.xml` configuration** with version 11.4.
- **Verified all tests** to ensure correct functionality with the updated changes.
---
phpunit.xml.dist | 23 +++++-----
tests/AbstractSitemapTest.php | 13 +++---
tests/FunctionsTest.php | 10 ++---
tests/SitemapFactoryTest.php | 81 +++++++++++++++--------------------
tests/SitemapIndexTest.php | 4 +-
tests/SitemapTest.php | 6 +--
6 files changed, 62 insertions(+), 75 deletions(-)
diff --git a/phpunit.xml.dist b/phpunit.xml.dist
index 480a1c8..4fd63d1 100644
--- a/phpunit.xml.dist
+++ b/phpunit.xml.dist
@@ -1,18 +1,19 @@
-
+
tests
-
-
+
+
+
./vendor
-
-
-
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/tests/AbstractSitemapTest.php b/tests/AbstractSitemapTest.php
index 168c4f0..a87b0be 100644
--- a/tests/AbstractSitemapTest.php
+++ b/tests/AbstractSitemapTest.php
@@ -1,6 +1,7 @@
abstractMock = new MockAbstractSitemap();
}
@@ -41,7 +42,7 @@ public function testFormatDateWithUnixTimestamp()
public function testFormatDateWithInvalidDate()
{
- $this->setExpectedException('InvalidArgumentException');
+ $this->expectException(\InvalidArgumentException::class);
$this->callProtectedMethod('formatDate', ['foo']);
}
@@ -71,7 +72,7 @@ public function testMaxUrlCount()
$urlCount->setAccessible(true);
$urlCount->setValue($this->abstractMock, AbstractSitemap::MAX_URLS);
- $this->setExpectedException('Tackk\Cartographer\MaxUrlCountExceededException');
+ $this->expectException(MaxUrlCountExceededException::class);
$this->callProtectedMethod('addUrlToDocument', [['loc' => 'http://foo.com']]);
}
diff --git a/tests/FunctionsTest.php b/tests/FunctionsTest.php
index 5179fbf..6f3443d 100644
--- a/tests/FunctionsTest.php
+++ b/tests/FunctionsTest.php
@@ -1,9 +1,9 @@
setExpectedException('InvalidArgumentException',
- 'Invalid type: string, Expected type(s): array, object, ArrayAccess');
+ $this->expectException(InvalidArgumentException::class);
Cartographer\get_property('foo', 'foo');
}
@@ -45,8 +44,7 @@ public function testCheckTypePasses()
public function testCheckTypeFails()
{
- $this->setExpectedException('InvalidArgumentException',
- 'Invalid type: ArrayObject, Expected type(s): array');
+ $this->expectException(InvalidArgumentException::class);
Cartographer\checktype(new ArrayObject(), ['array']);
}
}
diff --git a/tests/SitemapFactoryTest.php b/tests/SitemapFactoryTest.php
index 0e06375..42e14a1 100644
--- a/tests/SitemapFactoryTest.php
+++ b/tests/SitemapFactoryTest.php
@@ -1,47 +1,38 @@
filesystem = new Filesystem($adapter);
- $this->factory = new Tackk\Cartographer\SitemapFactory($this->filesystem);
+ $this->factory = new CreativeFactoryRV\Cartographer\SitemapFactory($this->filesystem);
}
- public function testCanInstantiate()
- {
- $this->assertInstanceOf('Tackk\Cartographer\SitemapFactory', $this->factory);
+ public function testCanInstantiate() {
+ $this->assertInstanceOf(SitemapFactory::class, $this->factory);
}
- public function testGetFilesystem()
- {
- $this->assertInstanceOf('League\Flysystem\FilesystemInterface', $this->factory->getFilesystem());
+ public function testGetFilesystem() {
+ $this->assertInstanceOf(FilesystemOperator::class, $this->factory->getFilesystem());
}
- public function testSetBaseUrl()
- {
+ public function testSetBaseUrl() {
$this->factory->setBaseUrl('foo/');
- $this->assertAttributeEquals('foo', 'baseUrl', $this->factory);
+ $this->assertEquals('foo', $this->factory->getBaseUrl());
$this->factory->setBaseUrl('foo');
- $this->assertAttributeEquals('foo', 'baseUrl', $this->factory);
+ $this->assertEquals('foo', $this->factory->getBaseUrl());
}
- public function testGetBaseUrl()
- {
+ public function testGetBaseUrl() {
$class = new ReflectionClass($this->factory);
$baseUrl = $class->getProperty('baseUrl');
$baseUrl->setAccessible(true);
@@ -50,8 +41,7 @@ public function testGetBaseUrl()
$this->assertEquals('foo', $this->factory->getBaseUrl());
}
- public function testGetFileCreated()
- {
+ public function testGetFileCreated() {
$class = new ReflectionClass($this->factory);
$filesCreated = $class->getProperty('filesCreated');
$filesCreated->setAccessible(true);
@@ -60,14 +50,12 @@ public function testGetFileCreated()
$this->assertEquals(['foo.txt'], $this->factory->getFilesCreated());
}
- public function testCreateRequiresIterator()
- {
- $this->setExpectedException('PHPUnit_Framework_Error');
+ public function testCreateRequiresIterator() {
+ $this->expectException(ArgumentCountError::class);
$this->factory->createSitemap();
}
- public function testCanCreateSmallSitemap()
- {
+ public function testCanCreateSmallSitemap() {
$expected = <<
@@ -84,8 +72,8 @@ public function testCanCreateSmallSitemap()
XML;
$urls = [];
- for ($i = 1; $i <= 3; $i++) {
- $urls[] = ['url' => 'http://foo.com/'.$i];
+ for ( $i = 1; $i <= 3; $i++ ) {
+ $urls[] = ['url' => 'http://foo.com/' . $i];
}
$path = $this->factory->createSitemap(new ArrayIterator($urls));
@@ -94,24 +82,23 @@ public function testCanCreateSmallSitemap()
$this->assertEquals($expected, $actual);
}
- public function testLargeSitemapCreatesIndex()
- {
+ public function testLargeSitemapCreatesIndex() {
$urls = [];
- for ($i = 1; $i <= 50002; $i++) {
- $urls[] = ['url' => 'http://foo.com/'.$i];
+ for ( $i = 1; $i <= 50002; $i++ ) {
+ $urls[] = ['url' => 'http://foo.com/' . $i];
}
$path = $this->factory->createSitemap(new ArrayIterator($urls));
$this->assertTrue($this->filesystem->has($path));
- foreach ($this->factory->getFilesCreated() as $file) {
+ foreach ( $this->factory->getFilesCreated() as $file ) {
$this->assertTrue($this->filesystem->has($file));
$this->filesystem->delete($file);
}
}
- public function testUrlMustBePresent()
- {
- $this->setExpectedException('InvalidArgumentException', 'Url is missing or not accessible.');
+ public function testUrlMustBePresent() {
+ $this->expectException(InvalidArgumentException::class);
+ $this->expectExceptionMessage('Url is missing or not accessible.');
$this->factory->createSitemap(new ArrayIterator([[]]));
}
}
diff --git a/tests/SitemapIndexTest.php b/tests/SitemapIndexTest.php
index 62cc3e2..114b095 100644
--- a/tests/SitemapIndexTest.php
+++ b/tests/SitemapIndexTest.php
@@ -1,6 +1,6 @@
XML;
- $sitemapIndex = new Tackk\Cartographer\SitemapIndex();
+ $sitemapIndex = new CreativeFactoryRV\Cartographer\SitemapIndex();
$sitemapIndex->add('http://foo.com/sitemaps/sitemap.1.xml', '2012-01-02');
$sitemapIndex->add('http://foo.com/sitemaps/sitemap.2.xml', '2012-01-02');
$this->assertEquals($expected, $sitemapIndex->toString());
diff --git a/tests/SitemapTest.php b/tests/SitemapTest.php
index 7f64980..bde08b3 100644
--- a/tests/SitemapTest.php
+++ b/tests/SitemapTest.php
@@ -1,8 +1,8 @@
Date: Tue, 29 Oct 2024 01:29:31 +0100
Subject: [PATCH 02/13] Update Package for Compatibility with Flysystem 3.0
- Updated dependencies to use Flysystem 3.0, addressing the vulnerability associated with Flysystem 1.0
- Refactored code to adopt changes in the Flysystem 3.0 API, ensuring compatibility and adherence to current best practices.
---
src/AbstractSitemap.php | 82 ++++++++++++++--------------
src/ChangeFrequency.php | 2 +-
src/MaxUrlCountExceededException.php | 7 +++
src/Sitemap.php | 2 +-
src/SitemapFactory.php | 32 +++--------
src/SitemapIndex.php | 2 +-
src/functions.php | 2 +-
7 files changed, 58 insertions(+), 71 deletions(-)
create mode 100644 src/MaxUrlCountExceededException.php
diff --git a/src/AbstractSitemap.php b/src/AbstractSitemap.php
index e8964c2..c1d3cd4 100644
--- a/src/AbstractSitemap.php
+++ b/src/AbstractSitemap.php
@@ -1,6 +1,6 @@
document = new DOMDocument($this->xmlVersion, $this->xmlEncoding);
$this->rootNode = $this->document->createElementNS($this->xmlNamespaceUri, $this->getRootNodeName());
@@ -80,14 +73,12 @@ public function __construct()
/**
* Freeze the sitemap, and append the rootNode to the document.
*/
- public function freeze()
- {
+ public function freeze() {
$this->document->appendChild($this->rootNode);
$this->isFrozen = true;
}
- public function isFrozen()
- {
+ public function isFrozen() {
return $this->isFrozen;
}
@@ -95,8 +86,7 @@ public function isFrozen()
* Gets the number of Urls in the sitemap.
* @return int
*/
- public function getUrlCount()
- {
+ public function getUrlCount() {
return $this->urlCount;
}
@@ -104,8 +94,7 @@ public function getUrlCount()
* Checks if the sitemap contains the maximum URL count.
* @return bool
*/
- public function hasMaxUrlCount()
- {
+ public function hasMaxUrlCount() {
return $this->urlCount === static::MAX_URLS;
}
@@ -113,18 +102,16 @@ public function hasMaxUrlCount()
* Converts the Sitemap to an XML string.
* @return string
*/
- public function toString()
- {
- return (string) $this;
+ public function toString() {
+ return (string)$this;
}
/**
* Converts the Sitemap to an XML string.
* @return string
*/
- public function __toString()
- {
- if (!$this->isFrozen()) {
+ public function __toString() {
+ if ( !$this->isFrozen() ) {
$this->freeze();
}
@@ -133,20 +120,19 @@ public function __toString()
/**
* Adds a URL to the document with the given array of elements.
- * @param array $urlArray
+ * @param array $urlArray
* @return $this
* @throws MaxUrlCountExceededException
*/
- protected function addUrlToDocument(array $urlArray)
- {
- if ($this->hasMaxUrlCount()) {
+ protected function addUrlToDocument(array $urlArray) {
+ if ( $this->hasMaxUrlCount() ) {
throw new MaxUrlCountExceededException('Maximum number of URLs has been reached, cannot add more.');
}
$node = $this->document->createElement($this->getNodeName());
- foreach ($urlArray as $key => $value) {
- if (is_null($value)) {
+ foreach ( $urlArray as $key => $value ) {
+ if ( is_null($value) ) {
continue;
}
$node->appendChild(new DOMElement($key, $value));
@@ -159,35 +145,47 @@ protected function addUrlToDocument(array $urlArray)
/**
* Escapes a string so it can be inserted into the Sitemap
- * @param string $string The string to escape.
+ * @param string $string The string to escape.
* @return string
*/
- protected function escapeString($string)
- {
- $from = ['&', '\'', '"', '>', '<'];
- $to = ['&', ''', '"', '>', '<'];
+ protected function escapeString($string) {
+ $from = [
+ '&',
+ '\'',
+ '"',
+ '>',
+ '<'
+ ];
+ $to = [
+ '&',
+ ''',
+ '"',
+ '>',
+ '<'
+ ];
return str_replace($from, $to, $string);
}
/**
* Takes a date as a string (or int in the case of a unix timestamp).
- * @param string $dateString
+ * @param string $dateString
* @return string
* @throws InvalidArgumentException
*/
- protected function formatDate($dateString)
- {
+ protected function formatDate($dateString) {
try {
// We have to handle timestamps a little differently
- if (is_numeric($dateString) && (int) $dateString == $dateString) {
- $date = DateTime::createFromFormat('U', (int) $dateString, new DateTimeZone('UTC'));
- } else {
+ if ( is_numeric($dateString) && (int)$dateString == $dateString ) {
+ $date = DateTime::createFromFormat('U', (int)$dateString, new DateTimeZone('UTC'));
+ }
+ else {
$date = new DateTime($dateString, new DateTimeZone('UTC'));
}
return $date->format(DateTime::W3C);
- } catch (\Exception $e) {
+ }
+ catch (\Exception $e) {
throw new InvalidArgumentException("Malformed last modified date: {$dateString}", 0, $e);
}
}
diff --git a/src/ChangeFrequency.php b/src/ChangeFrequency.php
index c83a665..319b3f5 100644
--- a/src/ChangeFrequency.php
+++ b/src/ChangeFrequency.php
@@ -1,6 +1,6 @@
filesystem = $filesystem;
}
/**
* Gets the Filesystem.
- * @return FilesystemInterface
+ * @return FilesystemOperator
*/
public function getFilesystem()
{
@@ -184,7 +184,7 @@ protected function parseEntry($entry)
*/
protected function randomHash()
{
- return md5($this->randomBytes(32));
+ return md5(random_bytes(32));
}
/**
@@ -196,22 +196,4 @@ protected function fileUrl($file)
{
return $this->baseUrl.'/'.ltrim($file, '/');
}
-
- /**
- * Generates a string of random bytes (of given length).
- * @param integer $bytes The number of bytes to return.
- * @throws \RuntimeException
- * @return string
- * @codeCoverageIgnore
- */
- protected function randomBytes($bytes = 32)
- {
- if (extension_loaded('openssl')) {
- return openssl_random_pseudo_bytes($bytes);
- } elseif (extension_loaded('mcrypt')) {
- return mcrypt_create_iv($bytes, MCRYPT_DEV_URANDOM);
- }
-
- throw new RuntimeException('Extension "openssl" or "mcrypt" is required, but is not installed.');
- }
}
diff --git a/src/SitemapIndex.php b/src/SitemapIndex.php
index 6bf0061..d254ef5 100644
--- a/src/SitemapIndex.php
+++ b/src/SitemapIndex.php
@@ -1,6 +1,6 @@
Date: Tue, 29 Oct 2024 01:42:14 +0100
Subject: [PATCH 03/13] Update composer.json to Reflect Package Changes:
- Modified dependencies to align with the updates made for compatibility with Flysystem 3.0.
- Adjusted version constraints and added any necessary new packages to support the latest changes.
- Ensured metadata accuracy such as package descriptions and authors, to reflect the current state of the project.
---
composer.json | 19 +++++++++++++------
1 file changed, 13 insertions(+), 6 deletions(-)
diff --git a/composer.json b/composer.json
index 551fa04..00ae1bb 100644
--- a/composer.json
+++ b/composer.json
@@ -1,28 +1,35 @@
{
- "name": "tackk/cartographer",
+ "name": "creativefactoryrv/cartographer",
"description": "A PHP sitemap generation tool.",
+ "version": "1.0.0",
"keywords": ["sitemap", "generator"],
"license": "MIT",
"authors": [
{
"name": "Dan Horrigan",
"email": "dh@tackk.com"
+ },
+ {
+ "name": "Daniele ViganĂ²"
}
],
- "minimum-stability": "dev",
+ "minimum-stability": "stable",
"require-dev": {
- "phpunit/phpunit": "4.0.*"
+ "phpunit/phpunit": "11.4.*"
},
"require": {
- "php": ">=5.4",
- "league/flysystem": "1.0.*"
+ "php": "^8.0.2",
+ "league/flysystem": "3.*"
},
"autoload": {
"files": [
"src/functions.php"
],
"psr-4": {
- "Tackk\\Cartographer\\": "src/"
+ "CreativeFactoryRV\\Cartographer\\": "src/"
}
+ },
+ "extra": {
+ "note": "This fork includes modifications by Daniele ViganĂ² to address a vulnerability caused by using an outdated version of League\\Flysystem as of 28/10/2024, based on the original work by Dan Horrigan."
}
}
From 0ba5a81a428a17c7a43d3e51f8d2204d6889fdc2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Daniele=20Vigan=C3=B2?=
<86785881+daniele-vigano@users.noreply.github.com>
Date: Tue, 29 Oct 2024 10:17:54 +0100
Subject: [PATCH 04/13] Deleted configuration files no longer in use.
---
.scrutinizer.yml | 14 --------------
.travis.yml | 18 ------------------
2 files changed, 32 deletions(-)
delete mode 100644 .scrutinizer.yml
delete mode 100644 .travis.yml
diff --git a/.scrutinizer.yml b/.scrutinizer.yml
deleted file mode 100644
index e93aa2c..0000000
--- a/.scrutinizer.yml
+++ /dev/null
@@ -1,14 +0,0 @@
-before_commands:
- - "composer install --prefer-source"
-
-filter:
- excluded_paths: [vendor/*, tests/*]
- paths: [src/*]
-
-tools:
- php_code_coverage: true
- php_sim: true
- php_pdepend: true
- php_analyzer: true
- php_code_coverage: true
-
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index 23d335b..0000000
--- a/.travis.yml
+++ /dev/null
@@ -1,18 +0,0 @@
-language: php
-php:
- - 5.4
- - 5.5
- - 5.6
- - hhvm
-
-before_script:
- - composer self-update
- - composer install --prefer-source --no-interaction --dev
-
-script: phpunit
-
-matrix:
- allow_failures:
- - php: 5.6
- - php: hhvm
- fast_finish: true
From c37024ef0263a2426655a247600c74fd690a8374 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Daniele=20Vigan=C3=B2?=
<86785881+daniele-vigano@users.noreply.github.com>
Date: Tue, 29 Oct 2024 10:24:12 +0100
Subject: [PATCH 05/13] Namespace refactoring to organize exceptions with
subsequent updating of PHPUnit tests.
---
src/AbstractSitemap.php | 2 +-
src/{ => Exception}/MaxUrlCountExceededException.php | 2 +-
tests/AbstractSitemapTest.php | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
rename src/{ => Exception}/MaxUrlCountExceededException.php (58%)
diff --git a/src/AbstractSitemap.php b/src/AbstractSitemap.php
index c1d3cd4..d73fe98 100644
--- a/src/AbstractSitemap.php
+++ b/src/AbstractSitemap.php
@@ -2,12 +2,12 @@
namespace CreativeFactoryRV\Cartographer;
+use CreativeFactoryRV\Cartographer\Exception\MaxUrlCountExceededException;
use DateTime;
use DateTimeZone;
use DOMDocument;
use DOMElement;
use InvalidArgumentException;
-use RuntimeException;
abstract class AbstractSitemap {
const MAX_URLS = 50000;
diff --git a/src/MaxUrlCountExceededException.php b/src/Exception/MaxUrlCountExceededException.php
similarity index 58%
rename from src/MaxUrlCountExceededException.php
rename to src/Exception/MaxUrlCountExceededException.php
index df28526..3a7f353 100644
--- a/src/MaxUrlCountExceededException.php
+++ b/src/Exception/MaxUrlCountExceededException.php
@@ -1,6 +1,6 @@
Date: Tue, 29 Oct 2024 10:28:17 +0100
Subject: [PATCH 06/13] Updated `.gitignore`.
---
.gitignore | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/.gitignore b/.gitignore
index 5e8a691..cfa689f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,3 +4,12 @@
.DS_Store
composer.lock
+/test.php
+/docker-compose.yml
+/Dockerfile
+/test-2.php
+/sitemaps/
+/logs/
+/.config/
+/.phpunit.result.cache
+/sitemap.xml
From 83b3b4ad03a654fc46bddd4894d6da05c5bbb8de Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Daniele=20Vigan=C3=B2?=
<86785881+daniele-vigano@users.noreply.github.com>
Date: Tue, 29 Oct 2024 10:44:31 +0100
Subject: [PATCH 07/13] Updated the documentation (README) and `composer.json`
to reflect the changes made to the package.
---
README.md | 69 +++++++++++++++++++++++++++------------------------
composer.json | 5 ++--
2 files changed, 40 insertions(+), 34 deletions(-)
diff --git a/README.md b/README.md
index a87c8f6..a635b59 100644
--- a/README.md
+++ b/README.md
@@ -1,32 +1,20 @@
# Cartographer
-[](https://packagist.org/packages/tackk/cartographer)
-[](https://packagist.org/packages/tackk/cartographer)
-[](https://packagist.org/packages/tackk/cartographer)
-
-[](https://travis-ci.org/tackk/cartographer)
-[](https://scrutinizer-ci.com/g/tackk/cartographer/)
-[](https://scrutinizer-ci.com/g/tackk/cartographer/)
-
-A sitemap generation tool for PHP following the [Sitemap Protocol v0.9](http://www.sitemaps.org/protocol.html).
+A sitemap generation tool for PHP following the [Sitemap Protocol v0.9](http://www.sitemaps.org/protocol.html), based on the work of Dan Horrigan ([tackk/cartographer](https://github.com/tackk/cartographer)). This fork was created to address vulnerabilities arising from outdated dependencies.
Cartographer can handle Sitemaps of any size. When generating sitemaps with more than 50,000
-entries (the limit), the sitemap becomes a "map of maps" (i.e. nested sitemaps).
-
-* **GitHub Repo:** [http://github.com/tackk/cartographer/](http://github.com/tackk/cartographer/)
-* **Documentation:** [http://tackk.github.io/cartographer/](http://tackk.github.io/cartographer/)
+entries, the sitemap becomes a "map of maps" (i.e. nested sitemaps).
## Supported PHP/HHVM Versions
-* **PHP:** >= 5.4 (including 5.6 beta1)
-* **HHVM:** >= 3.0.0
+* **PHP:** >= 8.0.2
## Installation
### Composer CLI
```
-composer require tackk/cartographer:1.0.*
+composer require creativefactoryrv/cartographer:1.0.*
```
### composer.json
@@ -34,7 +22,7 @@ composer require tackk/cartographer:1.0.*
``` json
{
"require": {
- "tackk/cartographer": "1.0.*"
+ "creativefactoryrv/cartographer": "1.0.*"
}
}
```
@@ -45,8 +33,8 @@ If you have a sitemap that is under 50,000 items, you can just use the Sitemap c
Generator.
``` php
-use Tackk\Cartographer\Sitemap;
-use Tackk\Cartographer\ChangeFrequency;
+use CreativeFactoryRV\Cartographer\ChangeFrequency;
+use CreativeFactoryRV\Cartographer\Sitemap
$sitemap = new Tackk\Cartographer\Sitemap();
$sitemap->add('http://foo.com', '2005-01-02', ChangeFrequency::WEEKLY, 1.0);
@@ -83,7 +71,7 @@ echo $sitemap->toString();
If you want to build a Sitemap Index, separate from the Sitemap Generator, you can!
``` php
-$sitemapIndex = new Tackk\Cartographer\SitemapIndex();
+$sitemapIndex = new CreativeFactoryRV\Cartographer\SitemapIndex();
$sitemapIndex->add('http://foo.com/sitemaps/sitemap.1.xml', '2012-01-02');
$sitemapIndex->add('http://foo.com/sitemaps/sitemap.2.xml', '2012-01-02');
@@ -114,7 +102,7 @@ echo $sitemapIndex->toString();
## Sitemap Factory
The Sitemap Factory create Sitemaps and Sitemap Indexes and writes them to the Filesystem.
-Is is can be used to generate full Sitemaps with more than **50,000** URLs.
+It can be used to generate full Sitemaps with more than **50,000** URLs.
If more than one sitemap is generated, it will create a Sitemap Index automatically.
@@ -126,13 +114,14 @@ means you can write the sitemaps to Local Disk, S3, Dropbox, wherever you want.
``` php
setBaseUrl('http://foo.com/sitemaps/');
-// Returns the URL to the main Sitemap/Index file
-$mainSitemap = $sitemapFactory->createSitemap($urls);
+$entries = [
+ [
+ 'url' => 'http://example.com/page1',
+ 'lastmod' => '2023-04-01',
+ 'changefreq' => 'daily',
+ 'priority' => '1.0'
+ ],
+ [
+ 'url' => 'http://example.com/page2',
+ 'lastmod' => '2023-04-02',
+ 'changefreq' => 'weekly',
+ 'priority' => '0.8'
+ ],
+];
+
+$iterator = new ArrayIterator($entries);
+// Returns the URL to the main Sitemap/Index file
+$mainSitemap = $sitemapFactory->createSitemap($iterator);
```
### Return Value
@@ -186,7 +191,7 @@ $files = $sitemapFactory->getFilesCreated();
## Running Tests
-*This assumes you have ran `composer update`.*
+*This assumes you ran `composer update`.*
From the repository root, run:
diff --git a/composer.json b/composer.json
index 00ae1bb..c515e4d 100644
--- a/composer.json
+++ b/composer.json
@@ -1,7 +1,7 @@
{
"name": "creativefactoryrv/cartographer",
"description": "A PHP sitemap generation tool.",
- "version": "1.0.0",
+ "version": "1.0.1",
"keywords": ["sitemap", "generator"],
"license": "MIT",
"authors": [
@@ -19,7 +19,8 @@
},
"require": {
"php": "^8.0.2",
- "league/flysystem": "3.*"
+ "league/flysystem": "3.*",
+ "ext-dom": "*"
},
"autoload": {
"files": [
From 250ee258a4660f805b27b7eb3af3403479684dc5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Daniele=20Vigan=C3=B2?=
<86785881+daniele-vigano@users.noreply.github.com>
Date: Tue, 29 Oct 2024 10:57:43 +0100
Subject: [PATCH 08/13] Updated the documentation (README) and `composer.json`
to reflect the changes made to the package.
---
README.md | 4 +++-
composer.json | 2 +-
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/README.md b/README.md
index a635b59..af81524 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,8 @@
# Cartographer
-A sitemap generation tool for PHP following the [Sitemap Protocol v0.9](http://www.sitemaps.org/protocol.html), based on the work of Dan Horrigan ([tackk/cartographer](https://github.com/tackk/cartographer)). This fork was created to address vulnerabilities arising from outdated dependencies.
+A sitemap generation tool for PHP following the [Sitemap Protocol v0.9](http://www.sitemaps.org/protocol.html), based on the work of Dan Horrigan ([tackk/cartographer](https://github.com/tackk/cartographer)).
+
+This fork was originally created to address vulnerabilities arising from outdated dependencies and along the way became compatible with PHP 8, bringing the original features into the current context.
Cartographer can handle Sitemaps of any size. When generating sitemaps with more than 50,000
entries, the sitemap becomes a "map of maps" (i.e. nested sitemaps).
diff --git a/composer.json b/composer.json
index c515e4d..6fd239c 100644
--- a/composer.json
+++ b/composer.json
@@ -1,7 +1,7 @@
{
"name": "creativefactoryrv/cartographer",
"description": "A PHP sitemap generation tool.",
- "version": "1.0.1",
+ "version": "1.1.1",
"keywords": ["sitemap", "generator"],
"license": "MIT",
"authors": [
From db31ef1f7b7f74efba16f9a4721f484974e983da Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Daniele=20Vigan=C3=B2?=
<86785881+daniele-vigano@users.noreply.github.com>
Date: Tue, 29 Oct 2024 11:03:36 +0100
Subject: [PATCH 09/13] Updated the documentation (README) and `composer.json`
to reflect the changes made to the package.
---
composer.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/composer.json b/composer.json
index 6fd239c..54318c7 100644
--- a/composer.json
+++ b/composer.json
@@ -1,7 +1,7 @@
{
"name": "creativefactoryrv/cartographer",
"description": "A PHP sitemap generation tool.",
- "version": "1.1.1",
+ "version": "1.1.2",
"keywords": ["sitemap", "generator"],
"license": "MIT",
"authors": [
From 59edd8721388b83fd2c482363d5d62936255e864 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Daniele=20Vigan=C3=B2?=
<86785881+daniele-vigano@users.noreply.github.com>
Date: Tue, 29 Oct 2024 11:04:28 +0100
Subject: [PATCH 10/13] Fixed inconsistencies in the version number, updated as
necessary to reflect this change.
---
composer.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/composer.json b/composer.json
index 54318c7..2ca73f8 100644
--- a/composer.json
+++ b/composer.json
@@ -1,7 +1,7 @@
{
"name": "creativefactoryrv/cartographer",
"description": "A PHP sitemap generation tool.",
- "version": "1.1.2",
+ "version": "1.1.3",
"keywords": ["sitemap", "generator"],
"license": "MIT",
"authors": [
From bfbfb91d77b9c4f4d0362b8627d3c6dffa10973a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Daniele=20Vigan=C3=B2?=
<86785881+daniele-vigano@users.noreply.github.com>
Date: Tue, 29 Oct 2024 11:20:30 +0100
Subject: [PATCH 11/13] Fixed some minor errors in documentation.
---
README.md | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/README.md b/README.md
index af81524..f7f8ced 100644
--- a/README.md
+++ b/README.md
@@ -36,9 +36,9 @@ Generator.
``` php
use CreativeFactoryRV\Cartographer\ChangeFrequency;
-use CreativeFactoryRV\Cartographer\Sitemap
+use CreativeFactoryRV\Cartographer\Sitemap;
-$sitemap = new Tackk\Cartographer\Sitemap();
+$sitemap = new Sitemap();
$sitemap->add('http://foo.com', '2005-01-02', ChangeFrequency::WEEKLY, 1.0);
$sitemap->add('http://foo.com/about', '2005-01-01');
@@ -74,6 +74,7 @@ If you want to build a Sitemap Index, separate from the Sitemap Generator, you c
``` php
$sitemapIndex = new CreativeFactoryRV\Cartographer\SitemapIndex();
+
$sitemapIndex->add('http://foo.com/sitemaps/sitemap.1.xml', '2012-01-02');
$sitemapIndex->add('http://foo.com/sitemaps/sitemap.2.xml', '2012-01-02');
From ea4f786e1db5d12643d92a010c0b89f0b6b8e182 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Daniele=20Vigan=C3=B2?=
<86785881+daniele-vigano@users.noreply.github.com>
Date: Tue, 29 Oct 2024 11:21:11 +0100
Subject: [PATCH 12/13] Fixed some minor errors in documentation.
---
README.md | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/README.md b/README.md
index f7f8ced..fae832b 100644
--- a/README.md
+++ b/README.md
@@ -16,7 +16,7 @@ entries, the sitemap becomes a "map of maps" (i.e. nested sitemaps).
### Composer CLI
```
-composer require creativefactoryrv/cartographer:1.0.*
+composer require creativefactoryrv/cartographer:1.*
```
### composer.json
@@ -24,7 +24,7 @@ composer require creativefactoryrv/cartographer:1.0.*
``` json
{
"require": {
- "creativefactoryrv/cartographer": "1.0.*"
+ "creativefactoryrv/cartographer": "1.*"
}
}
```
From 1f4b2f2287771c8960df76c9a4097276188f804c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Daniele=20Vigan=C3=B2?=
<86785881+daniele-vigano@users.noreply.github.com>
Date: Tue, 29 Oct 2024 11:25:34 +0100
Subject: [PATCH 13/13] Improved the "description" property.
---
composer.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/composer.json b/composer.json
index 2ca73f8..444de96 100644
--- a/composer.json
+++ b/composer.json
@@ -1,6 +1,6 @@
{
"name": "creativefactoryrv/cartographer",
- "description": "A PHP sitemap generation tool.",
+ "description": "A powerful yet user-friendly PHP sitemap generator designed to create large, comprehensive sitemaps.",
"version": "1.1.3",
"keywords": ["sitemap", "generator"],
"license": "MIT",