HomePhabricator

Update Title & LinkCache article ids right after move

Authored by matthiasmullie.

Description

Update Title & LinkCache article ids right after move

I believe this should fix all cases that depend on the correct
article ID. $from & $to objects will have the correct values.
Any other Title objects that get created will get it from
LinkCache, which is now also fixed. Unless GAID_FOR_UPDATE
is used, but that case will also result in the correct data.

I pass $to by-ref so I can easily clear mArticleId without
affecting LinkCache, which should be fine.
Alternatives could be:

  • using reflection to change mArticleID
  • use resetArticleID & then repopulate LinkCache:

    /*
    • We'll reset $to's article ID to make sure it's the correct one,
    • but doing so will also clear LinkCache, so we'll have to re-add it. */ $fields['id'] = $linkCache->getGoodLinkFieldObj( $to, 'id' ); $fields['length'] = $linkCache->getGoodLinkFieldObj( $to, 'length' ); $fields['redirect'] = $linkCache->getGoodLinkFieldObj( $to, 'redirect' ); $fields['revision'] = $linkCache->getGoodLinkFieldObj( $to, 'revision' ); $fields['model'] = $linkCache->getGoodLinkFieldObj( $to, 'model' );

      $to->resetArticleID( $fields['id'] ); $linkCache->addGoodLinkObj( $fields['id'], $to, $fields['length'], $fields['redirect'], $fields['revision'], $fields['model'] );

Bug: T112784
Change-Id: Ibbc09a10c9f8f5ccaec6f69011edc9c7089b217d

Details