Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Smarty_Internal_CompileBase missing from Composer autoload in PHP 7.4 & Smarty ~3.1 #611

Closed
Sonorpearl opened this issue Oct 8, 2020 · 9 comments
Labels
waiting Waiting for answer

Comments

@Sonorpearl
Copy link

Hello everyone,

it seems like the Smarty_Internal_CompileBase class is missing when requiring or updating the Composer with smarty/smart ~3.1. The following lines are missing:
autoload_classmap.php:
'Smarty_Internal_CompileBase' => $vendorDir . '/smarty/smarty/libs/sysplugins/smarty_internal_compilebase.php',
autoload_static.php:
'Smarty_Internal_CompileBase' => __DIR__ . '/..' . '/smarty/smarty/libs/sysplugins/smarty_internal_compilebase.php',

Otherwise I'm getting the following error with the Composer autoloader & include:
<br /> <b>Fatal error</b>: Uncaught Error: Class 'Smarty_Internal_CompileBase' not found in .../lib/smarty/smarty/libs/sysplugins/smarty_internal_compile_private_php.php:17 Stack trace: #0 .../lib/composer/ClassLoader.php(444): include() #1 .../lib/composer/ClassLoader.php(322): Composer\Autoload\includeFile('/var/www/...') #2 [internal function]: Composer\Autoload\ClassLoader-&gt;loadClass('Smarty_Internal...') #3 [internal function]: spl_autoload_call('Smarty_Internal...') #4 .../lib/smarty/smarty/libs/sysplugins/smarty_internal_templatecompilerbase.php(789): class_exists('Smarty_Internal...') #5 .../lib/smarty/smarty/libs/sysplugins/smarty_internal_templatelexer.php(435): Smarty_Internal_TemplateCompilerBase-&gt;getTagCompiler('private_php') #6 .../lib/smarty/smarty/libs/sysplugins/smarty_internal_templatelexer.php(359): Smarty_Internal_Templatelexer-&gt;yy_r1_16() #7 /var/www in <b>.../lib/smarty/smarty/libs/sysplugins/smarty_internal_compile_private_php.php</b> on line <b>17</b><br />

@Sonorpearl Sonorpearl changed the title Smarty_Internal_CompileBase missing from Composer autoload on PHP 7.4 & Smarty ~3.1 Smarty_Internal_CompileBase missing from Composer autoload in PHP 7.4 & Smarty ~3.1 Oct 8, 2020
@wisskid
Copy link
Contributor

wisskid commented Jan 5, 2021

@Sonorpearl I can't reproduce. Do you have a sample with test.php and composer.json files that triggers the error?

@wisskid wisskid closed this as completed Jan 5, 2021
@ironic
Copy link

ironic commented Nov 21, 2022

@wisskid I do have the very same issue with PHP 8.1 and Smarty 4.2 running in a PHP-FPM Docker container using composer:

