Returning void from execute() is success.
Returning true is success, false is failure with exit(1)
Using fatalError also using exit(1)
Change-Id: I1d40430ad6226e4aab8f0810b03ee1213282d123
Make getServer() always return a string, as documented, even with new
Database::NEW_UNCONNECTED handles that have yet to call open(). If the
'host' parameter to __construct() is ''/null, getServer() now returns
'localhost' instead of null. This avoids problems like fatal errors in
calls to TransactionProfiler::recordConnection().
Use Database constants for "connectionParams" field keys for better
static analysis.
Also:
* Add Database::getServerName() method that returns "readable" server
names in the style of LoadBalancer::getServerName(). Note that the
"hostName" field is already passed in from LoadBalancer.
* Migrate most getServer() callers to getServerName() for easier
debugging and more readable logging.
* Also, normalize Database/LoadBalancer SPI logging context to use
"db_server" and reduce logging code duplication in LoadBalancer.
Bug: T277056
Change-Id: I00ed4049ebb45edab1ea07561c47e226a423ea3b
I confirmed that the LoadExtensionSchemaUpdates hook no longer runs
after the parent patch to fix T249584 is merged, in either sql.php or
patchSql.php.
Note that sql.php is not just a "debugging script", it's intended for
use in production, and was used in production, hence T249565.
Bug: T249565
Bug: T157651
Change-Id: Ia4d99e00e6455eec9cf0fa486ec5e4b83c9cf25d
It's dangerously broken.
This is supposed to be a read-only ad-hoc debugging script but in actually
triggers 'LoadExtensionSchemaUpdates', which is effectively update.php, but
without any of the safe guards, and at a time where you least expect write
queries to happen, let alone administrative queries that drop tables and
run other schema migrations.
Bug: T157651
Change-Id: I8d18a7f5b1731333aa40a9d04dafdb7176cf1d52
Add a --status option which sets nonzero exit status for a query
returning or updating no rows. This is useful for shell scripts which
want to do simple existence checks (e.g. 'unless' conditions in Puppet)
or need to do a single-row change.
Change-Id: I3988c4fb24251dd8b33ac85aed9d0ae03eb0f910
* return empty array when the query had no result (instead of
falling back into non-JSON mode)
* return JSON for write queries as well
* retain legacy behavior in non-JSON mode for empty SELECTs, just in
case somebody relied on it
Change-Id: Iaefbb443650a395278d1cc9ab6aa668b13b217c9
These comments do not add anything. I argue they are worse than having
no comments, because I have to read them first to understand they
actually don't explain anything. Removing them makes room for actual
improvements in the future (if needed).
Change-Id: Iee70aad681b3385e9af282d5581c10addbb91ac4
Deprecate the second argument to Maintenance::error() in favor of a new
Maintenance::fatalError() method. This is intended to make it easier to
review flow control in maintenance scripts.
Change-Id: I75699008638f7e99b11210c7bb9e2e131fca7c9e
It's unreasonable to expect newbies to know that "bug 12345" means "Task T14345"
except where it doesn't, so let's just standardise on the real numbers.
This includes renaming fixBug20757.php to fixT22757.php for similar consistency.
Change-Id: If81a590d658fbd82c20c54ac47dfdc8856745ca3
This is more consistent with LoadBalancer, modern, and inclusive
of master/master mysql, NDB cluster, and MariaDB galera cluster.
The old constant is an alias now.
Change-Id: I0b37299ecb439cc446ffbe8c341365d1eef45849
When an erroneous query is entered into sql.php, it doesn't clear its
line buffer, so the intended next query (often fixing a typo in the
original) winds up concatenated onto the erroneous query. Usually
leading to another error, which repeats the process.
The solution is simple enough: clear the line buffer unconditionally,
not only when no exception is caught.
Change-Id: Ia78e2df8b9c6698c0a225bfb3135274ed8da5303
Swapped some "$var type" to "type $var" or added missing types
before the $var. Changed some other types to match the more common
spelling. Makes beginning of some text in captial.
Also added some missing @param.
Change-Id: I727deec35a712de0f0c676cc87dfa661f1ee965b
* This is useful for updating DBs that are not actually a that of a wiki.
For example a global blocking or central auth DB may not correspond to
any single wiki. Trying to use --wiki will fail with het deploy
Change-Id: I232182b79c9ca6421789f19771ba427498fff713
Follows-up I1343872de7, Ia533aedf63 and I2df2f80b81.
Also updated usage in text in documentation and the
installer LocalSettingsGenerator.
Most of them were handled by this regex:
- find: (require|include|require_once|include_once)\s*\(\s*(.+?)\s*\)\s*;$
- replace: $1 $2;
Change-Id: I6b38aad9a5149c9c43ce18bd8edbab14b8ce43fa
Squiz.WhiteSpace.LanguageConstructSpacing:
Language constructs must be followed by a single space;
expected "require_once expression" but found
"require_once(expression)"
It is a keyword (e.g. like `new`, `return` and `print`). As
such the parentheses don't make sense.
Per our code conventions, we use a space after keywords like
these. We appeared to have an unwritten exception for `require`
that doesn't make sense. About 60% of require/include usage
was missing the space and/or had superfluous parentheses.
It is as silly as print("foo") or return("foo"), it works
because keywords have no significance for whitespace between
it and the expression that follows, and since experessions can
be wrapped in parentheses for clarity (e.g. when doing string
concatenation or mathematical operations) the parenthesis
before and after basiclaly just ignored.
Change-Id: I2df2f80b8123714bea7e0771bf94b51ad5bb4b87