Publisher is EE6 compatible, but it does not support the Fluid field. Please do not contact asking when support will be available.

If you purchased an add-on from expressionengine.com, be sure to visit boldminded.com/claim to add the license to your account here on boldminded.com.

Ticket: TypeError Caught when trying to edit entry after adding advanced categories fieldtype

Status Resolved
Add-on / Version Advanced Categories 1.0.0
Severity
EE Version 6.3.4

adamrifat

Jun 15, 2022

When editing an existing entry after adding the advanced categories fieldtype I get the following error. This doesn’t happen when creating a new entry.

Argument 1 passed to Advanced_categories_ft::getInvalidCategories() must be of the type array, null given, called in user/addons/advanced_categories/ft.advanced_categories.php on line 102

See screenshot attachment for the full detail.

Thanks.

 

 

 

 

#1

BoldMinded (Brian)

Jun 15, 2022

Thanks, I’ll try to take a look at this soon.

#2

BoldMinded (Brian)

Jun 15, 2022

On line 101 of the ft.advanced_categories.php file is this line

$categoryOptions = array_filter($this->settings['category_options']);

Try changing it to this

$categoryOptions = array_filter($this->settings['category_options'] ?? []);
#3

BoldMinded (Brian)

Jun 15, 2022

It also seems like this fieldtype was added to a channel but no settings were defined on the fieldtype?

#4

BoldMinded (Brian)

Jun 15, 2022

Please respond in the ticket, not directly via the email.

What you sent was the add-on settings, not the field itself. When you create the field to add it to a channel it has options where you select which categories you want to show up when editing the entry.

#5

adamrifat

Jun 15, 2022

Yes I did setup the field and selected some categories.

#6

adamrifat

Jun 15, 2022

I just added another image to show the field settings.

#7

adamrifat

Jun 15, 2022

Your code snippet corrects the fatal error but the options still don’t show up on the edit screen as shown in the image I just uploaded 😉

#8

BoldMinded (Brian)

Jun 15, 2022

#9

adamrifat

Jun 16, 2022

Yes, there are two category groups assigned to the channel.

When I dump $this->settings in ft.advances_categories.php it shows an empty array so for some reason it’s not picking up the settings. The fieldtype is saving the settings so it’s a bit strange…

#10

adamrifat

Jun 16, 2022

It almost works with a new entry but after saving when I try and change the category it shows ‘Errors found’ so I can’t change the category or re-save the entry. Inspection of the console shows an ajax request which seems to update the category before I save the entry?

For an existing entry ‘settings’ is empty on the fieldtype object as is the content_id. So $this->content_id() returns empty. Consequently, getChannel returns a channel which doesn’t have any category groups assigned (and is actually from a different MSM site).

Why isn’t the content_id/settings populated for existing entries I wonder?

 

#11

BoldMinded (Brian)

Jun 16, 2022

So this is happening in an MSM site? Have you tried it in a single site install?

#12

adamrifat

Jun 16, 2022

No I haven’t.

Doesn’t it support MSM?

#13

BoldMinded (Brian)

Jun 16, 2022

It should, but it’s something I’d like to rule out.

#14

adamrifat

Jun 16, 2022

All the sites I have are MSM sites…presumabley it’s been tested on a MSM setup?

#15

BoldMinded (Brian)

Jun 16, 2022

It has not been tested in an MSM setup, but it’s also using EE’s models, so the queries should already be contextual to the site. I just asked that because you mentioned MSM.  MSM might not be related to the issue at all. I’m trying to narrow things down.

#16

adamrifat

Jun 16, 2022

Great, so now I’ll need to install a fresh copy of EE, the fieldtype and setup a channel and entries…although surely you know that works?

 

#17

BoldMinded (Brian)

Jun 16, 2022

When I can’t replicate something locally, as described by the customer, the first step is to ask the customer to replicate it in a new, fresh EE environment. This is mentioned on the page before you submit a ticket, and if you search through the support forum you’ll see similar requests.

#18

adamrifat

Jun 16, 2022

When you can’t replicate something? When it hasn’t been tested properly you mean?

I appreciate it’s sold ‘as is’ but I didn’t realise I’d be enroled onto the BoldMinded UAT testing team and pay for the privilige.

