Tag Archives: PHP

phpBB is Dead, Long Live FUDForum (or at least SMF)

March 20, 2007 Update: I’m going to post an update on this that should hopefully better state what I meant when I first wrote this article and better review of the latest beta version. Hopefully it is better organized with better clarity than this ranting and ungrateful (to the many developers of phpBB that slaved many hours to make phpBB the way it is) post. I apologize for the insensitivity of this post and for the FUD contained within.

phpBB Problems

The development of phpBB 3 has been past due for a long time. In my humble and not so educated opinion, it has faded (or if it hasn’t already, it will fade) into obscurity. The phpBB 2.x development line has been overtaken by other forum projects, including better security in their package. SMF offers many of the features that will appear in phpBB 3 and also offers phpBB ease of installation and use.

I should point out that I hated the predecessor of SMF. SMF is the golden son and I wish the developers the best. SMF does lack proper naming standards, or could use better established ones. I thought that “register1()” and “register2()” were horrible names for functions, but then I looked at the sign in functions and shouldn’t say I was surprised when I seen that they were named “signin1()” and “signin2()”. A correction, these are probably only two examples out of the ten; the rest of the functions properly describe the action.

I won’t say anything of SMF procedural usage, because I think it suits it well.

phpBB 3

The next version of phpBB does include a lot of features that have been missing from the 2.x line. It still doesn’t answer the question of whether phpBB 4 would take 2 or 3 years to add other major features.

SMF already has the advantage, because it includes those features that I already look for. While phpBB does offer features that SMF doesn’t, it wouldn’t take SMF long to include those features and include features that phpBB won’t have until the next branch.

Sadly, phpBB suffers from the “not developed here” paradigm. The push currently is for packages to include User integration and phpBB (Beta 1) doesn’t include those and is “locked in” to the user table. It may take several years before that is added and by then the user evolution might go from decentralized user authentication (like OpenID). I don’t think phpBB would be able to keep up with the evolution of user needs and other forum packages.

Whether phpBB 3 kicks major ass, will depend on the final version. The feature set looks to be damn good one with emphasis on security.

FUDforum

I remember a saying that either an open source package is easy and missing features and/or security or it is secure but missing ease of use. FUDforum reminded of that. One thing you can say of SMF and phpBB is that administation is easy. However, I can only see the developers improving that, but it is something that will keep me from totally replacing SMF with it on other projects.

Damn good Integration

The reason I used FUDforum, was that the project leader demanded forum integration, so I had to find a forum that could replace the crappy internal one. I already developed my own message board and I have no interest in supporting another. I’ll recommend coding a forum to anyone, but for education purposes only! The thought of using something that probably wasn’t even developed for a month over something that has been developed for more than two years is crazy and may I say, “Stupid”?.

This is probably one of the few times, where I’ll say focus should be on the project, and not on a component as large as a forum. SMF does include SSI integration, but I’m not looking for that method. FUDForum includes APIs for external user integration and forum integration. Which are both required for the project. I can forgive FUDforum for making my life a whole lot easier.

A look at the user importer: (Please note: The reference to the connection isn’t needed, but I’ve had problems before with separate connections and this was a precaution against any bugs.)

< ?php
$userDB = mysql_connect($host, $username,$password);
mysql_select_db($database_name, $userDB);

$userQuery = mysql_query("SELECT * FROM BETA_PLAYER", $userDB);

require realpath(dirname(__FILE__).'/../../FUDforum/scripts/fudapi.inc.php');

while($row = mysql_fetch_assoc($userQuery))
{
    $fetch = array();
    $fetch['id'] = $row['forum_id'];
    $isImportedQuery = fud_fetch_user($fetch); // Passing just the array seems to work.

    if(empty($isImportedQuery)) {
        // Build User
        $vals['login'] = $row['username'];
        $vals['passwd'] = $row['password']; // Lucky (??) The passwords weren't encrypted (!!!).
        $vals['email'] = $row['email'];
        $vals['name'] = 'John Doe';   // Names are required, but project user table doesn't has them.
        $vals['alias'] = $row['display_name'];

        $id = fud_add_user($vals, $error);    // Store return id for project user table.

        if($id != 0 and empty($error)) {
            // The project user id is different from the forum id, and for signing in,
            // it is stored in the project user table.
            mysql_query("UPDATE BETA_PLAYER SET forum_id=$id WHERE id=$row[id]", $userDB);
            echo "$row[username] has been added... $id<br />\n";    // For debugging

        }
    }
}

