I want to "touch" an article by performing an empty edit, as if someone clicked "Edit" followed by "Save Page". Does anyone know why this code works sometimes and has no effect other times?
function touch($page) { $title = Title::newFromText($page); if ($title) { $article = new Article($title); return $article->doEdit($article->getContent(), '', EDIT_UPDATE); }
Thanks, DanB
On Fri, Nov 19, 2010 at 3:55 AM, Daniel Barrett danb@vistaprint.com wrote:
I want to "touch" an article by performing an empty edit, as if someone clicked "Edit" followed by "Save Page". Does anyone know why this code works sometimes and has no effect other times?
function touch($page) { $title = Title::newFromText($page); if ($title) { $article = new Article($title); return $article->doEdit($article->getContent(), '', EDIT_UPDATE); }
I assume you want to achieve something more specific than editing an article with a null edit.
It would be best to go straight to the point, instead of relying on simulating user behaviour on the backend and expecting the application to react in a specific way.
What do you want to do here? Purge cache? Update page_touched? Something else?
In this case, I want to trigger an action that normally occurs on page save. We have an extension that writes the externallinks table. We made a change to the extension and now many entries in externallinks are wrong. A null edit in each article would cause its external links to be corrected in the externallinks table.
I tried running maintenance/refreshLinks.php, but it doesn't complete because some extensions (used by articles) are throwing errors.
I could also do a SQL update on the externallinks table, modifying the URLs (el_to values) directly. It works, but I'd rather have MediaWiki modify the data than me.
DanB
-----Original Message----- I assume you want to achieve something more specific than editing an article with a null edit.
What do you want to do here? Purge cache? Update page_touched? Something else?
Daniel Barrett wrote:
In this case, I want to trigger an action that normally occurs on page save. We have an extension that writes the externallinks table. We made a change to the extension and now many entries in externallinks are wrong. A null edit in each article would cause its external links to be corrected in the externallinks table.
I tried running maintenance/refreshLinks.php, but it doesn't complete because some extensions (used by articles) are throwing errors.
So you should fix those errors...
I could also do a SQL update on the externallinks table, modifying the URLs (el_to values) directly. It works, but I'd rather have MediaWiki modify the data than me.
DanB
I tried running maintenance/refreshLinks.php, but it doesn't complete because some extensions (used by articles) are throwing errors.
Platonides writes:
So you should fix those errors...
True, but (1) the errors don't come from the extensions themselves, but farther downstream in other systems, and (2) it turns out it wouldn't matter anyway, because refreshLinks.php does not fix external links, it merely deletes unused ones from the table. I need to refresh the whole table based on current wiki content.
In the end, I ran a custom SQL script and all is well.
DanB
mediawiki-l@lists.wikimedia.org