From fd053115adb5b27305667cec2101beb9e1f17827 Mon Sep 17 00:00:00 2001 From: Thomas Portelange Date: Wed, 20 Mar 2024 12:21:45 +0100 Subject: [PATCH 1/9] ENH Add ability to ignore domains entirely --- src/Middleware/InitStateMiddleware.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Middleware/InitStateMiddleware.php b/src/Middleware/InitStateMiddleware.php index e30ac8c5..72d4a046 100644 --- a/src/Middleware/InitStateMiddleware.php +++ b/src/Middleware/InitStateMiddleware.php @@ -86,6 +86,11 @@ public function getIsFrontend(HTTPRequest $request) */ public function getIsDomainMode(HTTPRequest $request) { + // Check environment for a ignored override + if (Environment::getEnv('SS_FLUENT_IGNORE_DOMAIN')) { + return false; + } + // Don't act in domain mode if none exist if (!Domain::getCached()->exists()) { return false; From 6961bc7b0bd54ab1fa5d60f7e3586fbbb0184f21 Mon Sep 17 00:00:00 2001 From: Damian Mooyman Date: Mon, 25 Mar 2024 10:58:17 +1300 Subject: [PATCH 2/9] fix: don't invoke db for ready check outside of dev urls fixes #828 --- src/Model/CachableModel.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/Model/CachableModel.php b/src/Model/CachableModel.php index c90c61f1..d7baeb8d 100644 --- a/src/Model/CachableModel.php +++ b/src/Model/CachableModel.php @@ -2,6 +2,8 @@ namespace TractorCow\Fluent\Model; +use SilverStripe\Control\Director; +use SilverStripe\Control\HTTPRequest; use SilverStripe\Core\ClassInfo; use SilverStripe\Core\Config\Config; use SilverStripe\Core\Injector\Injector; @@ -68,6 +70,13 @@ public static function clearCached() */ protected static function databaseIsReady() { + // Outside of dev/ don't actually do any checks, assume ready + /** @var HTTPRequest $request */ + $request = Injector::inst()->get(HTTPRequest::class); + if (stripos($request->getURL(false), 'dev/') !== 0) { + return true; + } + $object = DataObject::singleton(static::class); // if any of the tables aren't created in the database From 11e92f4ca2a8d7e8012db31b7a6b9ff2c7a12689 Mon Sep 17 00:00:00 2001 From: Damian Mooyman Date: Mon, 25 Mar 2024 11:09:02 +1300 Subject: [PATCH 3/9] fix: check for request prior to access --- src/Model/CachableModel.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Model/CachableModel.php b/src/Model/CachableModel.php index d7baeb8d..2e295a86 100644 --- a/src/Model/CachableModel.php +++ b/src/Model/CachableModel.php @@ -71,10 +71,12 @@ public static function clearCached() protected static function databaseIsReady() { // Outside of dev/ don't actually do any checks, assume ready - /** @var HTTPRequest $request */ - $request = Injector::inst()->get(HTTPRequest::class); - if (stripos($request->getURL(false), 'dev/') !== 0) { - return true; + if (Injector::inst()->has(HTTPRequest::class)) { + /** @var HTTPRequest $request */ + $request = Injector::inst()->get(HTTPRequest::class); + if (stripos($request->getURL(false), 'dev/') !== 0) { + return true; + } } $object = DataObject::singleton(static::class); From 4628a66a5090720e6e8ad125f399f73fb3186e75 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 1 Apr 2024 20:41:30 +0000 Subject: [PATCH 4/9] DEP Update JS dependencies --- client/dist/js/fluent.js | 2 +- yarn.lock | 4791 +++++++++++++++++++++----------------- 2 files changed, 2624 insertions(+), 2169 deletions(-) diff --git a/client/dist/js/fluent.js b/client/dist/js/fluent.js index 605301fb..1f28eb8c 100644 --- a/client/dist/js/fluent.js +++ b/client/dist/js/fluent.js @@ -1 +1 @@ -!function(){"use strict";var e={872:function(e){e.exports=NodeUrl},685:function(e,t,r){r.r(t),r.d(t,{default:function(){return S}});var n={};r.r(n),r.d(n,{exclude:function(){return x},extract:function(){return w},parse:function(){return j},parseUrl:function(){return k},pick:function(){return O},stringify:function(){return v},stringifyUrl:function(){return F}});const o="%[a-f0-9]{2}",c=new RegExp("("+o+")|([^%]+?)","gi"),s=new RegExp("("+o+")+","gi");function i(e,t){try{return[decodeURIComponent(e.join(""))]}catch{}if(1===e.length)return e;t=t||1;const r=e.slice(0,t),n=e.slice(t);return Array.prototype.concat.call([],i(r),i(n))}function a(e){try{return decodeURIComponent(e)}catch{let t=e.match(c)||[];for(let r=1;r`%${e.charCodeAt(0).toString(16).toUpperCase()}`)):encodeURIComponent(e):e}function y(e,t){return t.decode?l(e):e}function g(e){return Array.isArray(e)?e.sort():"object"==typeof e?g(Object.keys(e)).sort(((e,t)=>Number(e)-Number(t))).map((t=>e[t])):e}function h(e){const t=e.indexOf("#");return-1!==t&&(e=e.slice(0,t)),e}function b(e,t){return t.parseNumbers&&!Number.isNaN(Number(e))&&"string"==typeof e&&""!==e.trim()?e=Number(e):!t.parseBooleans||null===e||"true"!==e.toLowerCase()&&"false"!==e.toLowerCase()||(e="true"===e.toLowerCase()),e}function w(e){const t=(e=h(e)).indexOf("?");return-1===t?"":e.slice(t+1)}function j(e,t){d((t={decode:!0,sort:!0,arrayFormat:"none",arrayFormatSeparator:",",parseNumbers:!1,parseBooleans:!1,...t}).arrayFormatSeparator);const r=function(e){let t;switch(e.arrayFormat){case"index":return(e,r,n)=>{t=/\[(\d*)]$/.exec(e),e=e.replace(/\[\d*]$/,""),t?(void 0===n[e]&&(n[e]={}),n[e][t[1]]=r):n[e]=r};case"bracket":return(e,r,n)=>{t=/(\[])$/.exec(e),e=e.replace(/\[]$/,""),t?void 0!==n[e]?n[e]=[...n[e],r]:n[e]=[r]:n[e]=r};case"colon-list-separator":return(e,r,n)=>{t=/(:list)$/.exec(e),e=e.replace(/:list$/,""),t?void 0!==n[e]?n[e]=[...n[e],r]:n[e]=[r]:n[e]=r};case"comma":case"separator":return(t,r,n)=>{const o="string"==typeof r&&r.includes(e.arrayFormatSeparator),c="string"==typeof r&&!o&&y(r,e).includes(e.arrayFormatSeparator);r=c?y(r,e):r;const s=o||c?r.split(e.arrayFormatSeparator).map((t=>y(t,e))):null===r?r:y(r,e);n[t]=s};case"bracket-separator":return(t,r,n)=>{const o=/(\[])$/.test(t);if(t=t.replace(/\[]$/,""),!o)return void(n[t]=r?y(r,e):r);const c=null===r?[]:r.split(e.arrayFormatSeparator).map((t=>y(t,e)));void 0!==n[t]?n[t]=[...n[t],...c]:n[t]=c};default:return(e,t,r)=>{void 0!==r[e]?r[e]=[...[r[e]].flat(),t]:r[e]=t}}}(t),n=Object.create(null);if("string"!=typeof e)return n;if(!(e=e.trim().replace(/^[?#&]/,"")))return n;for(const o of e.split("&")){if(""===o)continue;const e=t.decode?o.replace(/\+/g," "):o;let[c,s]=u(e,"=");void 0===c&&(c=e),s=void 0===s?null:["comma","separator","bracket-separator"].includes(t.arrayFormat)?s:y(s,t),r(y(c,t),s,n)}for(const[e,r]of Object.entries(n))if("object"==typeof r&&null!==r)for(const[e,n]of Object.entries(r))r[e]=b(n,t);else n[e]=b(r,t);return!1===t.sort?n:(!0===t.sort?Object.keys(n).sort():Object.keys(n).sort(t.sort)).reduce(((e,t)=>{const r=n[t];return Boolean(r)&&"object"==typeof r&&!Array.isArray(r)?e[t]=g(r):e[t]=r,e}),Object.create(null))}function v(e,t){if(!e)return"";d((t={encode:!0,strict:!0,arrayFormat:"none",arrayFormatSeparator:",",...t}).arrayFormatSeparator);const r=r=>t.skipNull&&null==e[r]||t.skipEmptyString&&""===e[r],n=function(e){switch(e.arrayFormat){case"index":return t=>(r,n)=>{const o=r.length;return void 0===n||e.skipNull&&null===n||e.skipEmptyString&&""===n?r:null===n?[...r,[m(t,e),"[",o,"]"].join("")]:[...r,[m(t,e),"[",m(o,e),"]=",m(n,e)].join("")]};case"bracket":return t=>(r,n)=>void 0===n||e.skipNull&&null===n||e.skipEmptyString&&""===n?r:null===n?[...r,[m(t,e),"[]"].join("")]:[...r,[m(t,e),"[]=",m(n,e)].join("")];case"colon-list-separator":return t=>(r,n)=>void 0===n||e.skipNull&&null===n||e.skipEmptyString&&""===n?r:null===n?[...r,[m(t,e),":list="].join("")]:[...r,[m(t,e),":list=",m(n,e)].join("")];case"comma":case"separator":case"bracket-separator":{const t="bracket-separator"===e.arrayFormat?"[]=":"=";return r=>(n,o)=>void 0===o||e.skipNull&&null===o||e.skipEmptyString&&""===o?n:(o=null===o?"":o,0===n.length?[[m(r,e),t,m(o,e)].join("")]:[[n,m(o,e)].join(e.arrayFormatSeparator)])}default:return t=>(r,n)=>void 0===n||e.skipNull&&null===n||e.skipEmptyString&&""===n?r:null===n?[...r,m(t,e)]:[...r,[m(t,e),"=",m(n,e)].join("")]}}(t),o={};for(const[t,n]of Object.entries(e))r(t)||(o[t]=n);const c=Object.keys(o);return!1!==t.sort&&c.sort(t.sort),c.map((r=>{const o=e[r];return void 0===o?"":null===o?m(r,t):Array.isArray(o)?0===o.length&&"bracket-separator"===t.arrayFormat?m(r,t)+"[]":o.reduce(n(r),[]).join("&"):m(r,t)+"="+m(o,t)})).filter((e=>e.length>0)).join("&")}function k(e,t){t={decode:!0,...t};let[r,n]=u(e,"#");return void 0===r&&(r=e),{url:r?.split("?")?.[0]??"",query:j(w(e),t),...t&&t.parseFragmentIdentifier&&n?{fragmentIdentifier:y(n,t)}:{}}}function F(e,t){t={encode:!0,strict:!0,[p]:!0,...t};const r=h(e.url).split("?")[0]||"";let n=v({...j(w(e.url),{sort:!1}),...e.query},t);n&&(n=`?${n}`);let o=function(e){let t="";const r=e.indexOf("#");return-1!==r&&(t=e.slice(r)),t}(e.url);if(e.fragmentIdentifier){const n=new URL(r);n.hash=e.fragmentIdentifier,o=t[p]?n.hash:`#${e.fragmentIdentifier}`}return`${r}${n}${o}`}function O(e,t,r){r={parseFragmentIdentifier:!0,[p]:!1,...r};const{url:n,query:o,fragmentIdentifier:c}=k(e,r);return F({url:n,query:f(o,t),fragmentIdentifier:c},r)}function x(e,t,r){return O(e,Array.isArray(t)?e=>!t.includes(e):(e,r)=>!t(e,r),r)}var S=n}},t={};function r(n){var o=t[n];if(void 0!==o)return o.exports;var c=t[n]={exports:{}};return e[n](c,c.exports,r),c.exports}r.d=function(e,t){for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},function(){var e=n(r(872)),t=n(r(685));function n(e){return e&&e.__esModule?e:{default:e}}window.jQuery.entwine("ss",(r=>{const n=()=>{if(window&&window.ss&&window.ss.config&&window.ss.config.sections){const e=window.ss.config.sections.find((e=>"TractorCow\\Fluent\\Control\\LocaleAdmin"===e.name));if(e)return e.fluent||{}}return{}};r("input[data-hides]").entwine({onmatch(){this._super();const e=this.data("hides"),t=r(`[name='${e}']`).closest(".field");this.is(":checked")?t.hide():t.show()},onunmatch(){this._super()},onchange(){const e=this.data("hides"),t=r(`[name='${e}']`).closest(".field");this.is(":checked")?t.slideUp():t.slideDown()}}),r(".cms > .cms-container > .cms-menu > .cms-panel-content").entwine({onmatch(){this._super();const e=n();if(void 0===e.locales||0===e.locales.length)return;const t=r("
\n \n
");e.locales.forEach((n=>{const o=r("