Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Error: Undefined offset: 9 #210

Closed
michaelfromtheoutfit opened this issue Jan 18, 2019 · 8 comments
Closed

Error: Undefined offset: 9 #210

michaelfromtheoutfit opened this issue Jan 18, 2019 · 8 comments

Comments

@michaelfromtheoutfit
Copy link

michaelfromtheoutfit commented Jan 18, 2019

Hey Mark!

Craft Version: 3.1.1
CraftQl Version: 1.2.1

Running into an issue that I believe surfaced after I added tags to my build. Suddenly all of my queries are returning:

{ "error": "Undefined offset: 9" }

I went over to the api/debug endpoint you mentioned in another post and this is what I am getting:

1. in [redacted]/vendor/markhuot/craftql/src/Repositories/TagGroup.php at line 21

function load() {
      foreach (Craft::$app->tags->allTagGroups as $group) {
            if (!isset($this->groups[$group->id])) {
              $this->groups[$group->id] = $group;
            }
        }
    }
 
    function get($id) {
      return $this->groups[$id];
    }
 
    function all() {
        return $this->groups;
    }
 
}

Thanks in advance for any assistance and thanks for an another awesome plugin.

MW

@markhuot
Copy link
Owner

Ah, yea, this is because you have a field pointing to a tag group that doesn't exist any more. It's a weird thing about Craft. If you have a tag field pointing to group 9 and then you delete group 9 the field isn't updated. It's still pointing to 9. I'll get a workaround in there for this.

@michaelfromtheoutfit
Copy link
Author

I thought it might be something like this (because there was a similar request that had to do with categories) but I've only created one tag group and haven't removed any.

If I look at the db directly in craft_taggroups, there is just the one with the autoincrement id field set to 1. So I'm not sure exactly where the 9 is coming from.

Weird, right?

@markhuot
Copy link
Owner

Is there any way you can share a DB with me so I can take a peek? If not I'll see if I can recreate this on my own.

@michaelfromtheoutfit
Copy link
Author

Ah, I don't think I can share the full DB but I could share specific tables if that would be helpful. All of the content/entry/tags tables are just placeholder content at this point. If there's a list of tables you'd like to look at, just shoot me a message with that and where you'd like me to send the mysqldump.

@michaelfromtheoutfit
Copy link
Author

michaelfromtheoutfit commented Jan 21, 2019

Hey @markhuot,

Just adding a little more detail here in case it helps. I've noticed that the query itself isn't what is triggering the error to start happening. It is as soon as I toggle on the Query any tag option in my Token Scope.

For example, if I run this query with that disabled:

query fetchSection {
  entriesConnection(section:[mySection]) {
  	totalCount
  }
}

Everything runs fine. But as soon as I toggle the Query any tag lightswitch, that same query fails with the offset error.

markhuot added a commit that referenced this issue Jan 22, 2019
@markhuot
Copy link
Owner

Sorry, I figured out the issue here. It's a result of a Craft 3.1 change to use uid instead of id. I have a fix on dev-master and after some testing will get it released to a stable version.

@michaelfromtheoutfit
Copy link
Author

Thanks so much @markhuot! Really appreciate the help.

@markhuot
Copy link
Owner

markhuot commented Feb 5, 2019

This is fixed in 1.3.1!

@markhuot markhuot closed this as completed Feb 5, 2019
seamofreality pushed a commit to djfarly/craftql that referenced this issue Jul 3, 2019
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

2 participants