Fatal error: Uncaught Error: Class "Smarty_Internal_CompileBase" not found in /var/www/vhosts/smarty-test/vendor/smarty/smarty/libs/sysplugins/smarty_internal_compile_private_print_expression.php:17 Stack trace: #0 /var/www/vhosts/smarty-test/vendor/composer/ClassLoader.php(571): include() #1 /var/www/vhosts/smarty-test/vendor/composer/ClassLoader.php(428): Composer\Autoload\includeFile('/var/www/vhosts...') #2 [internal function]: Composer\Autoload\ClassLoader->loadClass('Smarty_Internal...') #3 /var/www/vhosts/smarty-test/vendor/smarty/smarty/libs/sysplugins/smarty_internal_templatecompilerbase.php(770): class_exists('Smarty_Internal...') #4 /var/www/vhosts/smarty-test/vendor/smarty/smarty/libs/sysplugins/smarty_internal_templatecompilerbase.php(747): Smarty_Internal_TemplateCompilerBase->getTagCompiler('private_print_e...') #5 /var/www/vhosts/smarty-test/vendor/smarty/smarty/libs/sysplugins/smarty_internal_templatecompilerbase.php(1482): Smarty_Internal_TemplateCompilerBase->callTagCompiler('private_print_e...', Array, Array) #6 /var/www/vhosts/smarty-test/vendor/smarty/smarty/libs/sysplugins/smarty_internal_templatecompilerbase.php(550): Smarty_Internal_TemplateCompilerBase->compileTag2('private_print_e...', Array, Array) #7 /var/www/vhosts/smarty-test/vendor/smarty/smarty/libs/sysplugins/smarty_internal_templateparser.php(2085): Smarty_Internal_TemplateCompilerBase->compileTag('private_print_e...', Array, Array) #8 /var/www/vhosts/smarty-test/vendor/smarty/smarty/libs/sysplugins/smarty_internal_templateparser.php(2777): Smarty_Internal_Templateparser->yy_r11() #9 /var/www/vhosts/smarty-test/vendor/smarty/smarty/libs/sysplugins/smarty_internal_templateparser.php(2872): Smarty_Internal_Templateparser->yy_reduce(11) #10 /var/www/vhosts/smarty-test/vendor/smarty/smarty/libs/sysplugins/smarty_internal_smartytemplatecompiler.php(128): Smarty_Internal_Templateparser->doParse(3, ', welcome to Sm...') #11 /var/www/vhosts/smarty-test/vendor/smarty/smarty/libs/sysplugins/smarty_internal_templatecompilerbase.php(466): Smarty_Internal_SmartyTemplateCompiler->doCompile('{* Smarty *}\nHe...', true) #12 /var/www/vhosts/smarty-test/vendor/smarty/smarty/libs/sysplugins/smarty_internal_templatecompilerbase.php(395): Smarty_Internal_TemplateCompilerBase->compileTemplateSource(Object(Smarty_Internal_Template), false, NULL) #13 /var/www/vhosts/smarty-test/vendor/smarty/smarty/libs/sysplugins/smarty_template_compiled.php(184): Smarty_Internal_TemplateCompilerBase->compileTemplate(Object(Smarty_Internal_Template)) #14 /var/www/vhosts/smarty-test/vendor/smarty/smarty/libs/sysplugins/smarty_template_compiled.php(141): Smarty_Template_Compiled->compileTemplateSource(Object(Smarty_Internal_Template)) #15 /var/www/vhosts/smarty-test/vendor/smarty/smarty/libs/sysplugins/smarty_template_compiled.php(105): Smarty_Template_Compiled->process(Object(Smarty_Internal_Template)) #16 /var/www/vhosts/smarty-test/vendor/smarty/smarty/libs/sysplugins/smarty_internal_template.php(216): Smarty_Template_Compiled->render(Object(Smarty_Internal_Template)) #17 /var/www/vhosts/smarty-test/vendor/smarty/smarty/libs/sysplugins/smarty_internal_templatebase.php(238): Smarty_Internal_Template->render(false, 1) #18 /var/www/vhosts/smarty-test/vendor/smarty/smarty/libs/sysplugins/smarty_internal_templatebase.php(134): Smarty_Internal_TemplateBase->_execute(Object(Smarty_Internal_Template), NULL, NULL, NULL, 1) #19 /var/www/vhosts/smarty-test/index.php(10): Smarty_Internal_TemplateBase->display('test.tpl') #20 {main} thrown in /var/www/vhosts/smarty-test/vendor/smarty/smarty/libs/sysplugins/smarty_internal_compile_private_print_expression.php on line 17

My composer.json file looks as follows:
{ "require": { "smarty/smarty": "~4.2" } }

Test PHP file:
`require "vendor/autoload.php";

$smarty = new Smarty();
$smarty->assign("name", "John");
$smarty->display("test.tpl");`

Test template file:
Hello {$name}, welcome to Smarty!

I found nearly all smarty classes in the composer classmap file, but Smarty_Internal_CompileBase is missing there.

@wisskid wisskid reopened this Nov 21, 2022
@wisskid
Copy link
Contributor

wisskid commented Nov 21, 2022

I'll have a look! Thank you for the detailed report.

@wisskid
Copy link
Contributor

wisskid commented Nov 21, 2022

I'm afraid I cannot reproduce:

#!/bin/bash

php -v

composer require "smarty/smarty 4.2"
composer install
echo 'Hello {$name}, welcome to Smarty!' > test.tpl
echo '<?php
require "vendor/autoload.php";

$smarty = new Smarty();
$smarty->assign("name", "John");
$smarty->display("test.tpl");' > test.php
php test.php
PHP 8.1.2-1ubuntu2.8 (cli) (built: Nov  2 2022 13:35:25) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.2, Copyright (c) Zend Technologies
    with Zend OPcache v8.1.2-1ubuntu2.8, Copyright (c), by Zend Technologies