Much love for making, what would normally be a long complicated testing process, into a short script that works perfectly the first time. The same can’t be said about FlashChat user integration that might fall apart if any one just blows on it. Letting the package manage the user instead is a far less painful experience, which is counter-intuitive.

Possibly Related Posts:


MySQL Database Mirroring: When Automatic Backups Fail

Back Story

Yes, my blog has been down for the past week or so. So what. That isn’t quite the issue, but it did give me quite a bit of reflection about past projects, besides the general confusion of why the database started to act up. This isn’t a rant about MySQL, because the blame is completely on me. Stuff happens and I really should have been more prepared.

———————-

Does anyone know why in a database you can sort of half-assed connect to, gather a few SELECT statements, but can’t dump (using mysqldump) or do any intensive SQL work? Also giving some user has too many connections error, when there are only one or two (accurate) connections.

Database Mirroring

It occurred to me in my darkest hour that if only I had a backup database that there wouldn’t have been any down time. Of course, if I had a hard backup on my computer there would only have been a few hours to a day or so of downtime. However, no downtime would have been just fine for other projects.

However, while I was contemplating this “genious” idea, a few flaws kept nagging me.

  • Redundancy is best done at the physical layer and this would be at the application layer.
  • It would be insane to keep up-to-date copies and it would be pointless to have something that would already be outdated
  • Keeping two or more backup copies is a good thing, generally. Sigh, if only I had a backup.

For research purposes, I’m going to try to implement this on another project and see how well it works (or doesn’t work). It would be fun to try different methods of wrongly implementing it.

Well, there is one reason to have this and it would be mainly for “shared” users, who are able to spare an extra database or two, who don’t have access to the hardware for clustering and hard drive mirroring. However, the problem I did have was a strange one and I could have used this method.

Self Restoration

It would be even better if perhaps, the database access layer could tell that the database was no good and then try to use a separate one. After it found a better database that it had permissions for, it could use the mysqldump file to restore itself and then retry.

Most of the projects I’ve worked with, it would take several minutes to reload the database tables, so it would be a short wait. It would make sense to display a message, like the one WordPress gave when the database could no longer be accessed, until it could restore itself.

I very much like the idea of displaying database and updating messages to visitors and site webmasters. It gives a better notice of what is going on, then just displaying a PHP error.

Conclusion

Really, this is just a case of denial and avoiding the main point of keeping secondary backups on your hard drive.

I’ll tell you one thing, I spent many hours ordering my family picture gallery and I’ll be damned if I’m going to spend that time again. As well as I was in the process or moving some of the posts to a wiki, where they would be better suited. As much as I hate writting stuff again, I did spend enough time on my own trying to get back the data.

Possibly Related Posts:


What I would like to see in PHP 7

A simple list of assorted ranting. It should be noted that some of the list is already possible, but would rather they be part of the core.

  • Better Design By Contract Support (possible now)
  • Native Object Types (SPL Types?)
  • Better and more consistent security
    1. Built-in nonces (PECL extension?)
    2. OpenID as PECL extension
    3. Core Authentication functions and objects that allows extensions
  • SPL Hookable for object method consistency
  • SPL MVC classes as PECL and core.

DBC or Design by Contract is possible now with assert and assert_options, but it really should be part of the function and class method prototype. It would separate the input checking before the body is executed and if supplied, would check the output. For objects, the assertions would be inheritable.

Other items of the list are for developmental consistency between projects. I feel it would be neater, if for instance, using the SPL Hookable object, would allow for learning an hookable API once and “plugging” in multiple objects of similar functionality.

