0
votes

I want to test new design of my project without turn off original one. I made a copy of the entire source directory to the new directory. I prepared subdomain and directory name as follow (this is shared hosting):

<pre>
    http://project.mydomain.com/
    /public/user1/project/

    http://project1.mydomain.com
    /public/user1/project1/
</pre>

The same I made on my localhost (Windows, Apache2.4, php 5.6). Just added '1' to new directory name and copy all content of source directory. On localhost both 'sites' work with any problem.

But on shared hosting duplicated site works fine until I try to use redirect control plugin. In result I see only blank page. It happens in all of my 14 modules and with any of route I used.

An example call:

<pre>
    public function fakeAction() 
    {        
        if ( $this->getRequest()->isPost() ) 
        {
            return $this->redirect()->toRoute('main');
        }

        return $this->redirect()->toRoute('login');        
    }

</pre>

,where route 'main' is configured as:

<pre>
    return [
        'router' => [
            'routes' => [

                'main' => [
                    'type' => Literal::class,
                    'options' => [
                        'route' => '/',
                        'defaults' => [
                            'controller' => Controller\MainController::class,
                            'action' => 'index'
                        ]
                    ]
                ],
</pre>

Few other facts:

  • I did not use events (like MvcEvent::EVENT_DISPATCH or any others)
  • I have only one onBootsrtap() method in Application module (13 others modules are nothing more than getConfig() in Module.php):

        
        public function onBootstrap ( MvcEvent $event )
        {
            $application = $event->getApplication();
            $serviceManager = $application->getServiceManager();
            $sessionManager = $serviceManager->get( SessionManager::class );
            $sessionManager->start();
        }
    
  • $this->redirect()->toRoute('main') return (IMHO) proper object:

        Zend\Http\PhpEnvironment\Response Object
        (
            [version:protected] => 
            [contentSent:protected] => 
            [recommendedReasonPhrases:protected] => Array
                (
                    [100] => Continue
                    [101] => Switching Protocols
                    [102] => Processing
                    [200] => OK
                    [201] => Created
                    [202] => Accepted
                    [203] => Non-Authoritative Information
                    [204] => No Content
                    [205] => Reset Content
                    [206] => Partial Content
                    [207] => Multi-status
                    [208] => Already Reported
                    [226] => IM Used
                    [300] => Multiple Choices
                    [301] => Moved Permanently
                    [302] => Found
                    [303] => See Other
                    [304] => Not Modified
                    [305] => Use Proxy
                    [306] => Switch Proxy
                    [307] => Temporary Redirect
                    [308] => Permanent Redirect
                    [400] => Bad Request
                    [401] => Unauthorized
                    [402] => Payment Required
                    [403] => Forbidden
                    [404] => Not Found
                    [405] => Method Not Allowed
                    [406] => Not Acceptable
                    [407] => Proxy Authentication Required
                    [408] => Request Time-out
                    [409] => Conflict
                    [410] => Gone
                    [411] => Length Required
                    [412] => Precondition Failed
                    [413] => Request Entity Too Large
                    [414] => Request-URI Too Long
                    [415] => Unsupported Media Type
                    [416] => Requested range not satisfiable
                    [417] => Expectation Failed
                    [418] => I'm a teapot
                    [422] => Unprocessable Entity
                    [423] => Locked
                    [424] => Failed Dependency
                    [425] => Unordered Collection
                    [426] => Upgrade Required
                    [428] => Precondition Required
                    [429] => Too Many Requests
                    [431] => Request Header Fields Too Large
                    [444] => Connection Closed Without Response
                    [451] => Unavailable For Legal Reasons
                    [499] => Client Closed Request
                    [500] => Internal Server Error
                    [501] => Not Implemented
                    [502] => Bad Gateway
                    [503] => Service Unavailable
                    [504] => Gateway Time-out
                    [505] => HTTP Version not supported
                    [506] => Variant Also Negotiates
                    [507] => Insufficient Storage
                    [508] => Loop Detected
                    [510] => Not Extended
                    [511] => Network Authentication Required
                    [599] => Network Connect Timeout Error
                )
            [statusCode:protected] => 302
            [reasonPhrase:protected] =>
            [headers:protected] => Zend\Http\Headers Object
                (
                    [pluginClassLoader:protected] => 
                    [headersKeys:protected] => Array
                        (
                            [0] => location
                        )
    
    
                [headers:protected] => Array
                    (
                        [0] => Array
                            (
                                [name] => Location
                                [line] => Location: /
                            )
    
                    )
    
            )
        [metadata:protected] => Array
            (
            )
        [content:protected] => 
    ) 
    
  • Address in browser is still the same.

  • Browser developer tool shows that browser is not redirecting anywhere (no new entries on network tab),
  • Browser does not get no new incoming data.
  • Apache error.log shared by provider does not have any entries
  • Apache access.log shows

        05/Mar/2018:13:43:51 +0100    
        xxx.xx.xx.xxx
        GET /favicon.ico HTTP/1.0
        Status: 200 318 B
    
    
    05/Mar/2018:13:43:49 +0100
    xxx.xx.xx.xxx   
    POST /open HTTP/1.0
    Status: 200 23 B
    

Maybe this is clue: Is it ok, that server are sending /favicon.ico AFTER POST? But why? I return as result of fakeAction() Zend\Http\PhpEnvironment\Response object not ViewModel.

  • I'm catching all exceptions, errors and strict notices but in this case - Apache/php/framework don't trigger any of them.

  • And last test: In case some files are damaged during copying I just only renamed directory of working version from 'project' to 'project1' efect is the same - redirect does not work.

UPDATE 1

  • I deleted vendor directory and get it again via composer.
  • Cache is clear (I did not use cache, zend framework is in development-mede all time)

FINAL UPDATE!

I found out what happend. As I wrote in one of my answer, I use composer via Zend Studio interface. Today I opened Zend Studio console and carefully checked console log. Every time I used command update/install dependencies composer used own cache (not online repository) and it copied module zend-developer-tool BUT (for unknow reason) one of module's file was corrupted in composer cache on local harddrive. After I deleted composer cache and run update/instal dependeces again all works as should be. Thanks all for effort.

1
Did you removed auto-generated config cache and run composer update?edigu
I did not use cache at all, project is all time development mode so cache is disabled, but for sure I checked - was empty. I deleted all "vendor " direcotry and get fresh from github. Nothing id changed.0kph

1 Answers

0
votes

Finally I traced source of problem. Right now it's not clear for me "why", but problem is conected with module zendframework/zend-developer-tools. Why am I sure that this module failed? I'm not. But maybe this help someone with similar cases.

In the act of powerlessness, I deleted the entire "require-dev" section and regenerated config files (composer update) and problem disappeared! This is the section:

"require-dev" : {
    "zendframework/zend-developer-tools" : "^1.1",
    "zendframework/zend-debug" : "^2.5",
    "san/san-session-toolbar" : "^1.0",
    "zfcampus/zf-development-mode" : "^3.1"
},

I thought, maybe @edigu has right, and problem is with auto-generated files and it is only coincidence. I had to know it for future - which module (if any) is responsible for my problem. After rollback to 'broken version' I was started to uninstall module one by one from this section (and I always regenerated files of course). Effect was the same - the problem was still alive. Only when I deleted zend-developer-tools all works fine...

Of course, if I delete zend-developers-tool in source project and then I copy it to new directory - all works fine form the begining.

As I have wrote above - I don't know "why", yet. But this is repeatable. Every time I copy original project - I have problem with redirect which gone after I delete this module...


FINAL UPDATE!

I found out what happend. As I wrote in one of my answer, I use composer via Zend Studio interface. Today I opened Zend Studio console and carefully checked console log. Every time I used command update/install dependencies composer used own cache (not online repository) and it copied module zend-developer-tool BUT (for unknow reason) one of module's file was corrupted in composer cache on local harddrive. After I deleted composer cache and run update/instal dependeces again all works as should be. Thanks all for effort.