CMS Tutorial: problem retrieving tagged articles

Yes, 5 years on from my last post and I’ve returned to the cakephp tutorial. This time I’ve got to the point of retrieving tagged articles, but I get this error:

“Impossible to generate condition with empty list of values for field (Tags.title)
Cake\Database\Exception\DatabaseException”

Looking at the additional info, the problem arises here in:

APP/Controller/ArticlesController.php at line92 in Cake\ORM\Query\SelectQuery->all

        // Use the ArticlesTable to find tagged articles.
        $articles = $this->Articles->find('tagged', tags: $tags)
            ->all();

The error message suggests: “Could this be caused by using Auto-Tables?” but I don’t think that’s the problem since I’ve got everything to work up until this point.

Unfortunately I can’t find any way of debugging my code so I can’t check on the values contained in variables. I’m using netbeans, but I can’t get debugging to work, although I’ll keep working on that - my current theory is that the debugger needs to work with Apache and won’t work with the cakephp development web server, but I’ve a bit of work to do with my apache2 configuration before I can test that.

I’m on Ubuntu 24.10 and using cakephp 5.

Does anyone have any suggestions about what may be going wrong here? I’ve checked the code many times and I’m sure it’s exactly what’s in the tutorial.

Is $tags empty? That’s my guess. dd(tags); on the line before that should tell you.

Firstly, thank you so much for the reply, and yes, I’d suspected that. But the problem was in my head rather than anything to so with how the program was working. That and the fact I couldn’t find any way to debug my code.

The tutorial had said “… now go to /articles/tagged/funny to see all the articles tagged with ‘funny’”. Now, none of my articles have that tag so I thought I could just go to /articles/tagged/ but of course you can’t, which is why I was getting the error. As you say, the error was being generated because the $tags variable was empty - and this showed up when I added dd($tags); to the code.

I didn’t know about that function and had been getting increasingly frustrated with my inability to find ways of debugging the code. So dd() will be a useful tool. Thank you.

And if you would like to suggest any other useful debugging methods, I’d be eternally grateful, because I can’t get xdebug to work with Netbeans no matter how hard I try :smile: .

Once again, many thanks for your help.

Are you aware of Debugging - 5.x ?

I didn’t, but I do now. It looks really useful - especially DebugKit, the output of which looks amazingly helpful.

Many thanks once again.