From 919c4756315ed328885b33fd2e5aea3e291b5f38 Mon Sep 17 00:00:00 2001 From: Ryan Cramer Date: Fri, 23 Feb 2018 10:36:15 -0500 Subject: [PATCH] Various minor adjustments --- wire/core/Pagefile.php | 14 +++++++++++++- wire/modules/Fieldtype/FieldtypeImage.module | 1 + wire/modules/Fieldtype/FieldtypePage.module | 15 ++++++++++++--- .../SessionHandlerDB/SessionHandlerDB.module | 7 +++++-- 4 files changed, 31 insertions(+), 6 deletions(-) diff --git a/wire/core/Pagefile.php b/wire/core/Pagefile.php index 5c34efb5..e4b11d55 100644 --- a/wire/core/Pagefile.php +++ b/wire/core/Pagefile.php @@ -497,7 +497,7 @@ class Pagefile extends WireData { break; case 'URL': // nocache url - $value = $this->url() . '?nc=' . @filemtime($this->filename()); + $value = $this->noCacheURL(); break; case 'pagefiles': $value = $this->pagefiles; @@ -528,6 +528,18 @@ class Pagefile extends WireData { return $value; } + /** + * Hookable no-cache URL + * + * #pw-internal + * + * @return string + * + */ + protected function ___noCacheURL() { + return $this->url() . '?nc=' . @filemtime($this->filename()); + } + /** * Return the next sibling Pagefile in the parent Pagefiles, or NULL if at the end. * diff --git a/wire/modules/Fieldtype/FieldtypeImage.module b/wire/modules/Fieldtype/FieldtypeImage.module index 418561d6..c9c843e8 100644 --- a/wire/modules/Fieldtype/FieldtypeImage.module +++ b/wire/modules/Fieldtype/FieldtypeImage.module @@ -90,6 +90,7 @@ class FieldtypeImage extends FieldtypeFile { } $variations = array(); foreach($img->getVariations() as $variation) { + /** @var Pageimage $variation */ $variations[$variation->name] = $variation->httpUrl(); } $value[$k]['variations'] = $variations; diff --git a/wire/modules/Fieldtype/FieldtypePage.module b/wire/modules/Fieldtype/FieldtypePage.module index 9e749a76..05a8f193 100644 --- a/wire/modules/Fieldtype/FieldtypePage.module +++ b/wire/modules/Fieldtype/FieldtypePage.module @@ -599,9 +599,18 @@ class FieldtypePage extends FieldtypeMulti implements Module, ConfigurableModule if(InputfieldPage::isValidPage($value, $field, $forPage)) { $valid = true; } else { - $valid = false; - $reason = $forPage->get("_isValidPage"); - if($throwException) throw new WireException("Page $value is not valid for $field->name ($reason)"); + $n = 0; + while(wireInstanceOf($forPage, 'RepeaterPage') && ++$n < 10) { + /** @var RepeaterPage $forPage */ + $forPage = $forPage->getForPage(); + } + if($n && InputfieldPage::isValidPage($value, $field, $forPage)) { + $valid = true; + } else { + $valid = false; + $reason = $forPage->get("_isValidPage"); + if($throwException) throw new WireException("Page $value is not valid for $field->name ($reason)"); + } } return $valid; diff --git a/wire/modules/Session/SessionHandlerDB/SessionHandlerDB.module b/wire/modules/Session/SessionHandlerDB/SessionHandlerDB.module index ac499817..ad83c287 100644 --- a/wire/modules/Session/SessionHandlerDB/SessionHandlerDB.module +++ b/wire/modules/Session/SessionHandlerDB/SessionHandlerDB.module @@ -86,7 +86,7 @@ class SessionHandlerDB extends WireSessionHandler implements Module, Configurabl * Write the given $data for the given session ID * * @param string $id Session ID - * @param string Serialized data to write + * @param string $data Serialized data to write * @return bool * */ @@ -203,6 +203,9 @@ class SessionHandlerDB extends WireSessionHandler implements Module, Configurabl /** * Session configuration options + * + * @param array $data + * @return InputfieldWrapper * */ public function getModuleConfigInputfields(array $data) { @@ -254,6 +257,7 @@ class SessionHandlerDB extends WireSessionHandler implements Module, Configurabl * * @param string $key * @param mixed $value + * @return void * */ public function __set($key, $value) { @@ -365,7 +369,6 @@ class SessionHandlerDB extends WireSessionHandler implements Module, Configurabl $database = $this->wire('database'); $sql = "ALTER TABLE $table MODIFY data MEDIUMTEXT NOT NULL"; $query = $database->prepare($sql); - $success = false; $query->execute(); $this->message("Updated sessions database for larger data storage", Notice::log); }