Yii Framework Test Script Submitting to Production

Edit: It looks like our RewriteRule directives in Apache may have been the culprit. We rarely use a .htaccess file and instead use configuration files to speed up Apache. Since we didn’t change index.php to index-test.php in the configuration, it was redirecting to the index.php!

In the Yii Framework, you can always call index-test.php to use your test settings & database connection. This is handy in a variety of ways. However, we recently found that some actions (redirects) that occurred after a page submit were redirecting us to the index.php – the production site. Luckily, we were still on our local machine, so we had no test cases misdirecting from test to production. To fix this, we set the URL Manager’s showScriptName to true in our test configuration. After we did this, everything worked as expected.

Snippet from our test configuration file:

// uncomment the following to enable URLs in path-format
   'showScriptName' => true,
Share this page:
  • Facebook
  • Twitter
  • Reddit
  • Google Bookmarks
  • email
  • Print
  • RSS
  • Digg
  • StumbleUpon
  • del.icio.us
  • Slashdot
  • Technorati
  • Tumblr

Steven Michaels

Steven Michaels specializes in PHP web applications utilizing MediaWiki, WordPress, Yii Framework and others. He is an open source contributor and leads development for both of Hollow Developers' internal projects, HollowGame and SpeechEase.

Facebook comments:

Leave a Reply