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

_Ex ファイルが存在しない場合は元ファイルのエイリアスを作成する #526

Merged
merged 18 commits into from
Apr 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 4 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,10 @@ jobs:
- run: echo "extension=gd" >> C:/tools/php/php.ini
shell: bash

# see https://github.com/composer/composer/issues/10340
- run: composer selfupdate 2.2.11
if: matrix.php < 7.2

- name: composer install
run: composer install --no-interaction -o

Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"ec-cube2/cli": "dev-master@dev",
"fzaninotto/faker": "^1.8",
"guzzlehttp/guzzle": "^5.3",
"nanasess/ec-cube2-class-extends-stubs": "^1.0",
"nanasess/eccube2-fixture-generator": "dev-main@dev",
"php5friends/phpunit48": ">=4.8.41"
},
Expand Down
36 changes: 35 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion data/__default.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php
exit; // Don't rewrite. This line is rewritten by EC-CUBE.
require_once CLASS_EX_REALDIR . 'page_extends/LC_Page_Ex.php';

/**
* ユーザーカスタマイズ用のページクラス
Expand Down
34 changes: 26 additions & 8 deletions data/class/SC_ClassAutoloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ class SC_ClassAutoloader
/**
* クラスのオートローディング本体
*
* LC_* には対応していない。
* @return void
*/
public static function autoload($class, $plugin_upload_realdir = PLUGIN_UPLOAD_REALDIR)
Expand All @@ -45,7 +44,7 @@ public static function autoload($class, $plugin_upload_realdir = PLUGIN_UPLOAD_R

if (($arrClassNamePart[0] === 'GC' || $arrClassNamePart[0] === 'SC') && $arrClassNamePart[1] === 'Utils') {
$classpath .= $is_ex ? 'util_extends/' : 'util/';
} elseif ($arrClassNamePart[0] === 'SC' && $is_ex === true && $count >= 4) {
} elseif (($arrClassNamePart[0] === 'SC' || $arrClassNamePart[0] === 'LC') && $is_ex === true && $count >= 4) {
$arrClassNamePartTemp = $arrClassNamePart;
// FIXME クラスファイルのディレクトリ命名が変。変な現状に合わせて強引な処理をしてる。
$arrClassNamePartTemp[1] = $arrClassNamePartTemp[1] . '_extends';
Expand Down Expand Up @@ -93,9 +92,14 @@ public static function autoload($class, $plugin_upload_realdir = PLUGIN_UPLOAD_R
$exp = "/(class[ ]+{$plugin_class}[ ]+extends +)[a-zA-Z_\-]+( *{?)/";
$replace = '$1' . $parent_classname . '$2';

$base_class_str = file_get_contents($plugin_classpath);
$base_class_str = str_replace(array('<?php', '?>'), '', $base_class_str);
$base_class_str = preg_replace($exp, $replace, $base_class_str, 1);
if (file_exists($plugin_classpath)) {
$base_class_str = file_get_contents($plugin_classpath);
$base_class_str = str_replace(array('<?php', '?>'), '', $base_class_str);
$base_class_str = preg_replace($exp, $replace, $base_class_str, 1);
} else {
$base_class_str = 'class '.$class.' extends '.$parent_classname.' {}';
}

eval($base_class_str);
} else {
include $plugin_classpath;
Expand All @@ -110,15 +114,29 @@ public static function autoload($class, $plugin_upload_realdir = PLUGIN_UPLOAD_R
if ($is_ex) {
$exp = "/(class[ ]+{$class}[ ]+extends +)[a-zA-Z_\-]+( *{?)/";
$replace = '$1' . $parent_classname . '$2';
$base_class_str = file_get_contents($classpath);
$base_class_str = str_replace(array('<?php', '?>'), '', $base_class_str);
$base_class_str = preg_replace($exp, $replace, $base_class_str, 1);

if (file_exists($classpath)) {
$base_class_str = file_get_contents($classpath);
$base_class_str = str_replace(array('<?php', '?>'), '', $base_class_str);
$base_class_str = preg_replace($exp, $replace, $base_class_str, 1);
} else {
$base_class_str = 'class '.$class.' extends '.$parent_classname.' {}';
}

eval($base_class_str);

return;
}
}
}

if ($is_ex) {
// *_Ex ファイルが存在しない場合は、元クラスのエイリアスとする
if (!file_exists($classpath) && strpos($class, '_Ex') !== false) {
class_alias(preg_replace('/_Ex$/', '', $class), $class);
}
}

if (file_exists($classpath)) {
include $classpath;
} else {
Expand Down
1 change: 0 additions & 1 deletion data/class/api/operations/AddrFromZip.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
* @author EC-CUBE CO.,LTD.
* @version $Id$
*/
require_once CLASS_EX_REALDIR . 'api_extends/SC_Api_Abstract_Ex.php';

class API_AddrFromZip extends SC_Api_Abstract_Ex
{
Expand Down
1 change: 0 additions & 1 deletion data/class/api/operations/BrowseNodeLookup.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
* @author EC-CUBE CO.,LTD.
* @version $Id$
*/
require_once CLASS_EX_REALDIR . 'api_extends/SC_Api_Abstract_Ex.php';

class API_BrowseNodeLookup extends SC_Api_Abstract_Ex
{
Expand Down
1 change: 0 additions & 1 deletion data/class/api/operations/CartAdd.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
* @author EC-CUBE CO.,LTD.
* @version $Id$
*/
require_once CLASS_EX_REALDIR . 'api_extends/SC_Api_Abstract_Ex.php';

class API_CartAdd extends SC_Api_Abstract_Ex
{
Expand Down
1 change: 0 additions & 1 deletion data/class/api/operations/CartClear.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
* @author EC-CUBE CO.,LTD.
* @version $Id$
*/
require_once CLASS_EX_REALDIR . 'api_extends/SC_Api_Abstract_Ex.php';

class API_CartClear extends SC_Api_Abstract_Ex
{
Expand Down
1 change: 0 additions & 1 deletion data/class/api/operations/CartCreate.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
* @author EC-CUBE CO.,LTD.
* @version $Id$
*/
require_once CLASS_EX_REALDIR . 'api_extends/SC_Api_Abstract_Ex.php';

class API_CartCreate extends SC_Api_Abstract_Ex
{
Expand Down
1 change: 0 additions & 1 deletion data/class/api/operations/CartGet.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
* @author EC-CUBE CO.,LTD.
* @version $Id$
*/
require_once CLASS_EX_REALDIR . 'api_extends/SC_Api_Abstract_Ex.php';

class API_CartGet extends SC_Api_Abstract_Ex
{
Expand Down
1 change: 0 additions & 1 deletion data/class/api/operations/CartModify.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
* @author EC-CUBE CO.,LTD.
* @version $Id$
*/
require_once CLASS_EX_REALDIR . 'api_extends/SC_Api_Abstract_Ex.php';

class API_CartModify extends SC_Api_Abstract_Ex
{
Expand Down
1 change: 0 additions & 1 deletion data/class/api/operations/Default.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
* @author EC-CUBE CO.,LTD.
* @version $Id$
*/
require_once CLASS_EX_REALDIR . 'api_extends/SC_Api_Abstract_Ex.php';

class API_Default extends SC_Api_Abstract_Ex
{
Expand Down
1 change: 0 additions & 1 deletion data/class/api/operations/GetVersion.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
* @author EC-CUBE CO.,LTD.
* @version $Id$
*/
require_once CLASS_EX_REALDIR . 'api_extends/SC_Api_Abstract_Ex.php';

class API_GetVersion extends SC_Api_Abstract_Ex
{
Expand Down
1 change: 0 additions & 1 deletion data/class/api/operations/ItemLookup.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
* @author EC-CUBE CO.,LTD.
* @version $Id$
*/
require_once CLASS_EX_REALDIR . 'api_extends/SC_Api_Abstract_Ex.php';

class API_ItemLookup extends SC_Api_Abstract_Ex
{
Expand Down
1 change: 0 additions & 1 deletion data/class/api/operations/ItemSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
* @author EC-CUBE CO.,LTD.
* @version $Id$
*/
require_once CLASS_EX_REALDIR . 'api_extends/SC_Api_Abstract_Ex.php';

class API_ItemSearch extends SC_Api_Abstract_Ex
{
Expand Down
1 change: 0 additions & 1 deletion data/class/helper/SC_Helper_HandleError.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,6 @@ public static function displaySystemError($errstr = null)

ob_clean();

require_once CLASS_EX_REALDIR . 'page_extends/error/LC_Page_Error_SystemError_Ex.php';
$objPage = new LC_Page_Error_SystemError_Ex();
$objPage->init();
if (isset($errstr)) {
Expand Down
1 change: 0 additions & 1 deletion data/class/pages/LC_Page_Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/

require_once CLASS_EX_REALDIR . 'page_extends/LC_Page_Ex.php';

/**
* Index のページクラス.
Expand Down
1 change: 0 additions & 1 deletion data/class/pages/LC_Page_InputZip.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/

require_once CLASS_EX_REALDIR . 'page_extends/LC_Page_Ex.php';

/**
* 郵便番号入力 のページクラス.
Expand Down
1 change: 0 additions & 1 deletion data/class/pages/LC_Page_ResizeImage.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/

require_once CLASS_EX_REALDIR . 'page_extends/LC_Page_Ex.php';

/**
* リサイズイメージ のページクラス.
Expand Down
1 change: 0 additions & 1 deletion data/class/pages/LC_Page_Sitemap.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/

require_once CLASS_EX_REALDIR . 'page_extends/LC_Page_Ex.php';

/**
* Sitemapプロトコル ファイル生成モジュール.
Expand Down
1 change: 0 additions & 1 deletion data/class/pages/abouts/LC_Page_Abouts.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/

require_once CLASS_EX_REALDIR . 'page_extends/LC_Page_Ex.php';

/**
* サイト概要のページクラス.
Expand Down
1 change: 0 additions & 1 deletion data/class/pages/admin/LC_Page_Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/

require_once CLASS_EX_REALDIR . 'page_extends/LC_Page_Ex.php';

/**
* 管理者ログイン のページクラス.
Expand Down
1 change: 0 additions & 1 deletion data/class/pages/admin/LC_Page_Admin_Home.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/

require_once CLASS_EX_REALDIR . 'page_extends/admin/LC_Page_Admin_Ex.php';

/**
* 管理画面ホーム のページクラス.
Expand Down
1 change: 0 additions & 1 deletion data/class/pages/admin/LC_Page_Admin_Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/

require_once CLASS_EX_REALDIR . 'page_extends/admin/LC_Page_Admin_Ex.php';

/**
* 管理者ログイン のページクラス.
Expand Down
1 change: 0 additions & 1 deletion data/class/pages/admin/LC_Page_Admin_Logout.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/

require_once CLASS_EX_REALDIR . 'page_extends/admin/LC_Page_Admin_Ex.php';

/**
* ログアウト のページクラス.
Expand Down
1 change: 0 additions & 1 deletion data/class/pages/admin/basis/LC_Page_Admin_Basis.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/

require_once CLASS_EX_REALDIR . 'page_extends/admin/LC_Page_Admin_Ex.php';

/**
* 店舗基本情報 のページクラス.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/

require_once CLASS_EX_REALDIR . 'page_extends/admin/LC_Page_Admin_Ex.php';

/**
* 配送方法設定 のページクラス.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/

require_once CLASS_EX_REALDIR . 'page_extends/admin/LC_Page_Admin_Ex.php';

/**
* 配送方法設定 のページクラス.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/

require_once CLASS_EX_REALDIR . 'page_extends/admin/LC_Page_Admin_Ex.php';

/**
* 定休日管理のページクラス.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/

require_once CLASS_EX_REALDIR . 'page_extends/admin/LC_Page_Admin_Ex.php';

/**
* 会員規約設定 のページクラス.
Expand Down
1 change: 0 additions & 1 deletion data/class/pages/admin/basis/LC_Page_Admin_Basis_Mail.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/

require_once CLASS_EX_REALDIR . 'page_extends/admin/LC_Page_Admin_Ex.php';

/**
* メール設定 のページクラス.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/

require_once CLASS_EX_REALDIR . 'page_extends/admin/LC_Page_Admin_Ex.php';

/**
* 支払方法設定 のページクラス.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/

require_once CLASS_EX_REALDIR . 'page_extends/admin/LC_Page_Admin_Ex.php';

/**
* 支払方法設定 のページクラス.
Expand Down
1 change: 0 additions & 1 deletion data/class/pages/admin/basis/LC_Page_Admin_Basis_Point.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/

require_once CLASS_EX_REALDIR . 'page_extends/admin/LC_Page_Admin_Ex.php';

/**
* ポイント設定 のページクラス.
Expand Down
1 change: 0 additions & 1 deletion data/class/pages/admin/basis/LC_Page_Admin_Basis_Tax.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/

require_once CLASS_EX_REALDIR . 'page_extends/admin/LC_Page_Admin_Ex.php';

/**
* 税率設定 のページクラス.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/

require_once CLASS_EX_REALDIR . 'page_extends/admin/LC_Page_Admin_Ex.php';

/**
* 特定商取引法 のページクラス.
Expand Down
Loading