Nonces are such awesome security feature, it would be nice to have it built into the $_POST superglobal without using an HTML hidden input. Since Authentication is such a common practice it would make some sense to have a base authentication, either database or otherwise.

Possibly Related Posts:


I like story time, but not all of the time

I’m enjoying reading the Extending and Embedding PHP by Sara Golemon book. This is not an review of the contents. I like the book, because it cuts the crap and hits you with just information that you need.

I had criticism, but then I realized the reasoning the author had, so I have no issues with the first 5 chapters, which I read up to. I just wish for the continuation of the extending PHP subject to create a more comprehensive series.

Pointers: The Novice Programmer’s Archenemy

On the subject matter of pointers, the book doesn’t have any explanation other than C source. Nope, just goes right along with no regard as to whether you have any experience with pointers or are scared to death of them, like I am.

Pointers are Voodoo magic that the elite programming Gods practice.

Just when I was about to throw the book away in disgust over my own lack of C knowledge, the Zend Memory Manager came up and all was well. Yeah, I’ll let Zend handle all of my memory. No pointer usage from this inexperience developer.

The Zend and PHP core developers really put a lot of thought and work in PHP. Much thanks and appreciation.

Story Time is the Best Time

My high school Physics teacher used to tell stories during class. It was entertaining and it kept from the tedious activities of the day. I compared the book to what he would do, which is deal out information with a little explanation and then after he was done, he’ll sit and tell a story.

The “story times” are scattered, but totally not inertia and much enjoyed.

Possibly Related Posts:


Why SDO Doesn’t Take Off

Question: SDO is sweet, why aren’t developers using it?

Developers will eventually start using it, it will take some time to go from the PHP way to SDO way. It would be easier to jump into SDO once better, more easily interpreted and simple to understand tutorials, code samples, and support is available. IBM tutorials are a little bit technical, with words and complex pictures (UML). Just give me code and explain how it works and let me run with the SDO scissors in my hand.

I just hope IBM and Zend continue the development and not back out, because of the impression that not a lot of developers are using it. The initial investment will pay off once more developers take a look at the wild animal SDO is and say, “Yes, this is awesome!”

My interest was that, in theory, SDO would save a great deal of work. It isn’t a matter of just recoding the source input from database to XML and back again. The switch would require a lot of work, but at least there is a common API which allows for the reading to be handled with consistency.

XML and Databases, but where is Spreadsheet Support?

The reason for why SDO isn’t used as often as some would probably like is because the two things that it currently offers are well taken care of in PHP. You can never have to many choices for handling XML, but combinations of multiple XML extensions can take care of most tasks. For databases, most are going to use MySQL (or MySQLi) or PDO and do you need anything else?

SDO offers the promise of offering more features, but PHP developers will have to do the implementation. Perhaps the two are for basing other future SDO extensions, but it was most likely a lot of programming to offer both XML and Database connections. Two of which would be very difficult from userland. I would like to see access to spreadsheets offered and any number of things that SDO can access.

XML: To many choices

Is that even possible as difficult as XML can be? Many choices are pretty bitchin and even more would be even better.

You have DOM, SimpleXML, XMLReader, XMLWriter, SOAP and WDDX, and finally SDO. If you are really hardcore, you don’t need any of those and just write your own package (not recommended for the sane).

For my work, I use DOM to write XML pages and DOM along with SimpleXML to read XML pages. DOM is quite powerful, and is also very difficult for some tasks and for simple reading, SimpleXML is far better. It helps that DOM and SimpleXML have functions for switching between the two easier. All you’ll need until XMLReader and XMLWriter, which I haven’t used, but does look like I’ll just love and will use them both in the future.

SDO is enchanting with its ArrayAccess for XPath, and I’ll be using SDO XML for that. I’m just not quite “down” with DOM XPath yet and probably won’t be for some time. It is really the only feature for me that gives it an advantage over the other choices, besides ArrayAccess property access.

