From c339bd5fd2c721bb8e75ba05edaf81377f7e17d1 Mon Sep 17 00:00:00 2001 From: Ryan Cramer Date: Tue, 28 Jul 2020 16:18:13 -0400 Subject: [PATCH] Fix issue processwire/processwire-issues#1115 --- wire/core/Pagefiles.php | 2 +- wire/core/PagefilesManager.php | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/wire/core/Pagefiles.php b/wire/core/Pagefiles.php index d3f3d67b..2683048e 100644 --- a/wire/core/Pagefiles.php +++ b/wire/core/Pagefiles.php @@ -946,7 +946,7 @@ class Pagefiles extends WireArray implements PageFieldValueInterface { $this->fieldsTemplate = false; /** @var FieldtypeFile $fieldtype */ $fieldtype = $field->type; - $template = $fieldtype ? $fieldtype->getFieldsTemplate($field) : null; + $template = $fieldtype && $fieldtype instanceof FieldtypeFile ? $fieldtype->getFieldsTemplate($field) : null; if($template) $this->fieldsTemplate = $template; } } diff --git a/wire/core/PagefilesManager.php b/wire/core/PagefilesManager.php index 8f188ba6..6056f262 100644 --- a/wire/core/PagefilesManager.php +++ b/wire/core/PagefilesManager.php @@ -619,8 +619,7 @@ class PagefilesManager extends Wire { if(!$key) continue; // first item, likely a filename, skip it break; // not first item means end of ID sequence } - $id = ltrim($part, '0'); // remove leading 0 and dash - $pageID = $id . $pageID; + $pageID = $part . $pageID; } return (int) $pageID;