Why does thinkphp do this?

Source: Internet
Author: User
Thinkphp is used to do this. the run () method must be used in aspect programming in thinkphp, but this method is strange because the function-defined parameters are not used in the function.
As shown in the following code, I checked the run () method in many behavior classes. almost this parameter is useless. for example, the & $ params parameter in the following code does not appear in the function code, now, you don't need thinkphp to waste this effort? The question is, is thinkphp's excessive behavior hidden !?
Public function run (& $ params) {if (C ('Upgrade _ NOTICE_ON ')&&(! S ('think _ upgrade_interval ') | C ('Upgrade _ NOTICE_DEBUG') {if (IS_SAE & C ('Upgrade _ NOTICE_QUEUE ')&&! Isset ($ _ POST ['think _ upgrade_queque ']) {$ queue = new SaeTaskQueue (C ('Upgrade _ NOTICE_QUEUE'); $ queue-> addTask ('http: //'. $ _ SERVER ['http _ host']. /index. php, 'think _ upgrade_queque = 1'); if (! $ Queue-> push () {trace ('Upgrade reminder queue failed, error cause :'. $ queue-> errmsg (), 'Upgrade notification error', 'notic', true);} return ;}$ akey = C ('Upgrade _ NOTICE_AKEY '); $ skey = C ('Upgrade _ NOTICE_SKEY '); $ this-> accesskey _ = $ akey? $ Akey: (defined ('sae _ ACCESSKEY ')? SAE_ACCESSKEY: ''); $ this-> secretkey _ = $ skey? $ Skey: (defined ('sae _ SECRETKEY ')? SAE_SECRETKEY: ''); $ current_version = C ('Upgrade _ CURRENT_VERSION '); // read interface $ info = $ this-> send (' http://sinaclouds.sinaapp.com/thinkapi/upgrade.php?v= '. $ Current_version); if ($ info ['version']! = $ Current_version) {if ($ this-> send_sms ($ info ['MSG ']) trace ($ info ['MSG'], 'Upgrade notification successful ', 'notic ', true); // send upgrade sms} S ('think _ upgrade_interval', true, C ('Upgrade _ NOTICE_CHECK_INTERVAL '));}}


Reply to discussion (solution)

How do you know you don't need it?

You are talking about tp behavior-driven.

Why is a parameter provided to run. In some cases, a parameter must be provided to the behavior to run properly.

I think it is useless only when I use less.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.