Databases

Updated: It seems some comments made weren’t based on fact, so I decided to rewrite parts of this section to correct those flaws.

For my development with ArrayAccess it would make more sense to use SDO over PDO, because SDO already has that feature. If I used PDO I would have to write the ArrayAccess method myself. It would save time to use SDO in that case. For those who don’t care about ArrayAccess, PDO probably would be a more logical choice.

Possible reasons for not using SDO include:

  1. Current speed comparsions of mysql extensions verses PDO suggests that PDO is slower by a considerable degree without emulating prepares. SDO uses PDO for the Relational part, so it is safe to say that SDO will be as fast as PDO if not slower.
  2. SDO has even more complexity than PDO and the PDO learning curve hasn’t so far been so great. SDO seems easy, as does PDO, but there are probably going to be “gotchas”, like in PDO, that would need to be covered. The best way to use SDO as it was intended and not coding it hackish-ly will also have to be covered in better detail.

To put it bluntly and I’m repeating what others have simply stated before, is that more people are going to use PDO for their database Data Object. SDO still uses PDO, but it is still another layer that developers might not care about.

Conclusion

I’m sorry if I ask a lot more questions, but such SDO requires a great deal of thought for any project. It would be nice if every developer used it, to make working on projects easier. It just needs to offer more backends.

In a couple of years, we’ll look back and ask what the big fuss over developers not using SDO was about. I’m quite sure that enough PHP developers are going to embrace SDO in the coming years depending on the coverage it gets that IBM and Zend’s investment will pay off in the end.

Possibly Related Posts:


Multitasking in PHP

Update: Old Technical Post. The findings, information and discussion might be outdated, useless or plain wrong given the current and fluid area of the topic in this post.

Technically, the answer is simply forking scripts or if multithreading is needed, using another language. It is okay, to learn another language and use it where one language might fail.

Common Developer Question

The misconception about PHP is that it doesn’t offer multitasking and that it is impossible. It is true that PHP doesn’t allow the userland developers access to multithreading features that Java enjoys. There is a reason for this and it will become clear.

Forking is one method of multitasking and there exists an extension called Process Control Extension to handle this. There are also command line PHP commands that will allow for an process to run outside of PHP and return the output to PHP.

Multithreading in PHP has little merits for developers. In most cases, the script should only run for a few milliseconds and after that time it will be dismantled. A poorly designed script that used multiple threads would further lengthen the time for which the script would run giving no advantage. There is no need, for example, to handle both GUI responsiveness and uploading to a file server in PHP using a web SAPI.

The primary purpose of PHP has always been for web development and there shouldn’t be a need for having two threads running concurrently. All you should be doing is processing for output. The design method of PHP web development differs from that of desktop applications. To put bluntly, creating another thread is not going to solve your performance problem.

Simulating Multitasking

The Process Control extension isn’t meant for web servers and so you have to fake multitasking to the visitor. There are many ways to do this, but what are doing is mostly caching the results for the visitors.

  1. Cron Jobs for time consuming tasks that “save” to another location, either file or database.
  2. Processing and caching for one request and then using the cached file for every request after that.
  3. JavaScript XMLHttpRequest or AJAX as it is commonly known for collecting data after the server side script has been sent.

Learning Curve for Multithreading

Multithreading is difficult, and to offer it to beginners would be asking for a lot of Apache servers to crash. Even if PHP abstracted and kept tracked of deadlocks and race conditions, which would be somewhat difficult, it would add overhead to the compiling and execution. It is best to leave the multithreading to Apache and PHP and not userland.

Race Conditions

Race Conditions occur whenever threads are dependent on accessing the same resource and by preforming actions that cancel out the other thread. Which is why it is better to use a database for storing data instead of a file for both reading and writing from two different scripts.

Dead Locks

A dead lock is whenever one Thread B locks a resource waiting for another Thread A to preform its action. Thread A needs the resource that Thread B has locked, so it can’t preform its task until Thread B releases the resource. It is an never ending cycle that is hell, from what I have read. They can be avoided by only locking for a short interval.

