formmailer Posted September 14, 2017 Posted September 14, 2017 Hi! I am getting the following error when trying to create a link in the editor (html textfield). Error: Uncaught Error: Call to a member function className() on null in /home/site_com/public_dev/wire/modules/Process/ProcessPageEditLink/ProcessPageEditLink.module:374 Stack trace: #0 /home/site_com/public_dev/wire/modules/Process/ProcessPageEditLink/ProcessPageEditLink.module(350): ProcessWire\ProcessPageEditLink->getFilesPage(Object(ProcessWire\Page)) #1 /home/site_com/public_dev/wire/modules/Process/ProcessPageEditLink/ProcessPageEditLink.module(393): ProcessWire\ProcessPageEditLink->getFiles() #2 /home/site_com/public_dev/wire/modules/Process/ProcessPageEditLink/ProcessPageEditLink.module(215): ProcessWire\ProcessPageEditLink->getFilesField() #3 /home/site_com/public_dev/wire/core/Wire.php(380): ProcessWire\ProcessPageEditLink->___execute() #4 /home/site_com/public_dev/wire/core/WireHooks.php(698): ProcessWire\Wire->_callMethod('___execute', Array) #5 /home/site_com/public_dev/wire/core/Wire.php(442): ProcessWire\WireHooks->runHooks(Object(ProcessWire\ProcessPageEditLink), 'e (line 374 of /home/site_com/public_dev/wire/modules/Process/ProcessPageEditLink/ProcessPageEditLink.module) Any ideas what could be causing this? //Jasper
abdus Posted September 14, 2017 Posted September 14, 2017 When adding link ProcessPageEditLink module checks for file fields on the page and repeater items. And does a recursion when it encounters a repeater field. Reading the core, it looks like getting the type of a field fails (field->type == null) and causes the error. Which version of PW are you using? Do you have a repeater field on the page? Uninstalled a fieldtype? Removed a field from repeater field or the page's template? Tried repairing the DB? protected function getFilesPage(Page $page, $prefix = '') { $files = array(); foreach($page->template->fieldgroup as $field) { /** @var Fieldtype $type */ $type = $field->type; if($type instanceof FieldtypeFile) { $value = $page->get($field->name); if($value) foreach($page->get($field->name) as $file) { $files[$file->url] = $prefix . $field->getLabel() . ': ' . $file->basename; } } else if(wireInstanceOf($type, 'FieldtypeRepeater')) { $value = $page->get($field->name); if($value) { if($value instanceof Page) $value = array($value); if(WireArray::iterable($value)) { foreach($value as $repeaterPage) { $files = array_merge($this->getFilesPage($repeaterPage, $field->getLabel() . ': '), $files); } } } } } return $files; } 1
adrian Posted September 14, 2017 Posted September 14, 2017 It looks to me like you are running 3.0.62 (or thereabouts) as line 374 of that file looks like: } else if(strpos($type->className(), 'FieldtypeRepeater') !== false) { I would suggest upgrading to the latest dev and see if that fixes it. The new version uses this instead: } else if(wireInstanceOf($type, 'FieldtypeRepeater')) { Otherwise, we'll need to debug $field (type and name) to see what field is causing it to hang up. 2
formmailer Posted September 14, 2017 Author Posted September 14, 2017 The version is correct. I don't think that Repeater fields are an issue since I have never used them. Since I am redoing an existing site that has been running PW since 1.x and has been upgraded every time, it might be a good idea to start from scratch and manually transfer content (will be a QA-job for the content as well). The DB itself seems to be fine, but contains quite some history and fields that aren't used anymore. //Jasper
adrian Posted September 14, 2017 Posted September 14, 2017 1 minute ago, formmailer said: it might be a good idea to start from scratch and manually transfer content I really would try upgrading to latest dev first - that wireInstanceOf function adds a lot of extra logic that I assume will take care of things when $type is null. 4
formmailer Posted September 14, 2017 Author Posted September 14, 2017 I upgraded to the latest dev and the problem is gone, so you were absolutely right @adrian. Thanks! A side note: I still might go for a clean install to get rid of some old, now obsolete, modules and scrappy coding from my side. A new start makes it also easier to use new PW features. 1
adrian Posted September 14, 2017 Posted September 14, 2017 Just now, formmailer said: I upgraded to the latest dev and the problem is gone, so you were absolutely right @adrian. Thanks! No problem at all - glad it got things sorted for you!
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now