So just to clarify I need to do a clean install, set up multiple sites and see if I can replicate the issue with no other addons installed, right?

#19

BoldMinded (Brian)

Jun 16, 2022

I’m not interested in getting into an argument. I removed the “beta” label from this add-on literally yesterday, after you purchased it. Perhaps that label was removed too soon. You can either wait until I can find time to do further testing, or you can setup the clean EE environment to try to replicate the issue.

#20

adamrifat

Jun 16, 2022

I’ve just installed clean, fresh install of EE along with the default data and theme that comes with it. Assigned the AC fieldtype and went to amend an existing entry and I got exactly the same error message.

This is running locally but I’ve attached a screenshot.

 

 

#21

adamrifat

Jun 16, 2022

Just to clarify is a single site after install and NOT a MSM

#22

BoldMinded (Brian)

Jun 16, 2022

Comment has been marked private.

#23

adamrifat

Jun 16, 2022

Tried it and it prevents the fatal error and gives a nicer message but I still can’t choose categories from the fieldtype

I’ve double checked and the category groups are assigned to the channel.

As per the above it seems as though

$this->settings

is empty.

#24

BoldMinded (Brian)

Jun 16, 2022

Comment has been marked private.

#25

BoldMinded (Brian)

Jun 16, 2022

Actually I take part of that back. this->content_id() does behave very differently, and very oddly. Next posted build should fix it.

#26

BoldMinded (Brian)

Jun 16, 2022

Comment has been marked private.

#27

BoldMinded (Brian)

Jun 16, 2022

Comment has been marked private.

#28

adamrifat

Jun 16, 2022

Did you see my comment here - https://boldminded.com/support/ticket/2430#comment20  and the attached image? This is with a fresh install and no additional sites added just the one that comes with the installation so I don’t think it’s MSM related as I can recreate the issue with a vanilla install of EE.

I tested the patched version but still the same for me.

#29

adamrifat

Jun 16, 2022

Also, the issue I’m having is for *existing* entries not new entries.

#30

BoldMinded (Brian)

Jun 16, 2022

Please edit the ticket and provide CP and FTP login so I can take a look.

#31

BoldMinded (Brian)

Jun 17, 2022

Comment has been marked private.

#32

adamrifat

Jun 17, 2022

Nope! $this->content_id is null on line 615 of ft.advanced_categories

Again it sort of works for a new entry but the validation on the field is buggy.

I’ll try and get it on a url where you can see what’s happening but honestly this is with a fresh install of EE with the data that comes with it.

#33

BoldMinded (Brian)

Jun 19, 2022

I’m going to need more information about the validation than “it’s buggy” - what is it doing incorrectly and what do you expect it to be doing? And what are your validation settings?

#34

adamrifat

Jun 20, 2022

I’ve set up a live site and added the details to the ticket.

This is a vanilla install of the latest EE downloaded from expressionengine.com along with v1.0.0 of AC. I’ve assigned one AC field named ‘AC Test’ to the Blog channel which has the Blog category group assigned.

As you can see when you go to edit an existing blog entry you get a fatal type error. I know you’ve supplied a patch for this but I thought let’s go back to square one so you can work through it step by step.

It it possible to create a new Blog entry but once the entry is saved there are validation warnings on the AC field and you can’t then resave it. You can see the field setting under the AC Test field I’ve created. I just want to ensure that one category from each category group is saved for each entry.

Also, it seems that for an existing entry when you can the AC field it saves the category via an AJAX call to https://boldminded.hastings.digital/admin.php?/cp/publish/edit/entry/13= which seems odd. Currently as the field cannot be saved this appears to remove all category selections.
Thanks.

#35

BoldMinded (Brian)

7 days ago

The FTP provided doesn’t appear to be working.

#36

adamrifat

7 days ago

I checked and it worked for me yesterday…it’s SFTP if that helps…

#37

BoldMinded (Brian)

7 days ago

I’d rather this test site have the latest patch I’ve provided instead of the original version.

#38

BoldMinded (Brian)

7 days ago

Comment has been marked private.

#39

adamrifat

7 days ago

Just posted two new images to the ticket. The FTP does work for me, sorry. The password is the same as the CMS admin login.

 

#40

BoldMinded (Brian)

7 days ago

FTP still doesn’t work. Are you sure access is not limited to an IP block? I’m using Transmit, which always works when the credentials are correct and access isn’t restricted somehow.

#41

adamrifat

7 days ago

I don’t know whether it’s IP blocked. You’re in the states, I think, my hosting is in the UK so that could well be the issue. I’m not going to open a ticket and see if they can whitelist your IP address.

Brian, I’m a bit exasperated by your approach here. Clearly, you can see the issues by logging into the control panel. The builds you’ve provided up to now don’t resolve the issue.

For the third time, this is just a vanilla install of EE and your add-on. Rather than wasting anymore of my time or yours can please just set this up locally and debug the issues?  Why do you need to FTP onto it when all the code is at hand?

It’s not really fair to keep asking me to do all this for you when the add-on is clearly broken.

I’m not looking for an argument but this is just wasting my time and yours.

 

 

 

 

#42

BoldMinded (Brian)

7 days ago

I have been setting this up and testing locally, and from what I can tell the latest build I sent you works fine, but it sounds like the site you provided me access to does not include that latest build. I’m not concerned with past errors, I want to see what your site is doing with the same build I’m using locally.

#43

BoldMinded (Brian)

7 days ago

If I’m unable to see the same error locally that you’re seeing, even with the same build, then it means something is happening on your site that is not happening on mine, so I need to be able to get into the code to find out why that is the case. There is only so much speculation I can do from my side.

#44

BoldMinded (Brian)

7 days ago

Is your FTP using a different port than 21 or 22?

#45

adamrifat

7 days ago

Maybe this will help - https://www.ionos.com/help/hosting/setting-up-and-managing-ftp-access/connection-data-for-secure-ftp/

I’ve just uploaded the build you sent through on Friday evening to the test site and it seems to be working much better now. Thank you.

I’ll go ahead and test this locally on my development site and let you know if I’m still seeing the issue.

#46

adamrifat

7 days ago

Sorry, it’s working much better now with the new entries you’ve created but not some of the original entries that were created in the installation of the sample theme. I’m seeing the same issue on my local site.

For example, see this entry - https://boldminded.hastings.digital/admin.php?/cp/publish/edit/entry/9 - where there are no categories to choose from in the AC field.

Thanks and sorry, I appreciate this isn’t anyone’s idea of fun!

#47

BoldMinded (Brian)

7 days ago

The FTP still isn’t working. Since what you’re experiencing isn’t something I’m seeing locally, I’ll need FTP access before I invest more time into this. Have you tried sending the FTP info to someone else to see if they can connect?

#48

adamrifat

7 days ago

What’s your IP address? I’ve had it before where the IP gets blocked after too many failed attempts.

#49

BoldMinded (Brian)

7 days ago

Comment has been marked private.

#50

adamrifat

7 days ago

Comment has been marked private.

#51

BoldMinded (Brian)

7 days ago

Comment has been marked private.

#52

BoldMinded (Brian)

7 days ago

Sorry, forgot to mention that after trusting the key I was able to login finally.

#53

adamrifat

7 days ago

You can trust it! Did you click OK?

#54

adamrifat

7 days ago

Hallelujah!

#55

BoldMinded (Brian)

7 days ago

Apparently EE doesn’t like it when you use the ChannelEntry model while editing an entry, which is news to me. I’ll be reaching out to the EE devs and file an issue about this. Your dev site appears to be working now, so try it out. If you need to update a local repo just grab the ft.advanced_categories.php file to get the updates.

#56

BoldMinded (Brian)

7 days ago

#57

adamrifat

7 days ago

Right, thanks seems to be working now.

Just wondering about the ajax call when I change the category selection on the AC field? Is that part of the field or EE?

Also, I need this two work for two category groups on my live site so I guess I’ll need to create two AC fields one for each category group…?

#58

BoldMinded (Brian)

7 days ago

The Ajax call for the validation? Yeah that is piggy backing off of EE’s native field validation.

As for the fields, it entirely depends on how you want to use it, but if you want to make a single required category for 2 different groups, then yeah it sounds like you might need 2 different AC fields.

#59

BoldMinded (Brian)

5 days ago

Adam, I’m going to close this out since it appears to be fixed. If something else pops up feel free to re-open this ticket or create a new one.

Login to reply