Resources

Cameron and Tracy Hughes. Object-Oriented Mulithreading Using C++. John Wiley and Sons. 1997.

Possibly Related Posts:


Floss Weekly Rasmus Review

I Always Thought Rasmus was a Jerk

I have no idea where I got this idea. He sounded humbled and quite nice, so I feel like an ass now. I think it might have something to do with perceiving those as better than myself as jerks, I suppose to help handle with my lack of mad skills.

He was cool to Perl and I was expecting him to mock it, which he didn’t. Perl is quite powerful for what it can do, so I don’t think anyone could sincerely say Perl sucks.

PHP History: Damn You PHP Manual

Anyone besides me feel really angry at PHP Manual for getting this wrong?

I wrote a college report using the PHP manual as a source. Now, if the teacher goes back to read it, he’ll find that the statement made is in fact incorrect and that I deserved a lower grade than what I received. I could justify my mistake by replying that I trusted the Official PHP Manual to be accurate when it wasn’t.

The correction is that PHP was in fact always in C and Perl was only a consideration that was toss aside.

Personal Home Pages or PHP Hypertext Preprocessor

When the teacher asked what PHP stood for, I replied, “Personal Home Pages.” Another student who went to the web site, corrected me and stated, “PHP Hypertext Preprocessor.” Who was right? Also, why did I feel like a fool afterwards?

We both were, but I was used to remembering Personal Home Pages, that I never thought to remember the new term for it. PHP Hypertext Preprocessor is the Professional usage. You don’t want to go to company saying you are going to code their site in something that has “Personal” in the acronym (source another blog, somewhere). I mock the recursive-ness of it.

I’ll take Rasmus advice, and not use it as an acronym and just say PHP. Is Perl an acronym? Depends on who you ask. Official word is no, the developers and manual should just strip the acronym and just use PHP. However, since it no longer stands for anything, can you write it as Php? Probably.

Namespaces in PHP 6

I know I’ll be happy, however there is still nothing official that I have read at least that even suggests that they are including it. I’ll be extremely happy and surprised if they include it and it works perfectly.

Remember, they added it to PHP 5 and took it out. I do think that the sooner they add it, the better. Rasmus did talk about Unicode, stating that PHP 6 is mostly a Unicode update. Those who think is only a minor upgrade should note how many functions need to be reworked to allow seamless working of existing applications and provide better tools for future ones.

If they don’t add it in PHP 6, then it has to be in PHP 7. They’ll have all the time of PHP 5 and 6 to work out any major bugs in the implementation.

Rasmus Still Works on PHP?

I always thought he left for better adventures. Probably got that in some false or misinterpreted context. Actually, he never said (or so I think) anything to whether he still codes PHP or just maintains what goes into it. My guess has always been the latter, but the former could still be true.

Open Source Burnout

I’ve experienced that and it does suck. Taking a break does let you think more about programming than when you are coding. Coming back, I was able to take in and understand than when before I left.

Possibly Related Posts:


One Year: My Past PHP Project Development Ranting

Please note that the content contained here is retrospective of my personal PHP development and may not have any interest to you.

Introduction

Really now, it has been a long year and I really haven’t done everything I had plan on. I have learned a lot from my past experiences.

I’ve been harboring a lot of hate towards Mecha Warz for some time now and it feels good to get it all out in one long rant. I can only justify the experience by gaining a love and respect for Version Control that I wouldn’t otherwise have.

  • Mecha Warz

    1. Use Version Control
    2. Keep It Really Simple for the Stupid or KIRSS
    3. Security is your Friend. Hackers brought in by (maybe) another team member are not
    4. Don’t Give Players poorly implemented and poorly designed banking job feature.
  • Mecha Asylum

    1. Use Smarty or Functional Page Template Package
    2. Features can stop working after a month for no apparent reason
    3. Game Complexity Sucks
    4. Coding Games isn’t About What you want
    5. Building a Game for Two years with minimal progress is embarrassing.
  • Gamehole!

    1. Don’t Sidetrack to learn other useful information.
    2. Don’t Sleep on the job
    3. Don’t make your client wait 9 months for a finished product.
    4. Do refactor working, functional code

