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

Uncaught Error: Class "Zend_Controller_Request_Http" not found in get.php #3453

Closed
S0FTWEX opened this issue Aug 20, 2023 · 9 comments · Fixed by #3476
Closed

Uncaught Error: Class "Zend_Controller_Request_Http" not found in get.php #3453

S0FTWEX opened this issue Aug 20, 2023 · 9 comments · Fixed by #3476

Comments

@S0FTWEX
Copy link

S0FTWEX commented Aug 20, 2023

Preconditions (*)

Using OpenMage version 20.1.0 & PHP8.2

Steps to reproduce (*)

  1. Hit the URL of non-existent image, e.g.: https://www.domain.tld/media/catalog/category/blankx.jpg
  2. Got error 'PHP message: PHP Fatal error: Uncaught Error: Class "Zend_Controller_Request_Http" not found in get.php:62

Solution (*)

I suggest to move the piece of code in get.php - from lines 78-84:

$mageFilename = 'app/Mage.php';

if (!file_exists($mageFilename)) {
    echo $mageFilename . ' was not found';
}

require_once $mageFilename;

to move above the line 62:
$request = new Zend_Controller_Request_Http();

@fballiano
Copy link
Contributor

I get a 404:

Screenshot 2023-08-20 alle 23 46 16

do you need developer mode or something else in order to trigger the error?

@kiatng
Copy link
Collaborator

kiatng commented Aug 21, 2023

I cannot replicate, I get a 404 as well on the OM 20.1.0 PHP8.2.

@S0FTWEX
Copy link
Author

S0FTWEX commented Aug 21, 2023

I get a 404:
Screenshot 2023-08-20 alle 23 46 16

do you need developer mode or something else in order to trigger the error?

My OpenMage was installed manually (extracting openmage-v20.1.0.zip file). Class Zend_Controller_Request_Http is defined only in vendor/shardj/zf1-future/library/Zend/Controller/Request/Http.php but 'vendor' is not mentioned in included paths in get.php (lines 32-35). So my question is: How can manually installed OpenMage load the Zend_Controller_Request_Http class in this file (get.php) if 'vendor' is not include path? I'm missing this vendor autoloader patch (from Mage.php) also here in get.php:

/** AUTOLOADER PATCH **/
$autoloaderPath = getenv('COMPOSER_VENDOR_PATH');
if (!$autoloaderPath) {
    $autoloaderPath = dirname(BP) . DS .  'vendor';
    if (!is_dir($autoloaderPath)) {
        $autoloaderPath = BP . DS . 'vendor';
    }
}
require $autoloaderPath . DS . 'autoload.php';
/** AUTOLOADER PATCH **/

@ferdiusa
Copy link
Contributor

This issue can be replicated if the .htaccess inside the media/ directory is properly parsed. (this actually redirects all request through get.php)
Some apache configurations skip this (and use the /.htaccess instead of /media/.htaccess for files in subdirectories). Try accessing
http://openmage.test/media/missingfile.jpg
This should result in error 500 instead of 404 due to the missing class (due to missing autoloader patch in get.php)

@ADDISON74
Copy link
Collaborator

@ferdiusa - that is a good observation. I tested this reported before and I got error 500, without anything in the webserver logs. Some testers reported above getting 404 error.

@S0FTWEX
Copy link
Author

S0FTWEX commented Aug 25, 2023

Error 500 can be fixed by adding

<IfModule mod_php8.c>
    php_flag engine 0
</IfModule>

in media/.htaccess. This fix actually redirects all request through get.php, but there is still problem with missing class Zend_Controller_Request_Http.

@fballiano
Copy link
Contributor

I hope #3476 fix this problem ;-)

@S0FTWEX
Copy link
Author

S0FTWEX commented Aug 31, 2023

I hope #3476 fix this problem ;-)

Yes, this PR fixes the problem.

@fballiano
Copy link
Contributor

@S0FTWEX could you leave a review with the green button on the top-left https://github.com/OpenMage/magento-lts/pull/3476/files? thanxxxx

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

Successfully merging a pull request may close this issue.

5 participants