In August I began the commit spree on the temporary GNU Social ‘master’ branch over at Gitorious. Temporary because the repository will likely in the future be under the ‘social’ project on that site.
Erkan recently asked for a roadmap of GNU Social development, but unfortunately I’m right now just going to give the next best thing – a summary of what’s been done the latest month. Starting after Evan’s currently last StatusNet commit at Tuesday July 16 2013,
2a70ed2: Merge branch '1.1.x', it was merged into the stone-age stuff of previous GNU Social code from 2010… and new development began. This is the story of our commits from 2013-08-12 to 2013-09-17.
First up, updating some libraries
I guess noone had dared touch the old piece of legacy PHP code that’s called “DB”, i.e. the ancient database abstraction layer StatusNet uses (and doesn’t really get used properly as there are many manual SQL queries in the code still). I didn’t dare do this either, but updates are always nice. So the first essential commit was updating the external library DB to its latest version:
7d8e199 Update to DB_DataObject 1.11.2
There was the idea to migrate everything to MDB2, which would still be able to handle the DataObject classes. However, since it still wouldn’t take care of the biggest problem – functions that are internally called by static methods but aren’t declared static – I figured it wasn’t worth the hassle. And the OpenID plugin supposedly would need lots of work… Anyway, if there’s anything we should do (besides drop PHP!) it’s to migrate over to PDO.
Long-standing merge requests
Then there was work to integrate some fixes from the list of merge requests and such which had not been taken into StatusNet master yet:
This felt like a relief for me personally, having written some of those myself. Several other good people had submitted merge requests as well which were taken care of in this round. All the details are in the commit log.
One big problem for new users was also the extreme sluggishness that arises from such a huge, dynamic piece of software as StatusNet. So we automatically enabled Memcache detection if PHP has the module. It requires the administrator to run a local memcache server, but at least no further configuration has to be done after ‘apt-get install memcached’.
What makes GNU Social GNU Social?
And so it became time for a distinction that separates GNU Social from StatusNet somewhat. Something which bothered me in every fresh install I ever made, too:
794163c Default to NOT ask for current location for new users
Privacy. At least we shouldn’t stalk fresh users by asking them where they live everytime they try to post stuff! Another privacy change had already been made (20bad68 regarding SSL-on-install), but this was the first that would immediately affect user experience. SSL improvements were made later as well (commit 81a357e), where a site configured as SSL ‘sometimes’ would never redirect users to http://.
Major overhaul of dataobjects
In a couple of steps to reduce code redundancy and ease future migration to better DB abstraction layers, many of the following commits were directed at the ‘classes/’ directory, finally taking some of the dataobjects to inherit “Managed_DataObject”. Which means that everything from caching to specifying data structure becomes much easier not to say more flexible.
0cb5b6f No need for newline when running 'echo' 3394efc staticGet is a static function d115cdd Managed_DataObject gets dynamic class detection for staticGet 1a9a8ea staticGet for sub-Managed_DataObject classes now calls parent 6c4c431 Plugins with classes that extend Managed_DataObject get better code reuse c36608b Some statically called functions in plugins now declared statically e95f77d Updating all Memcached_DataObject extended classes to Managed_DataObject 2a4dc77 The overloaded DB_DataObject function staticGet is now called getKV ade2bdc Bookmark class now has schemaDef (for Managed_DataObject) 1710a61 Magicsig class now Managed_DataObject with nicer schemaDef 861e838 pkeyGet is now static and more similar to getKV 3ce5631 Memcached_DataObject::multicache is now properly defined static 7e4718a IMPORTANT - fixed Magicsig to properly overload getKV (prev. staticGet) 761a849 Added shared default plugin list between profiles 923f16a Properly definingStatusNet class static functions with 'static' 97ce71e Managed_DataObject now has listGet for all classes 0785cc2 Don't use DB_DataObject::factory (statically at least) d5f82bb Class wasn't used anywhere, and file contained wrong class e40044e Further static declarations of functions 6f4c572 Unnecessary UTF-8 declaration for database b1465a7 We can now do late static binding (PHP >= 5.3) 3a7261f IMPORTANT: Making prev. Memcached_DataObject working again with schemaDef 66997f2 OStatus classes now has modern schemaDef 0bbcfa7 IMPORTANT - fixed HubSub to properly fetch primary keys 4fab7a9 GNU Social extensions fixes (please read note) 40fe10e Woops, forgot auto_increment (comes with 'serial') b6cfcfb More info for a proper, fancy-url lighttpd setup
…and during this time the code was broken several times. Part of the fixes also included depending on PHP >= 5.3, which means we can rely on much better object orientation and snazzier functionality (such as late static binding). Unfortunately several problems still exist internally in the DB abstraction layer, where it calls its own non-statically defined functions with static methods. So the ‘PHP Strict Standards’ warning bells keep going off all the time – and still do even after all of the commits in this post.
One important thing that changed during these commits however was the Memcached/Managed_DataObject API, where instead of calling the DB_DataObject function
staticGet (which wasn’t static!) it has been renamed
getKV (for getKeyValue). Some other related data-fetching functions were also renamed and changed throughout the codebase.
Code reuse is a good thing, viva la OOP!
Then there was a big one. Standardising the way class files are autoloaded, which had already been kinda-maybe-half-made in previous StatusNet code, I went through a lot of the code for plugins and could remove tons of lines of code with statically assigned ‘include_once’ lines. Instead it is all generally handled in the Plugin parent class for the event onAutoload. Many files were moved and renamed in the course of this commit, as they all would fit the same pattern, which can be seen in lib/plugin.php.
de55d8f plugins onAutoload now only overloads if necessary (extlibs etc.)
And then some more cleanup and fixing
More merge requests and general fixes that had been noticed while digging around in the code were implemented.
cb94a29 Syntax error in XMPP config example fac7371 pivotGet moved into Managed_DataObject b3e61ce Stronger typing, require array where param array 79e3acf Moved multiGet into Managed_DataObject f042eea removing empty "planned" GNU Social plugins 07ca304 Changes to GNUsocial plugins bd24ab6 Fixed comment description in STS plugin 47eb3cf db/core.php lacked User_username (Issue 3299)
And some new parent classes
When working on Free & Social, I rewrote some major parts of the code. A lot of it isn’t quite finished yet (like the theme engine migration), but many bits and pieces can be put back in to GNU Social. Like the fact that just about every Action where one interacts with a form can inherit, and standardise to, a ‘FormAction’ class:
8d57fb7 Added a FormAction extension cfa699e NewgroupAction converted to extend FormAction 83000f6 Proper definition of $args array in NewgroupAction->prepare c735a83 Conforming to code layout 0612e5e NewnoticeAction converted to extend FormAction 89b1066 IMPORTANT: parent::handlePost() in NewnoticeAction e5e3aeb newmessage (and Message class) fixed for FormAction f0e967f needLogin renamed checkLogin and made a property b2a0aa2 NewapplicationAction converted to FormAction c5bf6cb Using a bit more of $this->scoped (Action parent class)
As you can see I migrated a couple of actions as well, but many still need work. And an introduction of a SettingsAction parent class would also be very good!
Tidying up, cleaning and implementing merge request
Back to house cleaning. Some code improvements were made where little effort was needed. Strict typing is very important if one doesn’t enjoy headaches while reading and debugging code. So some of that was introduced (and a little bit more would come later):
747fe9d Tidying up getUser calls to profiles and some events a9c4bcd Removing unnecessary require_once lines (autoload!) 99312c8 Declaring some more static functions properly 81a357e Putting in functionality so that sites with the "Sometimes" SSL setting allow for users with plugins such as HTTPSEVERYWHERE who wish to use HTTPS to do so without having errors pop up. Specifically this references this issue: http://status.net/open-source/issues/3855#comment-48988. ade8c69 Twitter cards implementation. Currently only supports 'photo' cards. f0d86cd Add 'twitter:title' meta tag support.
jbfavre’s Twitter updates were also implemented. I actually haven’t tested these, but jbfavre is a good person whom we can all trust.
The Big JQuery Update
Some of the commits in the latest list are unrelated to JQuery updates (essentially all of the last ones except 8935a2f), but are instead part of tidying up and making the code stricter and less redundant. Many scripts are even thrown away, as they were never referenced anywhere in the code (such as farbtastic and jOverlay).
NOTE: A regression was made in jquery 2.x fixes, so please cherry-pick commit f711f9ee7551ac0fe59f1cdc5a375d4825d93e3c too if you’re annoyed with double-submitting favor forms and such ;)
…I leave it to the future to come up with a roadmap for the future :)