When Professionals say to use Version Control, either you do so or you’ll find out the hard way, like I did with Mecha Warz.

Read more »

Possibly Related Posts:


Don’t Advocate Inner Classes

What Are Inner Classes

Also known as classes in classes

Inner Classes are contained in parent classes and offer a sort of namespace mechanism for the public and open private class data transfer for private subclasses.

class ParentClass
{
    class InnerClass
    {
        function __construct() { }
        function __destruct() { }

        // Functions
    }

    function __construct() { }
    function __destruct() { }

    // Functions
}

The functionality is already available in other languages, but the question is whether it is needed in PHP. The short answer is no. With PHP execution model, it would further slow down and bloat PHP compilation.

Inner Class Purpose

I know of one language that restricts inner classes to structs only. The reason is that inner classes introduce developers to really bad design and further complicate usabliity. They are good to enclose data structures within the classes that are the only ones that are going to use them.

For example, if I want to return a customized error with code and error message.

class MyClass {

    class Error {
        public $code = 0;
        public $error = '';

        function __construct($code, $error) {
            $this->code = $code;
            $this->error = $error;
        }
    }

    function myTestFunction() {
        return new MyClass::Error(1, 'Test Error');
    }
}

Well, a better way would be to use arrays, which you could say function like structs. Since arrays are built-in, they serve the purpose better. Another consideration are exceptions, but that is missing the point. You could also use inner classes (and arrays) for returning phone book records and other information.

But It Is So Cool!

So what? I would rather the core developers spend more time implementing Namespaces than some feature no one in their right mind would use. People would use Namespaces and people advocating inner classes can use Namespaces for such a feature.

I have only seen one post advocating this, but one person means that there are probably 100 or 1000 more who think the same. If there is only one, then I should get the chainsaw ready and go a hunting. Don’t need any outside influence getting in and infecting the masses. You know how the plague spread.

Why Namespaces over Inner Classes

The appearances of both make it seem like they are both the same in different syntax. That could be true, but namespaces offer what inner classes can not. Packaging and importing. Inner classesoffer convenience to those who know how to use them correctly.

I think arrays should be used instead of adding more bloat than what is needed. Namespaces are going to add enough as it is.

You Don’t Need Inner Classes

The most interesting thing is that you don’t need to place classes in classes and most are just fine without it with clever naming scheme. Ah yes, the clever naming scheme. Give me Namespaces or give me… well, no use dieing over something that will be added in PHP 7. I can wait.

Update: changed name from Subclasses which is the worng technical term to the correct term, Inner Class.

Possibly Related Posts:


Global Functions and How to Not Use Them

When I develop in PHP and code functions, I always either place them in a file or place them at the top of the script. The force of habit comes from C++, and its been only a year ago that I realized that you can call functions at the bottom of the page. So trained was I at placing functions before I have to call them that I didn’t realize you can place functions anywhere and still use them.

Well, this is more about C++ and how I totally freaked out my teacher, by breaking his paradigm of thought. You see, you can have a definition of a function at the top of the page and then code the body of the function later. It was this ‘magic’ that I used to call a function from after the function body, when it was actually defined already. Of course, this is basic C/C++ knowledge and everyone knows this.

The Point?

Well, the script that I mentioned earlier left me looking for the functions in multiple different places, until I finally found them at the bottom, where I never expected them to be. What jackass places a function after he needs to use it?

Even if you have a foot and a gun, why go through the motion of shooting yourself in the foot, when your head is closer and therefore easier to aim at.

If there is something at least somewhat common about popular scripts that people use and extend, is that the functions are placed in organized manner. Reforming otherwise is a bitch and I remember rewriting the entire script anyway. You can’t reform when you can’t reuse anything.

Possibly Related Posts: