草庐IT

php - CakePHP 1.3 - 蛋糕库中的无限循环、Apache 崩溃、 session 助手和 __start()?

coder 2024-04-08 原文

将 session 助手添加到应用程序 Controller 后,Apache 开始崩溃。我已经通过日志记录的方式跟踪了问题,发现在/CORE/cake/libs/controller/component/session 中,函数 check() 开始运行一次但没有完成。但是,它调用的函数 __start() 会无限运行(至少直到 Apache 崩溃为止)。无限运行是指整个 __start() 函数一直运行多次。同样,一旦我在应用程序 Controller 中添加 session 助手,就会发生这种情况。没有它,Cake 似乎运行良好,直到我达到在 View 中使用 session 助手的地步。该系统正在从 Cake 1.1 升级,在 Cake 1.1 中, session 助手被自动包含并运行良好。我在 Cake 1.3.7 和 Cake 1.3.15 上都尝试过,结果相同。我猜 session 设置与 Cake 1.3 做事的方式有冲突。下面是我的 config/core 文件,来自 Apache 的崩溃信息,以及崩溃前的 Apache 日志。如果任何其他信息有帮助,请在评论中告诉我。任何建议如何解决这个问题?谢谢!

编辑:我忘了包含相关的 discussion here .不幸的是,他们在这里没有明确的解决方案,但他们似乎想修复蛋糕中的错误,我很乐意更改我的代码以避免错误。

编辑 2:我最近发现这个项目的经理计划在未来停止使用数据库 session ,这样就完全解决了我的问题。当然,我会将这个问题留给 future 的访问者。

应用程序/配置/core.php:

<?php
/**
 * This is core configuration file.
 *
 * Use it to configure core behavior of Cake.
 *
 * PHP versions 4 and 5
 *
 * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
 * Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
 *
 * Licensed under The MIT License
 * Redistributions of files must retain the above copyright notice.
 *
 * @copyright     Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
 * @link          http://cakephp.org CakePHP(tm) Project
 * @package       cake
 * @subpackage    cake.app.config
 * @since         CakePHP(tm) v 0.2.9
 * @license       MIT License (http://www.opensource.org/licenses/mit-license.php)
 */

/**
 * CakePHP Debug Level:
 *
 * Production Mode:
 *  0: No error messages, errors, or warnings shown. Flash messages redirect.
 *
 * Development Mode:
 *  1: Errors and warnings shown, model caches refreshed, flash messages halted.
 *  2: As in 1, but also with full debug messages and SQL output.
 *
 * In production mode, flash messages redirect after a time interval.
 * In development mode, you need to click the flash message to continue.
 */
    //Configure::write('debug', 2);

/**
 * CakePHP Log Level:
 *
 * In case of Production Mode CakePHP gives you the possibility to continue logging errors.
 *
 * The following parameters can be used:
 *  Boolean: Set true/false to activate/deactivate logging
 *    Configure::write('log', true);
 *
 *  Integer: Use built-in PHP constants to set the error level (see error_reporting)
 *    Configure::write('log', E_ERROR | E_WARNING);
 *    Configure::write('log', E_ALL ^ E_NOTICE);
 */
    //Configure::write('log', true);

/**
 * Application wide charset encoding
 */
    //Configure::write('App.encoding', 'UTF-8');

/**
 * To configure CakePHP *not* to use mod_rewrite and to
 * use CakePHP pretty URLs, remove these .htaccess
 * files:
 *
 * /.htaccess
 * /app/.htaccess
 * /app/webroot/.htaccess
 *
 * And uncomment the App.baseUrl below:
 */
    //Configure::write('App.baseUrl', env('SCRIPT_NAME'));

/**
 * Uncomment the define below to use CakePHP prefix routes.
 *
 * The value of the define determines the names of the routes
 * and their associated controller actions:
 *
 * Set to an array of prefixes you want to use in your application. Use for
 * admin or other prefixed routes.
 *
 *  Routing.prefixes = array('admin', 'manager');
 *
 * Enables:
 *  `admin_index()` and `/admin/controller/index`
 *  `manager_index()` and `/manager/controller/index`
 *
 * [Note Routing.admin is deprecated in 1.3.  Use Routing.prefixes instead]
 */
    //Configure::write('Routing.prefixes', array('admin'));

/**
 * Turn off all caching application-wide.
 *
 */
    //Configure::write('Cache.disable', true);

    define('DEBUG', 2);
    define('DEBUG_AJAX', true);
/**
 * Enable cache checking.
 *
 * If set to true, for view caching you must still use the controller
 * var $cacheAction inside your controllers to define caching settings.
 * You can either set it controller-wide by setting var $cacheAction = true,
 * or in each action using $this->cacheAction = true.
 *
 */
    Configure::write('Cache.check', false);

/**
 * Defines the default error type when using the log() function. Used for
 * differentiating error logging and debugging. Currently PHP supports LOG_DEBUG.
 */
    define('LOG_ERROR', 2);

/**
 * The preferred session handling method. Valid values:
 *
 * 'php'            Uses settings defined in your php.ini.
 * 'cake'       Saves session files in CakePHP's /tmp directory.
 * 'database'   Uses CakePHP's database sessions.
 *
 * To define a custom session handler, save it at /app/config/<name>.php.
 * Set the value of 'Session.save' to <name> to utilize it in CakePHP.
 *
 * To use database sessions, run the app/config/schema/sessions.php schema using
 * the cake shell command: cake schema create Sessions
 *
 */
    Configure::write('Session.save', 'database');

/**
 * The model name to be used for the session model.
 *
 * 'Session.save' must be set to 'database' in order to utilize this constant.
 *
 * The model name set here should *not* be used elsewhere in your application.
 */
    Configure::write('Session.model', 'Session');

/**
 * The name of the table used to store CakePHP database sessions.
 *
 * 'Session.save' must be set to 'database' in order to utilize this constant.
 *
 * The table name set here should *not* include any table prefix defined elsewhere.
 *
 * Please note that if you set a value for Session.model (above), any value set for
 * Session.table will be ignored.
 *
 * [Note: Session.table is deprecated as of CakePHP 1.3]
 */
    Configure::write('Session.table', 'cake_sessions');

/**
 * The DATABASE_CONFIG::$var to use for database session handling.
 *
 * 'Session.save' must be set to 'database' in order to utilize this constant.
 */
    Configure::write('Session.database', 'default');

/**
 * The name of CakePHP's session cookie.
 *
 * Note the guidelines for Session names states: "The session name references
 * the session id in cookies and URLs. It should contain only alphanumeric
 * characters."
 * @link http://php.net/session_name
 */
    Configure::write('Session.cookie', 'CAKEPHP');

/**
 * Session time out time (in seconds).
 * Actual value depends on 'Security.level' setting.
 */
    Configure::write('Session.timeout', '120');

/**
 * If set to false, sessions are not automatically started.
 */
    Configure::write('Session.start', true);

/**
 * When set to false, HTTP_USER_AGENT will not be checked
 * in the session. You might want to set the value to false, when dealing with
 * older versions of IE, Chrome Frame or certain web-browsing devices and AJAX
 */
    Configure::write('Session.checkAgent', true);

/**
 * The level of CakePHP security. The session timeout time defined
 * in 'Session.timeout' is multiplied according to the settings here.
 * Valid values:
 *
 * 'high'   Session timeout in 'Session.timeout' x 10
 * 'medium' Session timeout in 'Session.timeout' x 100
 * 'low'    Session timeout in 'Session.timeout' x 300
 *
 * CakePHP session IDs are also regenerated between requests if
 * 'Security.level' is set to 'high'.
 */
    Configure::write('Security.level', 'low');

/**
 * A random string used in security hashing methods.
 */
    Configure::write('Security.salt', 'DYhG93b0qyJfIxfs2guVoUubWwvniR2G0FgaC9mi');

/**
 * A random numeric string (digits only) used to encrypt/decrypt strings.
 */
    Configure::write('Security.cipherSeed', '76859309657453542496749683645');

/**
 * Apply timestamps with the last modified time to static assets (js, css, images).
 * Will append a querystring parameter containing the time the file was modified. This is
 * useful for invalidating browser caches.
 *
 * Set to `true` to apply timestamps, when debug = 0, or set to 'force' to always enable
 * timestamping.
 */
    //Configure::write('Asset.timestamp', true);
/**
 * Compress CSS output by removing comments, whitespace, repeating tags, etc.
 * This requires a/var/cache directory to be writable by the web server for caching.
 * and /vendors/csspp/csspp.php
 *
 * To use, prefix the CSS link URL with '/ccss/' instead of '/css/' or use HtmlHelper::css().
 */
    //Configure::write('Asset.filter.css', 'css.php');

/**
 * Plug in your own custom JavaScript compressor by dropping a script in your webroot to handle the
 * output, and setting the config below to the name of the script.
 *
 * To use, prefix your JavaScript link URLs with '/cjs/' instead of '/js/' or use JavaScriptHelper::link().
 */
    //Configure::write('Asset.filter.js', 'custom_javascript_output_filter.php');

/**
 * The classname and database used in CakePHP's
 * access control lists.
 */
    Configure::write('Acl.classname', 'DbAcl');
    Configure::write('Acl.database', 'default');

/**
 * If you are on PHP 5.3 uncomment this line and correct your server timezone
 * to fix the date & time related errors.
 */
    //date_default_timezone_set('UTC');

/**
 *
 * Cache Engine Configuration
 * Default settings provided below
 *
 * File storage engine.
 *
 *   Cache::config('default', array(
 *      'engine' => 'File', //[required]
 *      'duration'=> 3600, //[optional]
 *      'probability'=> 100, //[optional]
 *      'path' => CACHE, //[optional] use system tmp directory - remember to use absolute path
 *      'prefix' => 'cake_', //[optional]  prefix every cache file with this string
 *      'lock' => false, //[optional]  use file locking
 *      'serialize' => true, [optional]
 *  ));
 *
 *
 * APC (http://pecl.php.net/package/APC)
 *
 *   Cache::config('default', array(
 *      'engine' => 'Apc', //[required]
 *      'duration'=> 3600, //[optional]
 *      'probability'=> 100, //[optional]
 *      'prefix' => Inflector::slug(APP_DIR) . '_', //[optional]  prefix every cache file with this string
 *  ));
 *
 * Xcache (http://xcache.lighttpd.net/)
 *
 *   Cache::config('default', array(
 *      'engine' => 'Xcache', //[required]
 *      'duration'=> 3600, //[optional]
 *      'probability'=> 100, //[optional]
 *      'prefix' => Inflector::slug(APP_DIR) . '_', //[optional] prefix every cache file with this string
 *      'user' => 'user', //user from xcache.admin.user settings
 *      'password' => 'password', //plaintext password (xcache.admin.pass)
 *  ));
 *
 *
 * Memcache (http://www.danga.com/memcached/)
 *
 *   Cache::config('default', array(
 *      'engine' => 'Memcache', //[required]
 *      'duration'=> 3600, //[optional]
 *      'probability'=> 100, //[optional]
 *      'prefix' => Inflector::slug(APP_DIR) . '_', //[optional]  prefix every cache file with this string
 *      'servers' => array(
 *          '127.0.0.1:11211' // localhost, default port 11211
 *      ), //[optional]
 *      'compress' => false, // [optional] compress data in Memcache (slower, but uses less memory)
 *  ));
 *
 */
    Cache::config('default', array('engine' => 'File'));

/**
 * This is the URL at which your working copy
 * is accessed -- no trailing forward slash
 */
        define('BIRT_REPORT_BASE_URL', '');

/**
 * This is the directory to which BIRT has
 * permission to write files during graphing
 */
        define('BIRT_REPORT_WRITABLE_IMAGE_DIR', '');

Apache 崩溃:

Problem signature:
  Problem Event Name:   APPCRASH
  Application Name: httpd.exe
  Application Version:  2.2.11.0
  Application Timestamp:    493f5d44
  Fault Module Name:    php5ts.dll
  Fault Module Version: 5.2.9.9
  Fault Module Timestamp:   49a56925
  Exception Code:   c00000fd
  Exception Offset: 001a049d
  OS Version:   6.1.7601.2.1.0.768.3
  Locale ID:    1033
  Additional Information 1: 8278
  Additional Information 2: 82782538381a8681201b9137311ac754
  Additional Information 3: 9f8d
  Additional Information 4: 9f8d09670f894d997bbbca5236befa87

Apache 错误日志:

[Fri Apr 19 10:52:01 2013] [notice] Apache/2.2.11 (Win32) DAV/2 mod_ssl/2.2.11 OpenSSL/0.9.8i PHP/5.2.9 configured -- resuming normal operations
[Fri Apr 19 10:52:01 2013] [notice] Server built: Dec 10 2008 00:10:06
[Fri Apr 19 10:52:01 2013] [notice] Parent: Created child process 7024
[Fri Apr 19 10:52:02 2013] [notice] Digest: generating secret for digest authentication ...
[Fri Apr 19 10:52:02 2013] [notice] Digest: done
[Fri Apr 19 10:52:03 2013] [notice] Child 7024: Child process is running
[Fri Apr 19 10:52:03 2013] [notice] Child 7024: Acquired the start mutex.
[Fri Apr 19 10:52:03 2013] [notice] Child 7024: Starting 250 worker threads.
[Fri Apr 19 10:52:03 2013] [notice] Child 7024: Starting thread to listen on port 443.
[Fri Apr 19 10:52:03 2013] [notice] Child 7024: Starting thread to listen on port 80.

最佳答案

我找到了一个允许数据库版本的 session 工作的解决方法。这不是一个修复,但它可能适用于我的情况,尽管真正的修复仍然是首选。

解决方法是关闭代理检查:

Configure::write('Session.checkAgent', false);

关于php - CakePHP 1.3 - 蛋糕库中的无限循环、Apache 崩溃、 session 助手和 __start()?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16107483/

