Wick 0.8 in PHP4

Wick Ref: http://codeigniter.com/wiki/Wick/
Matchbox Ref: http://code.google.com/p/matchbox/

ผมพบว่าใน php4 จะมีการพยายามโหลดคลาส Wick สองครั้งครับ
(ผมตั้ง config ให้ autoload libraries Wick)

จริงๆ แล้ว Zacharias Knudsen เค้าบอกว่า Wick มัน php4 compatible นะครับ. ทำให้ผมไม่แน่ใจว่าที่ผมเจอ Error Redeclare นี่เพราะผมแก้ Framework ไปหลายจุดหรือป่าว?

แต่ไม่มีปัญหาครับ Error Redeclare เรื่องเล็กนิดเดียวครับ ก็แค่ดัก If เข้าไปนิดหน่อยก็เรียบร้อย แต่ไม่รู้ว่าจะมีผลต่อ Performance หรือป่าว และ Reliable ?. ในส่วนของ Performance ก็ไม่รู้จะทดสอบอย่างไรเหมือนกัน แต่ผมได้ทำการทดลองใช้งาน $this->load->uri ทั้งใน App และใน Module ซึ่งยังสามารถทำงานได้ปรกติ ก็ถือว่าโอเคครับ (มั้งนะ)

ถ้ามีเวลาเหลือ ผมคงจะหาวิธีแก้ที่สาเหตุ มันจริงๆ อีกทีครับ 🙂

แก้ไขแบบง่ายๆ ครับ  (เติมโค๊ด ๓ ตำแหน่ง)

จุดแรก

[php]if (class_exists('Wick')===FALSE) { // <-- Insert this line (at line 36)[/php]

จุดที่สอง

[php]function Wick ()
{
<span style="color: #0000ff;">static $php4_run_once; // <– Insert this line</span>
<span style="color: #0000ff;">if (isset($php4_run_once)) // <– Insert this line
return; // <– Insert this line
else // <– Insert this line
$php4_run_once = true; // <– Insert this line</span>
$ci = &get_instance();[/php]

จุดที่สาม

[php]} // <-- Insert this line</span>
/* End of file Wick.php */
/* Location: ./system/application/libraries/Wick.php */[/php]

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.