From 5e888ce13dc2e3de4f6e98aee72ba6910d4a49fa Mon Sep 17 00:00:00 2001 From: Jellygnite Date: Sun, 3 Nov 2024 11:58:40 +1000 Subject: [PATCH] ss5 updates --- composer.json | 13 +++++++------ src/Analysis/FocusKeywordContentAnalysis.php | 4 ++-- src/Analysis/FocusKeywordUniqueAnalysis.php | 2 +- src/Analysis/FocusKeywordUrlAnalysis.php | 2 +- src/Analysis/MetaDescAnalysis.php | 2 +- src/Analysis/TitleAnalysis.php | 4 ++-- src/Analysis/WordCountAnalysis.php | 4 ++-- src/Seo.php | 2 +- 8 files changed, 17 insertions(+), 16 deletions(-) diff --git a/composer.json b/composer.json index 7c0ccf7..598fe15 100644 --- a/composer.json +++ b/composer.json @@ -5,11 +5,12 @@ "keywords": ["silverstripe", "seo", "facebook", "twitter", "opengraph", "search", "optimization", "optimisation"], "license": "BSD-3-Clause", "require": { - "silverstripe/cms": "^4.1", - "jonom/silverstripe-text-target-length": "^2", - "wilr/silverstripe-googlesitemaps": "^2.1", - "kub-at/php-simple-html-dom-parser": "^1.7", - "axllent/silverstripe-trailing-slash": "^2.1" + "silverstripe/framework": "^5.0", + "silverstripe/admin": "^2.0", + "jonom/silverstripe-text-target-length": "^2", + "wilr/silverstripe-googlesitemaps": "^3.1", + "kub-at/php-simple-html-dom-parser": "^1.9", + "axllent/silverstripe-trailing-slash": "^2.2" }, "autoload": { "psr-4": { @@ -21,7 +22,7 @@ "client/dist" ], "branch-alias": { - "dev-master": "4.0-dev" + "dev-master": "5.x-dev" } }, "minimum-stability": "dev", diff --git a/src/Analysis/FocusKeywordContentAnalysis.php b/src/Analysis/FocusKeywordContentAnalysis.php index 6cd9323..827da26 100644 --- a/src/Analysis/FocusKeywordContentAnalysis.php +++ b/src/Analysis/FocusKeywordContentAnalysis.php @@ -43,7 +43,7 @@ public function getContentFromDom() { $dom = $this->getPage()->getRenderedHtmlDomParser(); $result = $dom->find(PageSeoExtension::config()->get('content_holder'), 0); - return strtolower(strip_tags($result ? $result->innertext() : '')); + return strtolower(strip_tags($result ? $result->innertext() : '')?? ''); } /** @@ -51,7 +51,7 @@ public function getContentFromDom() */ public function getKeyword() { - return strtolower($this->getPage()->FocusKeyword); + return strtolower($this->getPage()->FocusKeyword ?? ''); } /** diff --git a/src/Analysis/FocusKeywordUniqueAnalysis.php b/src/Analysis/FocusKeywordUniqueAnalysis.php index f0d984e..b47eae8 100644 --- a/src/Analysis/FocusKeywordUniqueAnalysis.php +++ b/src/Analysis/FocusKeywordUniqueAnalysis.php @@ -17,7 +17,7 @@ class FocusKeywordUniqueAnalysis extends Analysis */ public function getKeyword() { - return strtolower($this->getPage()->FocusKeyword); + return strtolower($this->getPage()->FocusKeyword ?? ''); } /** diff --git a/src/Analysis/FocusKeywordUrlAnalysis.php b/src/Analysis/FocusKeywordUrlAnalysis.php index 3c5941a..a6688aa 100644 --- a/src/Analysis/FocusKeywordUrlAnalysis.php +++ b/src/Analysis/FocusKeywordUrlAnalysis.php @@ -24,7 +24,7 @@ class FocusKeywordUrlAnalysis extends Analysis */ public function getKeyword() { - return strtolower($this->getPage()->FocusKeyword); + return strtolower($this->getPage()->FocusKeyword ?? ''); } /** diff --git a/src/Analysis/MetaDescAnalysis.php b/src/Analysis/MetaDescAnalysis.php index 9c8df72..2bf726c 100644 --- a/src/Analysis/MetaDescAnalysis.php +++ b/src/Analysis/MetaDescAnalysis.php @@ -74,7 +74,7 @@ public function run() return static::META_DESC_TOO_LONG; } - if ($keyword && !strstr(strtolower($desc), strtolower($keyword))) { + if ($keyword && !strstr(strtolower($desc ?? ''), strtolower($keyword ?? ''))) { return static::META_DESC_NO_FOCUS_KEYWORD; } diff --git a/src/Analysis/TitleAnalysis.php b/src/Analysis/TitleAnalysis.php index 9cba141..25ada59 100644 --- a/src/Analysis/TitleAnalysis.php +++ b/src/Analysis/TitleAnalysis.php @@ -74,11 +74,11 @@ public function run() return static::TITLE_TOO_LONG; } - if ($keyword && !strstr(strtolower($title), strtolower($keyword))) { + if ($keyword && !strstr(strtolower($title ?? ''), strtolower($keyword ?? ''))) { return static::TITLE_NO_FOCUS_KEYWORD; } - if ($keyword && strtolower(substr($title, 0, strlen($keyword))) !== strtolower($keyword)) { + if ($keyword && strtolower(substr($title, 0, strlen($keyword)) ?? '') !== strtolower($keyword ?? '')) { return static::TITLE_FOCUS_KEYWORD_POSITION; } diff --git a/src/Analysis/WordCountAnalysis.php b/src/Analysis/WordCountAnalysis.php index 6ee011c..85c6ec4 100644 --- a/src/Analysis/WordCountAnalysis.php +++ b/src/Analysis/WordCountAnalysis.php @@ -20,7 +20,7 @@ class WordCountAnalysis extends Analysis */ public function getWordCount() { - $content = strtolower(strip_tags($this->getContentFromDom())); + $content = strtolower(strip_tags($this->getContentFromDom()) ?? ''); return str_word_count($content); //return count(array_filter(explode(' ', $content ))); } @@ -31,7 +31,7 @@ public function getContentFromDom() $result = $dom->find(PageSeoExtension::config()->get('content_holder'), 0); - return strtolower(strip_tags($result ? $result->innertext() : '')); + return strtolower(strip_tags($result ? $result->innertext() : '') ?? ''); } /** diff --git a/src/Seo.php b/src/Seo.php index 796eb3b..9611a4e 100644 --- a/src/Seo.php +++ b/src/Seo.php @@ -39,7 +39,7 @@ public static function collateContentFields($owner) $content = implode(' ', $content); - return strtolower(strip_tags($content)); + return strtolower(strip_tags($content)?? ''); } /**