user-pic

Old browser bookmarks broken in MT 4.2

Vote 0 Votes

I had a number of browser bookmarks for my various MT installations that broke when I upgraded to MT 4.2. For instance, the following URL:

 http://www.example.com/cgi-bin/mt.cgi?__mode=menu&blog_id=1

Would generate the following errors:

 An error occurred
 failed loading package ${pkg}Dashboard for routine ${pkg}Dashboard::dashboard: syntax error at lib/MT.pm line 2622, near "${pkg}Dashboard" MT::handler_to_coderef('MT::App::CMS=HASH(0x85f03e4)', '${pkg}Dashboard::dashboard') called at lib/MT/App.pm line 2257 eval {...} called at lib/MT/App.pm line 2150 MT::App::run('MT::App::CMS=HASH(0x85f03e4)') called at lib/MT/Bootstrap.pm line 76 eval {...} called at lib/MT/Bootstrap.pm line 59 MT::Bootstrap::import('MT::Bootstrap', 'App', 'MT::App::CMS') called at mt.cgi line 11 main::BEGIN() called at lib/MT/Auth.pm line 11 eval {...} called at lib/MT/Auth.pm line 11

The problem was being caused by the "_mode=menu" portion of the query string, which no longer appears to be supported in MT 4.2. To resolve the issue for anyone else on my system who might have similarly ancient bookmarks, I inserted the following modrewrite rules into my .htaccess file:

 RewriteEngine on
 RewriteCond %{QUERY_STRING} ^(.*)__mode=menu(.*)$
 RewriteRule .* /cgi-bin/mt.cgi?%1__mode=dashboard%2 [R=301,L]

...which, if my rudimentary mod_rewrite skills haven't completely failed me, replaces any instance of "mode=menu" with "mode=dashboard".

I'm posting my solution here in hopes that it will:

 a. Help anyone else who is experiencing similar problems.
 b. Bring the mod_rewrite regexperts out of the woodwork to mock my solution and instruct people on the proper way to do it.

1 Reply

| Add a Reply
  • Thank you for posting this. For those interested in knowing why this happened, in MT 4.2 we did a lot of work to modularize the largest file in the entire codebase: MT/App/CMS.pm.

    When we broke it up into smaller pieces, some of the URLs changes as slightly related consequence. URLs also changes between MT 3.x and MT 4.x, so that can be another contributing reason.

    In any event, MT does not do these redirects automatically, but in hind sight, it probably should have.

    Thanks for posting this solution though!

Add a Reply

Forum Groups