On Wed, Jul 16, 2008 at 6:15 AM, brion@svn.wikimedia.org wrote:
Log Message:
Revert r37741 for now "Changed getInternalLinkAttributesInternal parameters: now accepts Title object if available, passes to hook. Also reordered some code in makeKnownLinkObj so that said hook can mangle the Title object. Reordering should have no other side-effects." This seems a bit icky and inconsistent. If it's necessary to pass titles around here, it should be done consistently, with appropriate fixups and refactoring to the old spaghetti code.
In particular, if you want titles to be accepted, you shouldn't add another parameter. This is PHP, not C -- parameters are untyped. Just do something like this at the beginning of getLinkAttributesInternal:
if( $title instanceof Title ) { $nt = $title; $title = $title->getPrefixedText(); } else { $nt = Title::newFromText( $title ); }
But I don't see why the hook could possibly want to be passed both a Title object *and* title text, since either one can be trivially constructed from the other. Pass one or the other, not both. Passing a Title object would be most consistent with the majority of hooks, I think -- I'd just do
wfRunHooks( ... array( ... Title::newFromText( $title ), ... ) );
I don't think there's any point in worrying about whether a Title is already available. This is not going to be a performance bottleneck.
wikitech-l@lists.wikimedia.org