Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.

Autoloader not finding class Smarty_Internal_Compile_Cycle

 
Post new topic   Reply to topic    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
zbmowrey
Smarty n00b


Joined: 01 Feb 2018
Posts: 3

PostPosted: Thu Feb 01, 2018 3:36 pm    Post subject: Autoloader not finding class Smarty_Internal_Compile_Cycle Reply with quote

Hi,

I'm updating an older codebase so that we can migrate from PHP 5.5 to 7.0 (Big job, I know).

On our PHP 7.0.27 box (Apache 2.2.15), I've installed the latest Smarty (3.1^) using Composer.

I've put the require_once for vendor/autoload.php at the top of our index; we do use a custom autoloader, but prepend is false so Composer's autoloader (and thus Smarty's) should be at the top of the stack.

My problem is that on some child pages (not all), we see that our custom autoloader is being told to load this class:

Smarty_Internal_Compile_Cycle

...Which doesn't exist. Multiple search engines, these forums, and scanning the code all turn up nothing.

I'm reading this as if Smarty's autoloader couldn't find the class, Composer's autoloader couldn't find it, and finally our in-house autoloader tried (and naturally failed).

Roughly 50% of our pages load fine with no issues, and the other 50% fail with this problem. I've reviewed the TPLs to see if there's something different about them, but I'm not seeing it. We are by no means pushing the boundaries of Smarty, it's all really basic variable calls and some foreach loops. And every page has those.

Can someone offer me some ideas to try for isolating the issue, or give me some direction to move in so I can give better/more detailed data if needed?

Thank you in advance!
Back to top
View user's profile Send private message
zbmowrey
Smarty n00b


Joined: 01 Feb 2018
Posts: 3

PostPosted: Thu Feb 01, 2018 3:58 pm    Post subject: Reply with quote

After further research, I found the underlying issue:

<tr class="{cycle values='odd,even'}">

This code is causing the error. I can fix our code by removing since we're going to switch our table layout/ux anyway.

Not sure why it's trying to find a class that doesn't exist, though. This call is documented in v3 (unless I'm misreading things), so I'd guess it's there.
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1744

PostPosted: Thu Feb 01, 2018 7:00 pm    Post subject: Reply with quote

Seems like your Smarty is misconfigured, or misinitialized.
{cycle} is part of standard distribution. https://www.smarty.net/docs/en/language.function.cycle.tpl

My guess is that you have a conflicting legacy Smarty code in your project.
Back to top
View user's profile Send private message
zbmowrey
Smarty n00b


Joined: 01 Feb 2018
Posts: 3

PostPosted: Thu Feb 01, 2018 7:34 pm    Post subject: Reply with quote

I appreciate your response. In the long term I'd rather understand what went wrong here (because I don't want any other surprises later), but for expediency I pulled out the cycles and as far as I can tell everything else is working perfectly.

If I ever do figure out the underlying cause, I'll add it here.
Back to top
View user's profile Send private message
bsmither
Smarty Elite


Joined: 20 Dec 2011
Posts: 306
Location: West Coast

PostPosted: Fri Feb 02, 2018 11:55 pm    Post subject: Reply with quote

Please try the Smarty command using quotes around the complete string of comma-separated list of arguments -- as opposed to using apostrophes.

Might make a difference. It did for me on a few other Smarty commands.
Back to top
View user's profile Send private message
bsmither
Smarty Elite


Joined: 20 Dec 2011
Posts: 306
Location: West Coast

PostPosted: Sat Feb 03, 2018 12:05 am    Post subject: Reply with quote

There is /plugins/function.cycle.php

Is there any way to get a backtrace up to the point where the call for Smarty_Internal_Compile_Cycle is made?
Back to top
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Mon Apr 09, 2018 12:45 pm    Post subject: Reply with quote

We use code like
Code:
class_exists($classname, [true])

to try to find compiler code or after that try plugins.
The class Smarty_Internal_Compiler_Cykle does not exists. next step would be to look in the plugin folder.

However this does only work if the autoloader return false if the class does not exists. There are some composer options which will disable this functinallity

see also https://github.com/smarty-php/smarty/issues/344
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP