Typo3 500 Error - Too Few Arguments to Function

Hi,

I’m completely new to PHP and Typo3 having never used either before, I’ve recently been tasked with moving a Typo3 Site and have chosen to move it into MS Azure onto a Windows VM running IIS. The site was previously running on a Unix Server provided by a third-party web hosting company.

After the migration I can get to the CMS and access all the content, I can view all the plugins - however, I cannot browse to any of the pages on the site without receiving a 500 Error.

In the PHP error.log I keep getting this error whenever I try and access a page - I am completely stumped as this was working on the old Unix Server so I suspect it must be down to misconfiguration somewhere.

The files on the file system are a mess with files from multiple versions just left there and way too many symlinks! I have done my best to unpick it but I’m left with this 500 error.

[02-Aug-2024 14:23:48 UTC] PHP Fatal error: Uncaught ArgumentCountError: Too few arguments to function TYPO3\CMS\Core\Localization\LanguageServiceFactory::__construct(), 0 passed in C:\inetpub\public_html\subsites\typo3_src\typo3\sysext\core\Classes\Utility\GeneralUtility.php on line 3477 and exactly 2 expected in C:\inetpub\public_html\subsites\typo3_src\typo3\sysext\core\Classes\Localization\LanguageServiceFactory.php:35
Stack trace:
#0 C:\inetpub\public_html\subsites\typo3_src\typo3\sysext\core\Classes\Utility\GeneralUtility.php(3477): TYPO3\CMS\Core\Localization\LanguageServiceFactory->__construct()
#1 C:\inetpub\public_html\subsites\typo3_src\typo3\sysext\core\Classes\Localization\LanguageService.php(446): TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(‘TYPO3\CMS\Core\…’)
#2 C:\inetpub\public_html\subsites\typo3_src\typo3\sysext\core\Classes\Information\Typo3Information.php(45): TYPO3\CMS\Core\Localization\LanguageService::create(‘default’)
#3 C:\inetpub\public_html\subsites\typo3_src\typo3\sysext\core\Classes\Utility\GeneralUtilit in C:\inetpub\public_html\subsites\typo3_src\typo3\sysext\core\Classes\Localization\LanguageServiceFactory.php on line 35

Any pointers would be appreciated!

Hi there!

First I want to try to explain the error message you’re getting a bit. You did not mention your TYPO3 version, so I am assuming it’s v12.

TYPO3 uses an autoloading mechanism (in conjunction with Dependency Injection) which, by some “magic” is able to know which parameters of PHP object constructors refer to which PHP service classes. This is like an “addressbook” of things and how to locate them were.

TYPO3 supports two modes of operation; a “composer” mode and a “classic” mode. You’re using the latter, as I can tell from your URL structure.

This map should then be stored (and loaded from) the directory typo3temp/var/cache/code/di/. There should be at least one file that contains the “mapping”, dependant on the extension and configuration you made.

The error you posted now tells us, that this map can somehow not be utilized to resolve the target constructor method service classes, and then just passes none. And that makes TYPO3 fail.

To fix the error, you can:

  • First try is to see if you can access the install tool at your site (http://yoursite.example.com/typo3/install.php). If that works, login, clear all caches there. Then try to access the normal backend
  • If the above fails, try to open your command prompt on the machine and execute c:\...\php.exe ./vendor/typo3/cms-cli/typo3 cache:flush. Adjust the paths to your php.exe and where your TYPO3 binary is located.
  • If that also did not work, backup your typo3temp directory (just in case you don’t have a copy) and remove all files and directories inside of it
  • If that still did not work, please ensure you really transferred all files from the UNIX variant, and carefully watch out if the symlinks got resolved properly
  • If all of that does not help further, tell us what happened at each step and maybe we can help further with more information.

By the way, did you make sure to use the same PHP version like the one that was installed on your UNIX system?

As for symlinks: You do not necessarily need them anymore. Which ones are left for you, and where do they point from/to?

Closing word and personal note: A Windows IIS installation ranks a bit lower in “ease of use” and performance and compativility. If possible, maybe think about continuing to host TYPO3 on a UNIX based system, that wasn’t so bad, if that existed previously :wink:
If you get into the actual backend, you will very likely face a plethora of further follow up issues like missing PHP mailserver configuration, missing image conversion configuration, PDF conversion tools, caching configuration, scheduler/crontab configuration etc.

2 Likes

Hi There,

Thank you for a very detailed reply - it is very useful to understand how things are working under the covers.

I am indeed using the classic mode. Just to confirm I can get to the TYPO3 CMS via the login page - /typo3/index.php and I can access everything in the CMS just fine. The issue is that I can’t get to any of the pages on the site itself (e.g. I have a page called /activitiesnew on the site and while I can open this from within the CMS and view/update the contents of the page but if I try and browse to mysite.com/activitiesnew I get a 500 error back.

From your list of steps I have already tried to:

  • Flush the cache through the CMS (Maintenance → Flush TYPO3 and PHP Cache)
  • Remove the typo3temp directory entirely from the file system - after this is done a new folder is generated but the error persists when I try to browse any of the pages.
  • I tried running the command you mentioned using the CLI but I’m faced with a different error:
c:\inetpub\public_html\subsites\typo3_src-master>c:\php\php.exe ./vendor/typo3/cms-cli/typo3 cache:flush

Warning: require(c:/inetpub/public_html/subsites/typo3_src-master/vendor/typo3/typo3/sysext/core/Configuration/DefaultConfiguration.php): failed to open stream: No such file or directory in C:\inetpub\public_html\subsites\typo3_src-master\typo3\sysext\core\Classes\Configuration\ConfigurationManager.php on line 92

Fatal error: require(): Failed opening required 'c:/inetpub/public_html/subsites/typo3_src-master/vendor/typo3/typo3/sysext/core/Configuration/DefaultConfiguration.php' (include_path='.;C:\php\pear') in C:\inetpub\public_html\subsites\typo3_src-master\typo3\sysext\core\Classes\Configuration\ConfigurationManager.php on line 92

I am not sure if this has anything to do with my error or if this is just related to the CLI. I am not sure why it tries to look for the sysext folder in the vendor directory as this is in the typo3 folder in the root of the site?

I agree that Windows is not the best platform to host this site on but I chose it as it is only required as a temporary solution and I am extremely comfortable with IIS and Web Hosting in General on a Windows Server.

The Typo 3 Version on the site is 10.4.28 - which is massively outdated now but this system that I am supporting hasn’t been updated for a very long time. The goal is to get it working on the existing version first and then migrate to a newer version.

PHP Version on both the Windows and Unix installation is: 7.4.

Ah. In Classic mode the CLI binary might be at another place. I haven’t used that for a longer time. Check if you find a file “typo3” (no file extension) in another directory, that might be the binary you need to execute with php.exe then.

Errors on getting the frontend inaccessbile could be due to .htaccess file not getting evaluated? Did you ensure your webserver is able to interpret it, and the file was transferred (should be in your document root, where “index.php” of TYPO3 lies).

HTH,
Garvin