http://redmine.openpne.jp/
http://redmine.openpne.jp/favicon.ico
2011-10-05T09:34:04Z
OpenPNE Issue Tracking System
OpenPNE 3 - Backport(バックポート) #2324: There are wrong URL generating for op_base_url with path name (パス名付きの op_base_url に対して誤った URL 生成をしている箇所がある)
http://redmine.openpne.jp/issues/2324?journal_id=11438
2011-10-05T09:34:04Z
Shinichi Urabe
urabe+op3@nuts-choco.com
<ul><li><strong>期日</strong> を <i>2011-10-06</i> にセット</li><li><strong>担当者</strong> を <i>Yuya Watanabe</i> にセット</li></ul>
OpenPNE 3 - Backport(バックポート) #2324: There are wrong URL generating for op_base_url with path name (パス名付きの op_base_url に対して誤った URL 生成をしている箇所がある)
http://redmine.openpne.jp/issues/2324?journal_id=11578
2011-10-10T09:06:18Z
Yuya Watanabe
watanabe@openpne.jp
<ul><li><strong>ステータス</strong> を <i>New(新規)</i> から <i>Accepted(着手)</i> に変更</li></ul><p><a class="issue tracker-4 status-5 priority-5 priority-high3 closed" title="Backport(バックポート): 設定ファイルを記述し忘れた場合に、招待メールに記載されたURLにアクセスできない (Fixed(完了))" href="http://redmine.openpne.jp/issues/2120">#2120</a> <a class="issue tracker-4 status-5 priority-4 priority-default closed" title="Backport(バックポート): OpenPNE.ymlのbase_url にパスが含まれない場合に、デバッグモードでwarningメッセージが表示される場合がある (Fixed(完了))" href="http://redmine.openpne.jp/issues/2325">#2325</a> は本チケットのBP元の実装により発生しうる問題のBPとなるため,本チケットのBP元となる <a class="issue tracker-1 status-5 priority-4 priority-default closed" title="Bug(バグ): There are wrong URL generating for op_base_url with path name (パス名付きの op_base_url に対して誤った URL 生成を... (Fixed(完了))" href="http://redmine.openpne.jp/issues/1155">#1155</a> の実装に <a class="issue tracker-1 status-5 priority-4 priority-default closed" title="Bug(バグ): OpenPNE.ymlのbase_url にパスが含まれない場合に、デバッグモードでwarningメッセージが表示される場合がある (Fixed(完了))" href="http://redmine.openpne.jp/issues/1577">#1577</a> および <a class="issue tracker-1 status-5 priority-5 priority-high3 closed" title="Bug(バグ): 設定ファイルを記述し忘れた場合に、招待メールに記載されたURLにアクセスできない (Fixed(完了))" href="http://redmine.openpne.jp/issues/1675">#1675</a> の実装を含めたものを本チケットの実装案として記述します.具体的には以下のようなものを検討しています.<br />また,BP元 <a class="issue tracker-1 status-5 priority-4 priority-default closed" title="Bug(バグ): There are wrong URL generating for op_base_url with path name (パス名付きの op_base_url に対して誤った URL 生成を... (Fixed(完了))" href="http://redmine.openpne.jp/issues/1155">#1155</a> ではSSLを考慮したコミットも含まれますが, 3.4 ではSSLは未対応であるため本チケットでは対応しません.</p>
<p><a class="issue tracker-4 status-5 priority-5 priority-high3 closed" title="Backport(バックポート): 設定ファイルを記述し忘れた場合に、招待メールに記載されたURLにアクセスできない (Fixed(完了))" href="http://redmine.openpne.jp/issues/2120">#2120</a> <a class="issue tracker-4 status-5 priority-4 priority-default closed" title="Backport(バックポート): OpenPNE.ymlのbase_url にパスが含まれない場合に、デバッグモードでwarningメッセージが表示される場合がある (Fixed(完了))" href="http://redmine.openpne.jp/issues/2325">#2325</a> は下記実装案では問題として発生しないと考えられますが,レビューおよびテストの手がかりとするため,本チケット対応後に同様のステータスに変更します.</p>
<a name="実装案"></a>
<h3 >実装案<a href="#実装案" class="wiki-anchor">¶</a></h3>
<pre>
diff --git a/lib/config/sfOpenPNEApplicationConfiguration.class.php b/lib/config/sfOpenPNEApplicationConfiguration.class.php
index 1de6ab2..37d573a 100644
--- a/lib/config/sfOpenPNEApplicationConfiguration.class.php
+++ b/lib/config/sfOpenPNEApplicationConfiguration.class.php
@@ -19,6 +19,8 @@ abstract class sfOpenPNEApplicationConfiguration extends sfApplicationConfigurat
{
static protected $zendLoaded = false;
+ protected $appRoutings = array();
+
public function initialize()
{
mb_internal_encoding('UTF-8');
@@ -519,4 +521,85 @@ abstract class sfOpenPNEApplicationConfiguration extends sfApplicationConfigurat
parent::setCacheDir($newCacheDir);
}
+
+ public function generateAppUrl($application, $parameters = array(), $absolute = false)
+ {
+ list($route, $parameters) = sfContext::getInstance()->getController()
+ ->convertUrlStringToParameters($parameters);
+
+ return $this->getAppRouting($application)->generate($route, $parameters, $absolute);
+ }
+
+ protected function getAppRouting($application)
+ {
+ if (isset($this->appRoutings[$application]))
+ {
+ return $this->appRoutings[$application];
+ }
+
+ $context = sfContext::getInstance();
+ $configuration = $context->getConfiguration();
+
+ $config = new opRoutingConfigHandler();
+ $currentApp = sfConfig::get('sf_app');
+
+ sfConfig::set('sf_app', $application);
+ $configuration->setAppDir(sfConfig::get('sf_apps_dir').DIRECTORY_SEPARATOR.$application);
+
+ $settings = sfDefineEnvironmentConfigHandler::getConfiguration($configuration->getConfigPaths('config/settings.yml'));
+ $isNoScriptName = !empty($settings['.settings']['no_script_name']);
+
+ $options = $context->getRouting()->getOptions();
+ $url = sfConfig::get('op_base_url');
+ if ('http://example.com' !== $url)
+ {
+ $parts = parse_url($url);
+
+ $parts['path'] = isset($parts['path']) ? $parts['path'] : '';
+ $options['context']['prefix'] = $this->getAppScriptName($application, sfConfig::get('sf_environment'), $parts['path'], $isNoScriptName);
+
+ if (isset($parts['host']))
+ {
+ $options['context']['host'] = $parts['host'];
+ }
+ }
+ else
+ {
+ $path = preg_replace('#/[^/]+\.php$#', '', $options['context']['prefix']);
+ $options['context']['prefix'] = $this->getAppScriptName($application, sfConfig::get('sf_environment'), $path, $isNoScriptName);
+ }
+
+ $routing = new sfPatternRouting($context->getEventDispatcher(), null, $options);
+ $routing->setRoutes($config->evaluate($configuration->getConfigPaths('config/routing.yml')));
+ $context->getEventDispatcher()->notify(new sfEvent($routing, 'routing.load_configuration'));
+
+ sfConfig::set('sf_app', $currentApp);
+ $configuration->setAppDir(sfConfig::get('sf_apps_dir').DIRECTORY_SEPARATOR.$currentApp);
+
+ $this->appRoutings[$application] = $routing;
+
+ return $this->appRoutings[$application];
+ }
+
+ protected function getAppScriptName($application, $env, $prefix, $isNoScriptName = false)
+ {
+ if ($isNoScriptName)
+ {
+ return $prefix;
+ }
+
+ if ('/' === $prefix)
+ {
+ $prefix = '';
+ }
+
+ $name = $prefix.'/'.$application;
+ if ('prod' !== $env)
+ {
+ $name .= '_'.$env;
+ }
+ $name .= '.php';
+
+ return $name;
+ }
}
diff --git a/lib/helper/opUtilHelper.php b/lib/helper/opUtilHelper.php
index 06dc86c..6eb49a9 100644
--- a/lib/helper/opUtilHelper.php
+++ b/lib/helper/opUtilHelper.php
@@ -204,39 +204,7 @@ function _app_url_for_route($application, $routeName, $params = array(), $absolu
function _app_url_for_internal_uri($application, $internal_uri, $absolute = false)
{
- // stores current states
- $current_application = sfContext::getInstance()->getConfiguration()->getApplication();
- $current_environment = sfContext::getInstance()->getConfiguration()->getEnvironment();
- $current_is_debug = sfContext::getInstance()->getConfiguration()->isDebug();
- $current_config = sfConfig::getAll();
-
- // computes a url
- if (sfContext::hasInstance($application))
- {
- $context = sfContext::getInstance($application);
- sfContext::switchTo($application);
- }
- else
- {
- $config = ProjectConfiguration::getApplicationConfiguration($application, $current_environment, $current_is_debug);
- $context = sfContext::createInstance($config, $application);
- }
- $is_strip_script_name = (bool)sfConfig::get('sf_no_script_name');
- $result_url = $context->getController()->genUrl($internal_uri, $absolute);
-
- // restores the previous states
- sfContext::switchTo($current_application);
- sfConfig::add($current_config);
-
- // replaces a script name
- $before_script_name = basename(sfContext::getInstance()->getRequest()->getScriptName());
- $after_script_name = _create_script_name($application, $current_environment);
- if ($is_strip_script_name)
- {
- $before_script_name = '/'.$before_script_name;
- $after_script_name = '';
- }
- return str_replace($before_script_name, $after_script_name, $result_url);
+ return sfContext::getInstance()->getConfiguration()->generateAppUrl($application, $internal_uri, $absolute);
}
function _create_script_name($application, $environment)
</pre>
OpenPNE 3 - Backport(バックポート) #2324: There are wrong URL generating for op_base_url with path name (パス名付きの op_base_url に対して誤った URL 生成をしている箇所がある)
http://redmine.openpne.jp/issues/2324?journal_id=11579
2011-10-10T09:17:06Z
wa ta
watanabe4dgt@gmail.com
<ul><li><strong>ステータス</strong> を <i>Accepted(着手)</i> から <i>Pending Review(レビュー待ち)</i> に変更</li><li><strong>進捗率</strong> を <i>0</i> から <i>50</i> に変更</li></ul><p>更新履歴 <a class="changeset" title="(fixes #2324, BP from #1155 #1577 #1675) fixed that generating URL is not consider of the op_base..." href="http://redmine.openpne.jp/projects/op3/repository/revisions/624162b8675e15160e20a2882003060860239c50">624162b8675e15160e20a2882003060860239c50</a> で適用されました。</p>
OpenPNE 3 - Backport(バックポート) #2324: There are wrong URL generating for op_base_url with path name (パス名付きの op_base_url に対して誤った URL 生成をしている箇所がある)
http://redmine.openpne.jp/issues/2324?journal_id=11608
2011-10-12T07:42:06Z
Minoru Takai
main.coeurl@gmail.com
<ul><li><strong>ステータス</strong> を <i>Pending Review(レビュー待ち)</i> から <i>Pending Testing(テスト待ち)</i> に変更</li><li><strong>進捗率</strong> を <i>50</i> から <i>70</i> に変更</li></ul><blockquote>
<p><a class="issue tracker-4 status-5 priority-5 priority-high3 closed" title="Backport(バックポート): 設定ファイルを記述し忘れた場合に、招待メールに記載されたURLにアクセスできない (Fixed(完了))" href="http://redmine.openpne.jp/issues/2120">#2120</a> <a class="issue tracker-4 status-5 priority-4 priority-default closed" title="Backport(バックポート): OpenPNE.ymlのbase_url にパスが含まれない場合に、デバッグモードでwarningメッセージが表示される場合がある (Fixed(完了))" href="http://redmine.openpne.jp/issues/2325">#2325</a> は本チケットのBP元の実装により発生しうる問題のBPとなるため,本チケットのBP元となる <a class="issue tracker-1 status-5 priority-4 priority-default closed" title="Bug(バグ): There are wrong URL generating for op_base_url with path name (パス名付きの op_base_url に対して誤った URL 生成を... (Fixed(完了))" href="http://redmine.openpne.jp/issues/1155">#1155</a> の実装に <a class="issue tracker-1 status-5 priority-4 priority-default closed" title="Bug(バグ): OpenPNE.ymlのbase_url にパスが含まれない場合に、デバッグモードでwarningメッセージが表示される場合がある (Fixed(完了))" href="http://redmine.openpne.jp/issues/1577">#1577</a> および <a class="issue tracker-1 status-5 priority-5 priority-high3 closed" title="Bug(バグ): 設定ファイルを記述し忘れた場合に、招待メールに記載されたURLにアクセスできない (Fixed(完了))" href="http://redmine.openpne.jp/issues/1675">#1675</a> の実装を含めたものを本チケットの実装案として記述します.具体的には以下のようなものを検討しています.</p>
</blockquote>
<p><a class="issue tracker-4 status-5 priority-5 priority-high3 closed" title="Backport(バックポート): 設定ファイルを記述し忘れた場合に、招待メールに記載されたURLにアクセスできない (Fixed(完了))" href="http://redmine.openpne.jp/issues/2120">#2120</a>, <a class="issue tracker-4 status-5 priority-4 priority-default closed" title="Backport(バックポート): There are wrong URL generating for op_base_url with path name (パス名付きの op_base_url に対して誤った URL 生成を... (Fixed(完了))" href="http://redmine.openpne.jp/issues/2324">#2324</a>, <a class="issue tracker-4 status-5 priority-4 priority-default closed" title="Backport(バックポート): OpenPNE.ymlのbase_url にパスが含まれない場合に、デバッグモードでwarningメッセージが表示される場合がある (Fixed(完了))" href="http://redmine.openpne.jp/issues/2325">#2325</a> に関する修正が、本チケットの修正 <a class="changeset" title="(fixes #2324, BP from #1155 #1577 #1675) fixed that generating URL is not consider of the op_base..." href="http://redmine.openpne.jp/projects/op3/repository/revisions/624162b8675e15160e20a2882003060860239c50">624162b8</a> で全て取り込まれていることを確認しました。</p>
<blockquote>
<p>また,BP元 <a class="issue tracker-1 status-5 priority-4 priority-default closed" title="Bug(バグ): There are wrong URL generating for op_base_url with path name (パス名付きの op_base_url に対して誤った URL 生成を... (Fixed(完了))" href="http://redmine.openpne.jp/issues/1155">#1155</a> ではSSLを考慮したコミットも含まれますが, 3.4 ではSSLは未対応であるため本チケットでは対応しません.</p>
</blockquote>
<p><a class="issue tracker-1 status-5 priority-4 priority-default closed" title="Bug(バグ): There are wrong URL generating for op_base_url with path name (パス名付きの op_base_url に対して誤った URL 生成を... (Fixed(完了))" href="http://redmine.openpne.jp/issues/1155">#1155</a> では 4 個のコミットがされており、2個目から4個目は lib/filter/opExecutionFilter.class.php に対する修正でしたが、このファイルは OpenPNE-3.5.0 で新規追加されたもの <a class="changeset" title="sfOpenPNE を op に変えた" href="http://redmine.openpne.jp/projects/op3/repository/revisions/c1072092ac6bc951015b15c6745f9d5a3e560963">c1072092</a> であり 3.4.x ではその前身となるファイルも存在しないため、2個目から4個目のコミットは 3.4.x 系の対象外と判断できます。</p>
<p>レビューOKです。</p>
OpenPNE 3 - Backport(バックポート) #2324: There are wrong URL generating for op_base_url with path name (パス名付きの op_base_url に対して誤った URL 生成をしている箇所がある)
http://redmine.openpne.jp/issues/2324?journal_id=11614
2011-10-12T08:20:13Z
Mutsumi Imamura
imamura@openpne.jp
<ul><li><strong>ステータス</strong> を <i>Pending Testing(テスト待ち)</i> から <i>Fixed(完了)</i> に変更</li><li><strong>進捗率</strong> を <i>70</i> から <i>100</i> に変更</li></ul><p>動作確認OKです。</p>