Info from https://repo.packagist.org: #StandWithUkraine
./composer.json has been created
Running composer update smarty/smarty
Loading composer repositories with package information
Info from https://repo.packagist.org: #StandWithUkraine
Updating dependencies
Lock file operations: 1 install, 0 updates, 0 removals
  - Locking smarty/smarty (v4.2.0)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 1 install, 0 updates, 0 removals
  - Installing smarty/smarty (v4.2.0): Extracting archive
Generating autoload files

Installing dependencies from lock file (including require-dev)
Verifying lock file contents can be installed on current platform.
Nothing to install, update or remove
Generating autoload files
Hello John, welcome to Smarty!

@wisskid
Copy link
Contributor

wisskid commented Nov 21, 2022

The composer install is useless, already implied by composer require as indicated by the Nothing to install, update or remove in the output.

@wisskid wisskid added the waiting Waiting for answer label Nov 21, 2022
@wisskid
Copy link
Contributor

wisskid commented Nov 21, 2022

I'm quite curious what might be causing this error. Smarty_Internal_CompileBase is quite obviously exactly where it should be:

$ grep -r "class Smarty_Internal_CompileBase"
vendor/smarty/smarty/libs/sysplugins/smarty_internal_compilebase.php:abstract class Smarty_Internal_CompileBase

and Smarty's composer.json autoloads the entire libs directory:

"autoload": {
        "classmap": [
            "libs/"
        ]
    },

@ironic
Copy link

ironic commented Nov 22, 2022

Thank you @wisskid for having a quick look an this issue. You're right, this is NO Smarty bug!
It seems to be a WSL2 bug, see:

I tried it on an other plattform and all Smarty classes were listed correctly.

@wisskid wisskid closed this as not planned Won't fix, can't repro, duplicate, stale Nov 22, 2022
@Tacks9
Copy link

Tacks9 commented Jul 3, 2023

  • I also encountered the same problem, I am trying to upgrade smarty , smarty/smarty:v3.1.36 => smarty/smarty:v3.1.48
$ composer require smarty/smarty:v3.1.48
./composer.json has been updated
Running composer update smarty/smarty
Loading composer repositories with package information
Info from https://repo.packagist.org: #StandWithUkraine
Updating dependencies
Lock file operations: 0 installs, 1 update, 0 removals
  - Upgrading smarty/smarty (v3.1.36 => v3.1.48)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 0 installs, 1 update, 0 removals
  - Downloading smarty/smarty (v3.1.48)
  - Upgrading smarty/smarty (v3.1.36 => v3.1.48): Extracting archive
Generating autoload files
2 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
No security vulnerability advisories found
  • However, when accessing the page, an error was encountered as follows
Fatal error: Uncaught Error: Class 'Smarty_Internal_CompileBase' not found in /www/vendor/smarty/smarty/libs/sysplugins/smarty_internal_compile_private_function_plugin.php ,
  • Thank you for this issue , I checked the file autoload_classmap.phpautoload_static.php ,There are indeed a few lines missing
autoload_classmap.php:
'Smarty_Internal_CompileBase' => $vendorDir . '/smarty/smarty/libs/sysplugins/smarty_internal_compilebase.php',

autoload_static.php:
'Smarty_Internal_CompileBase' => __DIR__ . '/..' . '/smarty/smarty/libs/sysplugins/smarty_internal_compilebase.php',
  • But it's not about smart , It could be my environment

Error

/www/ # composer -V
Composer version 2.5.7 2023-05-24 15:00:39
/www/ # php -v
PHP 7.4.33 (cli) (built: Nov 12 2022 09:21:12) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.33, Copyright (c), by Zend Technologies
/www/ # uname -a
Linux 99dfd383a39e 5.10.16.3-microsoft-standard-WSL2 #1 SMP Fri Apr 2 22:23:49 UTC 2021 x86_64 Linux

Success

# cat /etc/redhat-release 
CentOS Linux release 7.2.1511 (Core)

@ironic
Copy link

ironic commented Jul 3, 2023

See post before, this is no Smarty/PHP Bug:
microsoft/WSL#5074

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
waiting Waiting for answer
Projects
None yet
Development

No branches or pull requests

4 participants