Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Get MediaWiki
Get extensions
Tech blog
Contribute
Support
User help
FAQ
Technical manual
Support desk
Communication
Development
Developer portal
Code statistics
mediawiki.org
Community portal
Recent changes
Translate content
Random page
Village pump
Sandbox
Search
English
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Export translations
Translate
English
Language statistics
Message group statistics
Export
Tools
Tools
move to sidebar
hide
Actions
Language statistics
Message group statistics
Export
General
Upload file
Special pages
Printable version
Get shortened URL
Download QR code
{{DISPLAYTITLE:Příručka:Shell.php}}<languages/> {{MW file|shell.php|maintenance/|class1=MediaWikiShell}} '''shell.php''' je [[Special:MyLanguage/Manual:Maintenance scripts|údržbový skript]], který se nachází v adresáři <code>maintenance</code>, který poskytuje [[w:REPL|REPL shell]], který můžete použít k živému hraní s objekty MediaWiki a funkcemi. Je založen na [http://psysh.org/ PsySH]; nahrazuje {{ll|Manual:Eval.php|eval.php}}, který je méně robustní a má méně funkcí. Kromě schopnosti vyhodnocovat příkazy PHP zahrnuje funkce zpracování chyb a fatálních událostí způsobem, který nenaruší shell, zkoumání vnitřních částí objektů, zdrojového kódu a dokumentace prostřednictvím reflexe, integrace externího editoru a další. <span id="Usage"></span> == Použití == Interaktivně: <code>php maintenance/shell.php</code><br /> Provádění PHP příkazů ze souboru: <code>cat commands.txt | maintenance/shell.php</code> <span id="Options"></span> === Možnosti === {| class="wikitable" ! width="20%" | Volba !! Popis |- | --log-channels || Vytiskne protokoly odeslané na dané [[Special:MyLanguage/Manual:$wgDebugLogGroups|logové kanály]]. Oddělené čárkami: <code>--log-channels authentication,cookie,session</code> úrovně protokolu lze filtrovat pomocí <code>--log-channels authentication,cookie:info,session:error</code> |- | --log-all || Tisk protokolů odeslaných do všech kanálů |- | --dbo-debug || Zaznamená více informací souvisejících s databází (přibližně stejné jako nastavení {{wg|DebugDumpSql}}) |- | --no-session || Předstírá, že byl nastaven <code>MW_NO_SESSION</code> (užitečné pro ladění kódu, který je vyvolán z koncových bodů bez relace, jako je <code>load.php</code>) |} <span id="Examples"></span> == Příklady == <span id="Command_execution_and_error_handling"></span> === Provádění příkazů a zpracování chyb === <pre style="overflow:auto;"> $ php maintenance/shell.php Psy Shell v0.12.2 (PHP 7.4.33 — cli) by Justin Hileman > MW::user('Admin') = MediaWiki\User\User {#5704 +mId: 1, +mName: "Admin", +mActorId: 1, +mRealName: "", +mEmail: "admin@local.wmftest.net", +mTouched: "20240114073920", +mEmailAuthenticated: "20010101000000", +mFrom: "id", mId: 1, mName: "Admin", mActorId: 1, mRealName: "", mEmail: "admin@local.wmftest.net", mTouched: "20240114073920", mEmailAuthenticated: "20010101000000", mFrom: "id", } > // use $_ for previous return value > $_->mQuickTouched PHP Error: Cannot access protected property User::$mQuickTouched in Psy Shell code on line 2 > sudo $_->mQuickTouched = null > User::newFromIdentity(0) TypeError Argument 1 passed to MediaWiki\User\User::newFromIdentity() must implement interface MediaWiki\User\UserIdentity, int given, called on line 2. > wtf TypeError Argument 1 passed to MediaWiki\User\User::newFromIdentity() must implement interface MediaWiki\User\UserIdentity, int given, called on line 2. -- 0: () at includes/user/User.php:652 1: MediaWiki\User\User::newFromIdentity() at eval()'d code:2 2: eval() at vendor/psy/psysh/src/ExecutionLoopClosure.php:52 Use wtf -a to see 8 more lines </pre> <span id="Reflection"></span> === Odraz === <pre style="overflow:auto;"> > ls Message Class Constants: FORMAT_BLOCK_PARSE, FORMAT_ESCAPED, FORMAT_PARSE, FORMAT_PLAIN, FORMAT_TEXT Class Methods: __construct, __toString, bitrateParam, bitrateParams, content, durationParam, durationParams, escaped, exists, expiryParam, expiryParams, getFormat, getKey, getKeysToTry, getLanguage, getParams, getTitle, inContentLanguage, inLanguage, isBlank, isDisabled, isMultiKey, listParam, newFallbackSequence, newFromKey, newFromSpecifier, numParam, numParams, params, parse, parseAsBlock, plain, plaintextParam, plaintextParams, rawParam, rawParams, serialize, setContext, setInterfaceMessageFlag, sizeParam, sizeParams, text, timeperiodParam, timeperiodParams, title, toString, unserialize, useDatabase > doc Message::setContext public function setContext(IContextSource $context) Description: Set the language and the title from a context object Param: IContextSource $context Return: Message $this Since: 1.19 >>> show Message::setContext > 724| public function setContext( IContextSource $context ) { 725| $this->inLanguage( $context->getLanguage() ); 726| $this->title( $context->getTitle() ); 727| $this->interface = true; 728| 729| return $this; 730| } </pre> <span id="Debug_output"></span> === Výstupní ladění === <pre style="overflow:auto;"> $ php maintenance/shell.php --log-all --dbo-debug [debug] [DBReplication] Wikimedia\Rdbms\LBFactory::getChronologyProtector: using request info { "IPAddress": "", "UserAgent": "", "ChronologyProtection": "true" } [debug] [DBConnection] Wikimedia\Rdbms\LoadBalancer::openConnection: calling initLB() before first connection. [debug] [DBConnection] Connected to database 0 at '127.0.0.1'. [debug] [DBQuery] wiki SHOW /* Wikimedia\Rdbms\DatabaseMysqlBase::serverIsReadOnly */ GLOBAL VARIABLES LIKE 'read_only' [debug] [DBQuery] SHOW GLOBAL VARIABLES LIKE 'read_only' Psy Shell v0.8.5 (PHP 5.6.30-0+deb8u1 — cli) by Justin Hileman >>> MW::message("Recentchanges")->text() [debug] [CryptRand] mcrypt_create_iv generated 20 bytes of randomness. [debug] [CryptRand] 0 bytes of randomness leftover in the buffer. [info] [MessageCache] MessageCache::load: Loading en... local cache is empty, got from global cache => "Recent changes" </pre> <span id="Editline_integration"></span> == Integrace editačního řádku == PsySH lze integrovat s [[w:GNU_Readline|readline]] / editline (PHP je obvykle předpřipraven s druhým). Ukázka <code>.editrc</code> pro vyhledávání v historii: <syntaxhighlight lang="text"> # make PgUp/PgDown work, sort of # editline has no prefix search so use fulltext search bind "\e[5~" ed-search-prev-history bind "\e[6~" ed-search-next-history </syntaxhighlight> <span id="See_also"></span> == Související odkazy == * {{ll|Manual:How to debug}} [[Category:Maintenance scripts{{#translation:}}|shell.php]] [[Category:MediaWiki development{{#translation:}}]]
Toggle limited content width