Page MenuHomePhabricator

Make common methods more convenient to access in PsySH
Closed, ResolvedPublicBUG REPORT

Description

The PsySH shell built into MediaWiki (shell.php) is a great debugging tool but its typeahead functionality is limited. This is partially a (probably hard) upstream issue around how tab completion is handled, where AIUI readline offers limited flexibility, and partially unsolvable (since it has no way of knowing about classes or namespaces which haven't been autoloaded yet). With things increasingly getting namespaced and global functions deprecated, this means that using PsySH involves lots of tedious typing. We should improve that.

Probably the simplest option is to provide a debug helper class with a short name (Dbg or maybe just D) with a bunch of static methods for common commands, like D::services() to get the service container or D::u('someName') to get a user, and autoload the class when PsySH is fired up.

Details

Related Changes in Gerrit:

Event Timeline

Probably the simplest option is to provide a debug helper class with a short name (Dbg or maybe just D) with a bunch of static methods for common commands, like D::services() to get the service container or D::u('someName') to get a user, and autoload the class when PsySH is fired up.

This can be done via the MaintenanceShellStart hook; Wikibase already uses it to provide an mws() function (MediaWiki services – returns the service container) and wbr and wbc class aliases (WikibaseRepo and WikibaseClient, both of which have lots of static methods to access services), introduced in this Gerrit change.

Change 885036 had a related patch set uploaded (by Gergő Tisza; author: Daniel Kinzler):

[mediawiki/core@master] shell: define convenience variables.

https://gerrit.wikimedia.org/r/885036

Change #885036 abandoned by Daniel Kinzler:

[mediawiki/core@master] shell: define convenience variables.

https://gerrit.wikimedia.org/r/885036