有关php - CakePHP 1.3 - 蛋糕库中的无限循环、Apache 崩溃、 session 助手和 __start()?的更多相关文章

  1. 叮咚买菜基于 Apache Doris 统一 OLAP 引擎的应用实践 - 2

    导读:随着叮咚买菜业务的发展,不同的业务场景对数据分析提出了不同的需求,他们希望引入一款实时OLAP数据库,构建一个灵活的多维实时查询和分析的平台,统一数据的接入和查询方案,解决各业务线对数据高效实时查询和精细化运营的需求。经过调研选型,最终引入ApacheDoris作为最终的OLAP分析引擎,Doris作为核心的OLAP引擎支持复杂地分析操作、提供多维的数据视图,在叮咚买菜数十个业务场景中广泛应用。作者|叮咚买菜资深数据工程师韩青叮咚买菜创立于2017年5月,是一家专注美好食物的创业公司。叮咚买菜专注吃的事业,为满足更多人“想吃什么”而努力,通过美好食材的供应、美好滋味的开发以及美食品牌的孵

  2. ruby-on-rails - Rails 优雅地处理超时 session ? - 2

    使用rails4,ruby2。我在rails配置中为我的cookiesession设置了30分钟的超时时间。问题是,如果我转到表单,让session超时,然后提交表单,我会收到此ActionController::InvalidAuthenticityToken错误。如何在Rails中优雅地处理这个错误?比如说,重定向到登录屏幕? 最佳答案 在您的ApplicationController:rescue_fromActionController::InvalidAuthenticityTokendoredirect_tosome_p

  3. ruby - Hanami link_to 助手只呈现最后一个元素 - 2

    我是HanamiWorld的新人。我已经写了这段代码:moduleWeb::Views::HomeclassIndexincludeWeb::ViewincludeHanami::Helpers::HtmlHelperdeftitlehtml.headerdoh1'Testsearchengine',id:'title'hrdiv(id:'test')dolink_to('Home',"/",class:'mnu_orizontal')link_to('About',"/",class:'mnu_orizontal')endendendendend我在模板上调用了title方法。htm

  4. ruby-on-rails - 为什么在 Rails 5.1.1 中删除了 session 存储初始化程序 - 2

    我去了这个website查看Rails5.0.0和Rails5.1.1之间的区别为什么5.1.1不再包含:config/initializers/session_store.rb?谢谢 最佳答案 这是删除它的提交:Setupdefaultsessionstoreinternally,nolongerthroughanapplicationinitializer总而言之,新应用没有该初始化器,session存储默认设置为cookie存储。即与在该初始值设定项的生成版本中指定的值相同。 关于

  5. ruby - Sinatra session 未按预期持续 - 2

    我正在尝试使用Sinatra中的重定向和session在网站周围传递一些数据。这是一个简化的示例,使用PrettyPrint进行调试:require'pp'require'rubygems'require'sinatra'enable:sessionsget'/'dosession[:foo]='12345'puts'session1'ppsessionredirectto('/redir')endget'/redir'doputs'session2'ppsession'helloworld'end查看Thin的输出,我看到:>>Listeningon0.0.0.0:4567,CTRL

  6. ruby-on-rails - 将 Rails 路由助手作为类方法添加到类中 - 2

    我如何将像“root_path”这样的Rails路由助手作为类方法添加到像my_model.rb这样的类中?所以我的课是这样的:ClassMyModeldefself.fooreturnself.root_pathendendMyModel.foo以上不起作用,因为ClassMyModel不响应root_path这是我所知道的:我可以使用includeRails.application.routes.url_helpers,但这只会将模块的方法添加为实例方法我试过扩展Rails.application.routes.url_helpers但它没用请随时给我上课:)

  7. ruby 私有(private)类方法助手 - 2

    您好,我正在尝试创建一个帮助程序,用于将ruby​​方法大量定义为私有(private)类方法。通常,可以通过使用private_class_method键工作将方法定义为私有(private)类方法。但我想创建一个以下样式的助手:classPersondefine_private_class_methodsdodefmethod_oneenddefmethod_twoendendend我计划通过以下方式动态定义它,但根本不起作用:classObjectdefself.define_private_class_methods&blockinstance_evaldoprivate&bl

  8. ruby-on-rails - RSpec 应用程序助手测试 : Undefined local variable or method `helper` - 2

    有一段时间这似乎是一个闪烁的错误,但现在它一直出现:当我在一个相当简单的ApplicationHelper规范上运行RSpec时,我得到以下错误:%rspec--backtrace1)ApplicationHelperrendersMarkdownfromplaintextFailure/Error:expect(helper.md(plaintext)).toeq("Header\n")NameError:undefinedlocalvariableormethod`helper'for##/Users/danielsh/.rvm/gems/ruby-2.1.1@project-st

  9. ruby-on-rails - 这个 C 和 PHP 程序员如何学习 Ruby 和 Rails? - 2

    按照目前的情况,这个问题不适合我们的问答形式。我们希望答案得到事实、引用或专业知识的支持,但这个问题可能会引发辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visitthehelpcenter指导。关闭9年前。我来自C、php和bash背景,很容易学习,因为它们都有相同的C结构,我可以将其与我已经知道的联系起来。然后2年前我学了Python并且学得很好,Python对我来说比Ruby更容易学。然后从去年开始,我一直在尝试学习Ruby,然后是Rails,我承认,直到现在我还是学不会,讽刺的是那些打着简单易学的烙印,但是对于我这样一个老练的程序员来说,我只是无法将它

  10. ruby - 如何强制 Rack :session + sinatra to read "rack.session" from params instead of cookies - 2

    我正在处理oauth1.0(twitter和flickr)。网站工作在80端口,oauth服务器工作在8080端口算法:向oauth服务器发送ajax请求以检查用户是否有有效的access_token如果用户没有access_token或access_token已过期,则打开授权窗口在oauth服务器的用户session中保存access_token发送分享数据到oauth服务器它使用sinatra+rack:session+rack::session::sequel+sqlite来存储session。它在每个响应中发送Set-Cookie:rack.session=id我正在使用2种

随机推荐