Merge "Add checkDependencies.php"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Wed, 29 May 2019 19:36:04 +0000 (19:36 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Wed, 29 May 2019 19:36:04 +0000 (19:36 +0000)
525 files changed:
RELEASE-NOTES-1.34
autoload.php
composer.json
docs/hooks.txt
includes/AjaxResponse.php
includes/Block.php [deleted file]
includes/DefaultSettings.php
includes/EditPage.php
includes/FeedUtils.php
includes/LinkFilter.php
includes/Linker.php
includes/MediaWiki.php
includes/MovePage.php
includes/OutputHandler.php
includes/OutputPage.php
includes/Permissions/PermissionManager.php
includes/ServiceWiring.php
includes/Setup.php
includes/Storage/DerivedPageDataUpdater.php
includes/Title.php
includes/actions/RawAction.php
includes/api/ApiBase.php
includes/api/ApiBlock.php
includes/api/ApiMain.php
includes/api/ApiMove.php
includes/api/ApiQueryAllImages.php
includes/api/ApiQueryAllLinks.php
includes/api/ApiQueryAllPages.php
includes/api/ApiQueryAllUsers.php
includes/api/ApiQueryBase.php
includes/api/ApiQueryProtectedTitles.php
includes/api/ApiQueryRevisions.php
includes/api/ApiUnblock.php
includes/api/i18n/ar.json
includes/api/i18n/ba.json
includes/api/i18n/cs.json
includes/api/i18n/de.json
includes/api/i18n/en-gb.json
includes/api/i18n/en.json
includes/api/i18n/es.json
includes/api/i18n/fr.json
includes/api/i18n/gl.json
includes/api/i18n/he.json
includes/api/i18n/hu.json
includes/api/i18n/it.json
includes/api/i18n/ja.json
includes/api/i18n/ko.json
includes/api/i18n/ksh.json
includes/api/i18n/lt.json
includes/api/i18n/mk.json
includes/api/i18n/nb.json
includes/api/i18n/nl.json
includes/api/i18n/pl.json
includes/api/i18n/pt-br.json
includes/api/i18n/pt.json
includes/api/i18n/qqq.json
includes/api/i18n/ru.json
includes/api/i18n/sv.json
includes/api/i18n/uk.json
includes/api/i18n/zh-hans.json
includes/api/i18n/zh-hant.json
includes/auth/AuthManager.php
includes/auth/CheckBlocksSecondaryAuthenticationProvider.php
includes/block/AbstractBlock.php
includes/block/BlockManager.php
includes/block/BlockRestrictionStore.php
includes/block/DatabaseBlock.php [new file with mode: 0644]
includes/block/Restriction/NamespaceRestriction.php
includes/block/Restriction/PageRestriction.php
includes/cache/MessageCache.php
includes/cache/localisation/LocalisationCache.php
includes/changes/ChangesList.php
includes/clientpool/SquidPurgeClient.php
includes/content/ContentHandler.php
includes/db/MWLBFactory.php
includes/debug/logger/LegacyLogger.php
includes/debug/logger/monolog/LineFormatter.php
includes/deferred/CdnCacheUpdate.php
includes/deferred/DeferredUpdates.php
includes/deferred/TransactionRoundAwareUpdate.php [new file with mode: 0644]
includes/deferred/TransactionRoundDefiningUpdate.php
includes/diff/DiffEngine.php
includes/diff/DifferenceEngine.php
includes/diff/TextSlotDiffRenderer.php
includes/externalstore/ExternalStoreDB.php
includes/htmlform/HTMLForm.php
includes/import/WikiRevision.php
includes/installer/DatabaseInstaller.php
includes/installer/Installer.php
includes/installer/MssqlInstaller.php
includes/installer/MysqlInstaller.php
includes/installer/OracleInstaller.php
includes/installer/PostgresInstaller.php
includes/installer/SqliteInstaller.php
includes/installer/i18n/en.json
includes/installer/i18n/nb.json
includes/installer/i18n/olo.json
includes/installer/i18n/qqq.json
includes/installer/i18n/vi.json
includes/jobqueue/Job.php
includes/jobqueue/jobs/DoubleRedirectJob.php
includes/jobqueue/jobs/RefreshLinksJob.php
includes/libs/objectcache/APCBagOStuff.php
includes/libs/objectcache/APCUBagOStuff.php
includes/libs/objectcache/RESTBagOStuff.php
includes/libs/rdbms/ChronologyProtector.php
includes/libs/rdbms/TransactionProfiler.php
includes/libs/rdbms/database/Database.php
includes/libs/rdbms/database/IDatabase.php
includes/libs/rdbms/database/utils/GeneralizedSql.php [new file with mode: 0644]
includes/libs/rdbms/exception/DBQueryDisconnectedError.php [new file with mode: 0644]
includes/libs/rdbms/lbfactory/LBFactory.php
includes/media/BitmapHandler.php
includes/media/BmpHandler.php
includes/media/DjVuImage.php
includes/media/FormatMetadata.php
includes/objectcache/ObjectCache.php
includes/page/Article.php
includes/page/WikiPage.php
includes/parser/Parser.php
includes/parser/ParserFactory.php
includes/parser/ParserOutput.php
includes/preferences/DefaultPreferencesFactory.php
includes/preferences/MultiUsernameFilter.php
includes/resourceloader/MessageBlobStore.php
includes/resourceloader/ResourceLoaderModule.php
includes/skins/Skin.php
includes/specialpage/ChangesListSpecialPage.php
includes/specialpage/QueryPage.php
includes/specials/SpecialAllMessages.php
includes/specials/SpecialBlock.php
includes/specials/SpecialBlockList.php
includes/specials/SpecialContributions.php
includes/specials/SpecialDeletedContributions.php
includes/specials/SpecialMovepage.php
includes/specials/SpecialRedirect.php
includes/specials/SpecialSearch.php
includes/specials/SpecialUnblock.php
includes/specials/SpecialWatchlist.php
includes/specials/forms/PreferencesFormOOUI.php
includes/specials/pagers/AllMessagesTablePager.php
includes/specials/pagers/BlockListPager.php
includes/specials/pagers/ImageListPager.php
includes/specials/pagers/UsersPager.php
includes/title/NamespaceInfo.php
includes/user/User.php
includes/user/UserGroupMembership.php
includes/watcheditem/WatchedItemQueryService.php
includes/watcheditem/WatchedItemStore.php
includes/widget/SearchInputWidget.php
includes/widget/search/SearchFormWidget.php
languages/Language.php
languages/data/Names.php
languages/i18n/abs.json
languages/i18n/ace.json
languages/i18n/aeb-arab.json
languages/i18n/af.json
languages/i18n/ais.json
languages/i18n/am.json
languages/i18n/ami.json
languages/i18n/an.json
languages/i18n/ar.json
languages/i18n/arn.json
languages/i18n/ary.json
languages/i18n/arz.json
languages/i18n/as.json
languages/i18n/ast.json
languages/i18n/avk.json
languages/i18n/awa.json
languages/i18n/az.json
languages/i18n/azb.json
languages/i18n/ba.json
languages/i18n/ban.json
languages/i18n/bar.json
languages/i18n/bcc.json
languages/i18n/bcl.json
languages/i18n/be-tarask.json
languages/i18n/be.json
languages/i18n/bg.json
languages/i18n/bgn.json
languages/i18n/bho.json
languages/i18n/bjn.json
languages/i18n/bn.json
languages/i18n/bqi.json
languages/i18n/br.json
languages/i18n/bs.json
languages/i18n/ca.json
languages/i18n/cdo.json
languages/i18n/ce.json
languages/i18n/ckb.json
languages/i18n/co.json
languages/i18n/crh-cyrl.json
languages/i18n/crh-latn.json
languages/i18n/cs.json
languages/i18n/csb.json
languages/i18n/cv.json
languages/i18n/cy.json
languages/i18n/da.json
languages/i18n/de-ch.json
languages/i18n/de-formal.json
languages/i18n/de.json
languages/i18n/diq.json
languages/i18n/dsb.json
languages/i18n/dty.json
languages/i18n/ee.json
languages/i18n/egl.json
languages/i18n/el.json
languages/i18n/en.json
languages/i18n/eo.json
languages/i18n/es.json
languages/i18n/et.json
languages/i18n/eu.json
languages/i18n/exif/vi.json
languages/i18n/ext.json
languages/i18n/fa.json
languages/i18n/fi.json
languages/i18n/fo.json
languages/i18n/fr.json
languages/i18n/frp.json
languages/i18n/frr.json
languages/i18n/fur.json
languages/i18n/fy.json
languages/i18n/ga.json
languages/i18n/gan-hans.json
languages/i18n/gan-hant.json
languages/i18n/gd.json
languages/i18n/gl.json
languages/i18n/glk.json
languages/i18n/gom-latn.json
languages/i18n/grc.json
languages/i18n/gsw.json
languages/i18n/gu.json
languages/i18n/hak.json
languages/i18n/he.json
languages/i18n/hi.json
languages/i18n/hif-latn.json
languages/i18n/hil.json
languages/i18n/hr.json
languages/i18n/hrx.json
languages/i18n/hsb.json
languages/i18n/hu.json
languages/i18n/hy.json
languages/i18n/hyw.json
languages/i18n/ia.json
languages/i18n/id.json
languages/i18n/ig.json
languages/i18n/ilo.json
languages/i18n/inh.json
languages/i18n/io.json
languages/i18n/is.json
languages/i18n/it.json
languages/i18n/ja.json
languages/i18n/jv.json
languages/i18n/ka.json
languages/i18n/kaa.json
languages/i18n/kab.json
languages/i18n/kk-arab.json
languages/i18n/kk-cyrl.json
languages/i18n/kk-latn.json
languages/i18n/km.json
languages/i18n/kn.json
languages/i18n/ko.json
languages/i18n/krc.json
languages/i18n/ksh.json
languages/i18n/ku-latn.json
languages/i18n/la.json
languages/i18n/lb.json
languages/i18n/lfn.json
languages/i18n/li.json
languages/i18n/lij.json
languages/i18n/lki.json
languages/i18n/lmo.json
languages/i18n/lrc.json
languages/i18n/lt.json
languages/i18n/lus.json
languages/i18n/lv.json
languages/i18n/lzh.json
languages/i18n/mai.json
languages/i18n/mdf.json
languages/i18n/mg.json
languages/i18n/mk.json
languages/i18n/ml.json
languages/i18n/mn.json
languages/i18n/mnw.json
languages/i18n/mr.json
languages/i18n/ms.json
languages/i18n/mt.json
languages/i18n/my.json
languages/i18n/myv.json
languages/i18n/nah.json
languages/i18n/nan.json
languages/i18n/nap.json
languages/i18n/nb.json
languages/i18n/nds-nl.json
languages/i18n/nds.json
languages/i18n/ne.json
languages/i18n/nl-informal.json
languages/i18n/nl.json
languages/i18n/nn.json
languages/i18n/nqo.json
languages/i18n/nys.json
languages/i18n/oc.json
languages/i18n/olo.json
languages/i18n/or.json
languages/i18n/pa.json
languages/i18n/pam.json
languages/i18n/pl.json
languages/i18n/pms.json
languages/i18n/pnb.json
languages/i18n/prg.json
languages/i18n/ps.json
languages/i18n/pt-br.json
languages/i18n/pt.json
languages/i18n/qqq.json
languages/i18n/qu.json
languages/i18n/rm.json
languages/i18n/ro.json
languages/i18n/roa-tara.json
languages/i18n/ru.json
languages/i18n/rue.json
languages/i18n/sa.json
languages/i18n/sah.json
languages/i18n/sc.json
languages/i18n/scn.json
languages/i18n/sco.json
languages/i18n/sd.json
languages/i18n/sdc.json
languages/i18n/se.json
languages/i18n/sei.json
languages/i18n/ses.json
languages/i18n/sgs.json
languages/i18n/sh.json
languages/i18n/shi.json
languages/i18n/shn.json
languages/i18n/si.json
languages/i18n/sk.json
languages/i18n/skr-arab.json
languages/i18n/sl.json
languages/i18n/sli.json
languages/i18n/so.json
languages/i18n/sq.json
languages/i18n/sr-ec.json
languages/i18n/sr-el.json
languages/i18n/stq.json
languages/i18n/su.json
languages/i18n/sv.json
languages/i18n/sw.json
languages/i18n/szl.json
languages/i18n/ta.json
languages/i18n/tay.json
languages/i18n/tcy.json
languages/i18n/te.json
languages/i18n/tg-cyrl.json
languages/i18n/tg-latn.json
languages/i18n/th.json
languages/i18n/tk.json
languages/i18n/tl.json
languages/i18n/to.json
languages/i18n/tr.json
languages/i18n/trv.json
languages/i18n/tt-cyrl.json
languages/i18n/tt-latn.json
languages/i18n/tyv.json
languages/i18n/ug-arab.json
languages/i18n/uk.json
languages/i18n/ur.json
languages/i18n/uz.json
languages/i18n/vec.json
languages/i18n/vep.json
languages/i18n/vi.json
languages/i18n/vo.json
languages/i18n/vro.json
languages/i18n/wa.json
languages/i18n/war.json
languages/i18n/wo.json
languages/i18n/wuu.json
languages/i18n/xmf.json
languages/i18n/xsy.json
languages/i18n/yi.json
languages/i18n/yo.json
languages/i18n/yue.json
languages/i18n/zea.json
languages/i18n/zh-hans.json
languages/i18n/zh-hant.json
languages/messages/MessagesEn.php
maintenance/benchmarks/benchmarkPurge.php
maintenance/cleanupBlocks.php
maintenance/findHooks.php
maintenance/purgeChangedPages.php
maintenance/purgeList.php
maintenance/update.php
opensearch_desc.php
package.json
resources/Resources.php
resources/lib/foreign-resources.yaml
resources/lib/ooui/History.md
resources/lib/ooui/i18n/bjn.json [new file with mode: 0644]
resources/lib/ooui/i18n/eo.json
resources/lib/ooui/i18n/hyw.json [new file with mode: 0644]
resources/lib/ooui/i18n/sah.json
resources/lib/ooui/oojs-ui-apex.js
resources/lib/ooui/oojs-ui-core-apex.css
resources/lib/ooui/oojs-ui-core-wikimediaui.css
resources/lib/ooui/oojs-ui-core.js
resources/lib/ooui/oojs-ui-core.js.map.json
resources/lib/ooui/oojs-ui-toolbars-apex.css
resources/lib/ooui/oojs-ui-toolbars-wikimediaui.css
resources/lib/ooui/oojs-ui-toolbars.js
resources/lib/ooui/oojs-ui-widgets-apex.css
resources/lib/ooui/oojs-ui-widgets-wikimediaui.css
resources/lib/ooui/oojs-ui-widgets.js
resources/lib/ooui/oojs-ui-widgets.js.map.json
resources/lib/ooui/oojs-ui-wikimediaui.js
resources/lib/ooui/oojs-ui-windows-apex.css
resources/lib/ooui/oojs-ui-windows-wikimediaui.css
resources/lib/ooui/oojs-ui-windows.js
resources/lib/ooui/themes/apex/icons-content.json
resources/lib/ooui/themes/apex/icons-editing-advanced.json
resources/lib/ooui/themes/apex/icons-editing-citation.json
resources/lib/ooui/themes/wikimediaui/icons-editing-citation.json
resources/lib/ooui/themes/wikimediaui/icons-editing-core.json
resources/lib/ooui/themes/wikimediaui/images/icons/articleDisambiguation-ltr-invert.png
resources/lib/ooui/themes/wikimediaui/images/icons/articleDisambiguation-ltr-invert.svg
resources/lib/ooui/themes/wikimediaui/images/icons/articleDisambiguation-ltr-progressive.png
resources/lib/ooui/themes/wikimediaui/images/icons/articleDisambiguation-ltr-progressive.svg
resources/lib/ooui/themes/wikimediaui/images/icons/articleDisambiguation-ltr.png
resources/lib/ooui/themes/wikimediaui/images/icons/articleDisambiguation-ltr.svg
resources/lib/ooui/themes/wikimediaui/images/icons/articleNotFound-ltr-invert.png
resources/lib/ooui/themes/wikimediaui/images/icons/articleNotFound-ltr-invert.svg
resources/lib/ooui/themes/wikimediaui/images/icons/articleNotFound-ltr-progressive.png
resources/lib/ooui/themes/wikimediaui/images/icons/articleNotFound-ltr-progressive.svg
resources/lib/ooui/themes/wikimediaui/images/icons/articleNotFound-ltr.png
resources/lib/ooui/themes/wikimediaui/images/icons/articleNotFound-ltr.svg
resources/lib/ooui/themes/wikimediaui/images/icons/articleNotFound-rtl-invert.png
resources/lib/ooui/themes/wikimediaui/images/icons/articleNotFound-rtl-invert.svg
resources/lib/ooui/themes/wikimediaui/images/icons/articleNotFound-rtl-progressive.png
resources/lib/ooui/themes/wikimediaui/images/icons/articleNotFound-rtl-progressive.svg
resources/lib/ooui/themes/wikimediaui/images/icons/articleNotFound-rtl.png
resources/lib/ooui/themes/wikimediaui/images/icons/articleNotFound-rtl.svg
resources/lib/ooui/themes/wikimediaui/images/icons/settings-invert.png
resources/lib/ooui/themes/wikimediaui/images/icons/settings-invert.svg
resources/lib/ooui/themes/wikimediaui/images/icons/settings-progressive.png
resources/lib/ooui/themes/wikimediaui/images/icons/settings-progressive.svg
resources/lib/ooui/themes/wikimediaui/images/icons/settings.png
resources/lib/ooui/themes/wikimediaui/images/icons/settings.svg
resources/lib/ooui/themes/wikimediaui/images/icons/web-invert.png [deleted file]
resources/lib/ooui/themes/wikimediaui/images/icons/web-invert.svg [deleted file]
resources/lib/ooui/themes/wikimediaui/images/icons/web-progressive.png [deleted file]
resources/lib/ooui/themes/wikimediaui/images/icons/web-progressive.svg [deleted file]
resources/lib/ooui/themes/wikimediaui/images/icons/web.png [deleted file]
resources/lib/ooui/themes/wikimediaui/images/icons/web.svg [deleted file]
resources/src/jquery.tablesorter.styles/jquery.tablesorter.styles.less
resources/src/jquery/jquery.byteLength.js [deleted file]
resources/src/jquery/jquery.suggestions.js
resources/src/mediawiki.action/mediawiki.action.view.dblClickEdit.js
resources/src/mediawiki.content.json.less
resources/src/mediawiki.language/mediawiki.language.specialCharacters.js
resources/src/mediawiki.special.apisandbox/apisandbox.js
resources/src/mediawiki.special.block.js
resources/src/mediawiki.special.preferences.styles.ooui.less
resources/src/mediawiki.widgets/mw.widgets.CopyTextLayout.css [new file with mode: 0644]
resources/src/mediawiki.widgets/mw.widgets.CopyTextLayout.js [new file with mode: 0644]
tests/phpunit/MediaWikiTestCase.php
tests/phpunit/includes/BlockTest.php [deleted file]
tests/phpunit/includes/EditPageTest.php
tests/phpunit/includes/LinkerTest.php
tests/phpunit/includes/MediaWikiVersionFetcherTest.php
tests/phpunit/includes/MovePageTest.php
tests/phpunit/includes/OutputPageTest.php
tests/phpunit/includes/Permissions/PermissionManagerTest.php
tests/phpunit/includes/RevisionDbTestBase.php
tests/phpunit/includes/TemplateCategoriesTest.php
tests/phpunit/includes/TitleMethodsTest.php
tests/phpunit/includes/TitlePermissionTest.php
tests/phpunit/includes/TitleTest.php
tests/phpunit/includes/WebRequestTest.php
tests/phpunit/includes/actions/ActionTest.php
tests/phpunit/includes/api/ApiBaseTest.php
tests/phpunit/includes/api/ApiBlockInfoTraitTest.php
tests/phpunit/includes/api/ApiBlockTest.php
tests/phpunit/includes/api/ApiDeleteTest.php
tests/phpunit/includes/api/ApiEditPageTest.php
tests/phpunit/includes/api/ApiMainTest.php
tests/phpunit/includes/api/ApiMoveTest.php
tests/phpunit/includes/api/ApiParseTest.php
tests/phpunit/includes/api/ApiQueryBlocksTest.php
tests/phpunit/includes/api/ApiQueryInfoTest.php
tests/phpunit/includes/api/ApiQueryUserInfoTest.php
tests/phpunit/includes/api/ApiStashEditTest.php
tests/phpunit/includes/api/ApiUnblockTest.php
tests/phpunit/includes/api/ApiUserrightsTest.php
tests/phpunit/includes/auth/AuthManagerTest.php
tests/phpunit/includes/auth/CheckBlocksSecondaryAuthenticationProviderTest.php
tests/phpunit/includes/auth/TemporaryPasswordPrimaryAuthenticationProviderTest.php
tests/phpunit/includes/block/BlockManagerTest.php
tests/phpunit/includes/block/BlockRestrictionStoreTest.php
tests/phpunit/includes/block/DatabaseBlockTest.php [new file with mode: 0644]
tests/phpunit/includes/changes/OldChangesListTest.php
tests/phpunit/includes/db/LBFactoryTest.php
tests/phpunit/includes/debug/logger/LegacyLoggerTest.php
tests/phpunit/includes/debug/logger/monolog/LineFormatterTest.php
tests/phpunit/includes/deferred/DeferredUpdatesTest.php
tests/phpunit/includes/diff/TextSlotDiffRendererTest.php
tests/phpunit/includes/libs/MWMessagePackTest.php
tests/phpunit/includes/libs/rdbms/ChronologyProtectorTest.php [new file with mode: 0644]
tests/phpunit/includes/objectcache/RESTBagOStuffTest.php
tests/phpunit/includes/page/ArticleTablesTest.php
tests/phpunit/includes/page/WikiPageDbTestBase.php
tests/phpunit/includes/parser/ParserFactoryTest.php
tests/phpunit/includes/parser/ParserTest.php [new file with mode: 0644]
tests/phpunit/includes/resourceloader/ResourceLoaderSkinModuleTest.php
tests/phpunit/includes/resourceloader/ResourceLoaderStartUpModuleTest.php
tests/phpunit/includes/shell/ShellTest.php
tests/phpunit/includes/specialpage/FormSpecialPageTestCase.php
tests/phpunit/includes/specials/SpecialBlockTest.php
tests/phpunit/includes/specials/pagers/BlockListPagerTest.php
tests/phpunit/includes/title/NamespaceInfoTest.php
tests/phpunit/includes/user/LocalIdLookupTest.php
tests/phpunit/includes/user/PasswordResetTest.php
tests/phpunit/includes/user/UserGroupMembershipTest.php
tests/phpunit/includes/user/UserTest.php
tests/phpunit/includes/watcheditem/WatchedItemQueryServiceUnitTest.php
tests/phpunit/includes/watcheditem/WatchedItemStoreUnitTest.php
tests/selenium/wdio.conf.js
thumb.php

index d9ac7bf..d372db8 100644 (file)
@@ -35,10 +35,19 @@ For notes on 1.33.x and older releases, see HISTORY.
   module or will be generated by Mediawiki itself (depending on the set-up).
 
 ==== Changed configuration ====
+* $wgUseCdn, $wgCdnServers, $wgCdnServersNoPurge, and $wgCdnMaxAge – These four
+  CDN-related config variables have been renamed from being specific to Squid –
+  they were previously $wgUseSquid, $wgSquidServers, $wgSquidServersNoPurge, and
+  $wgSquidMaxage respectively. This aligns them with the related existing
+  variable $wgCdnMaxageLagged. The previous configuration variable names are
+  deprecated, but will be used as the fall back if they are still set.
+  Note that wgSquidPurgeUseHostHeader has not been renamed, as it is deprecated.
 * …
 
 ==== Removed configuration ====
-* …
+* $wgWikiDiff2MovedParagraphDetectionCutoff — If you still want a custom change
+  size threshold, please specify in php.ini, using the configuration variable
+  wikidiff2.moved_paragraph_detection_cutoff.
 
 === New user-facing features in 1.34 ===
 * …
@@ -54,12 +63,13 @@ For notes on 1.33.x and older releases, see HISTORY.
 
 ==== Changed external libraries ====
 * Updated Mustache from 1.0.0 to v3.0.1.
-* Updated OOUI from v0.31.3 to v0.31.5.
+* Updated OOUI from v0.31.3 to v0.32.0.
 * Updated composer/semver from 1.4.2 to 1.5.0.
 * Updated composer/spdx-licenses from 1.4.0 to 1.5.1 (dev-only).
 * Updated mediawiki/codesniffer from 25.0.0 to 26.0.0 (dev-only).
 * Updated cssjanus/cssjanus from 1.2.1 to 1.3.0.
 * Updated wikimedia/at-ease from 1.2.0 to 2.0.0.
+* Updated wikimedia/remex-html from 2.0.1 to 2.0.3.
 * …
 
 ==== Removed external libraries ====
@@ -173,6 +183,14 @@ because of Phabricator reports.
 * The LegacyHookPreAuthenticationProvider class, deprecated since its creation
   in 1.27, has been removed.
 * IP::isValidBlock(), deprecated in 1.30, has been removed.
+* WikiPage::prepareContentForEdit now doesn't accept an integer for $revision,
+  was deprecated in 1.25.
+* The jquery.byteLength module, deprecated in 1.31, was removed.
+  Use the mediawiki.String module instead.
+* mw.language.specialCharacters, deprecated in 1.33, has been removed.
+  Use require( 'mediawiki.language.specialCharacters' ) instead.
+* EditPage::submit(), deprecated in 1.29, has been removed. Used $this->edit()
+  directly.
 * …
 
 === Deprecations in 1.34 ===
@@ -208,9 +226,17 @@ because of Phabricator reports.
 * The getSubjectPage, getTalkPage, and getOtherPage of Title are deprecated.
   Use NamespaceInfo's getSubjectPage, getTalkPage, and getAssociatedPage.
 * MWMessagePack class, no longer used, has been deprecated in 1.34.
-* The Block class is separated into Block (for blocks stored in the database),
-  and SystemBlock (for temporary blocks created by the system). SystemBlock
-  should be used when creating any temporary blocks.
+* The Block class is separated into DatabaseBlock (for blocks stored in the
+  database), and SystemBlock (for temporary blocks created by the system).
+  SystemBlock should be used when creating any temporary blocks. Block is
+  a deprecated alias for DatabaseBlock.
+* Parser::$mConf is deprecated. It will be removed entirely in a later version.
+  Some context can be found at T224165.
+* Constructing Parser directly is deprecated. Obtain one from ParserFactory.
+* Title::moveSubpages is deprecated. Use MovePage::moveSubpages or
+  MovePage::moveSubpagesIfAllowed.
+* The MWNamespace class is deprecated. Use MediaWikiServices::getNamespaceInfo.
+* (T62260) Hard deprecate Language::getExtraUserToggles() method.
 
 === Other changes in 1.34 ===
 * …
index 1b3b150..a9b65fa 100644 (file)
@@ -208,7 +208,7 @@ $wgAutoloadLocalClasses = [
        'BitmapHandler_ClientOnly' => __DIR__ . '/includes/media/BitmapHandler_ClientOnly.php',
        'BitmapMetadataHandler' => __DIR__ . '/includes/media/BitmapMetadataHandler.php',
        'Blob' => __DIR__ . '/includes/libs/rdbms/encasing/Blob.php',
-       'Block' => __DIR__ . '/includes/Block.php',
+       'Block' => __DIR__ . '/includes/block/DatabaseBlock.php',
        'BlockLevelPass' => __DIR__ . '/includes/parser/BlockLevelPass.php',
        'BlockListPager' => __DIR__ . '/includes/specials/pagers/BlockListPager.php',
        'BlockLogFormatter' => __DIR__ . '/includes/logging/BlockLogFormatter.php',
@@ -1497,6 +1497,7 @@ $wgAutoloadLocalClasses = [
        'TrackBlobs' => __DIR__ . '/maintenance/storage/trackBlobs.php',
        'TrackingCategories' => __DIR__ . '/includes/TrackingCategories.php',
        'TraditionalImageGallery' => __DIR__ . '/includes/gallery/TraditionalImageGallery.php',
+       'TransactionRoundAwareUpdate' => __DIR__ . '/includes/deferred/TransactionRoundAwareUpdate.php',
        'TransactionRoundDefiningUpdate' => __DIR__ . '/includes/deferred/TransactionRoundDefiningUpdate.php',
        'TransformParameterError' => __DIR__ . '/includes/media/TransformParameterError.php',
        'TransformTooBigImageAreaError' => __DIR__ . '/includes/media/TransformTooBigImageAreaError.php',
@@ -1637,6 +1638,7 @@ $wgAutoloadLocalClasses = [
        'Wikimedia\\Rdbms\\DBError' => __DIR__ . '/includes/libs/rdbms/exception/DBError.php',
        'Wikimedia\\Rdbms\\DBExpectedError' => __DIR__ . '/includes/libs/rdbms/exception/DBExpectedError.php',
        'Wikimedia\\Rdbms\\DBMasterPos' => __DIR__ . '/includes/libs/rdbms/database/position/DBMasterPos.php',
+       'Wikimedia\\Rdbms\\DBQueryDisconnectedError' => __DIR__ . '/includes/libs/rdbms/exception/DBQueryDisconnectedError.php',
        'Wikimedia\\Rdbms\\DBQueryError' => __DIR__ . '/includes/libs/rdbms/exception/DBQueryError.php',
        'Wikimedia\\Rdbms\\DBQueryTimeoutError' => __DIR__ . '/includes/libs/rdbms/exception/DBQueryTimeoutError.php',
        'Wikimedia\\Rdbms\\DBReadOnlyError' => __DIR__ . '/includes/libs/rdbms/exception/DBReadOnlyError.php',
@@ -1655,6 +1657,7 @@ $wgAutoloadLocalClasses = [
        'Wikimedia\\Rdbms\\DatabaseSqlite' => __DIR__ . '/includes/libs/rdbms/database/DatabaseSqlite.php',
        'Wikimedia\\Rdbms\\FakeResultWrapper' => __DIR__ . '/includes/libs/rdbms/database/resultwrapper/FakeResultWrapper.php',
        'Wikimedia\\Rdbms\\Field' => __DIR__ . '/includes/libs/rdbms/field/Field.php',
+       'Wikimedia\\Rdbms\\GeneralizedSql' => __DIR__ . '/includes/libs/rdbms/database/utils/GeneralizedSql.php',
        'Wikimedia\\Rdbms\\IBlob' => __DIR__ . '/includes/libs/rdbms/encasing/IBlob.php',
        'Wikimedia\\Rdbms\\IDatabase' => __DIR__ . '/includes/libs/rdbms/database/IDatabase.php',
        'Wikimedia\\Rdbms\\ILBFactory' => __DIR__ . '/includes/libs/rdbms/lbfactory/ILBFactory.php',
index 11680ff..c4ed4e3 100644 (file)
@@ -27,7 +27,7 @@
                "ext-xml": "*",
                "guzzlehttp/guzzle": "6.3.3",
                "liuggio/statsd-php-client": "1.0.18",
-               "oojs/oojs-ui": "0.31.6",
+               "oojs/oojs-ui": "0.32.0",
                "pear/mail": "1.4.1",
                "pear/mail_mime": "1.10.2",
                "pear/net_smtp": "1.8.1",
@@ -47,7 +47,7 @@
                "wikimedia/php-session-serializer": "1.0.7",
                "wikimedia/purtle": "1.0.7",
                "wikimedia/relpath": "2.1.1",
-               "wikimedia/remex-html": "2.0.1",
+               "wikimedia/remex-html": "2.0.3",
                "wikimedia/running-stat": "1.2.1",
                "wikimedia/scoped-callback": "3.0.0",
                "wikimedia/utfnormal": "2.0.0",
index 1419d0a..7f8b192 100644 (file)
@@ -3568,7 +3568,10 @@ hook. If your extension absolutely, positively must prevent some files from
 being uploaded, use UploadVerifyFile or UploadVerifyUpload.
 $upload: (object) An instance of UploadBase, with all info about the upload
 $user: (object) An instance of User, the user uploading this file
-$props: (array) File properties, as returned by FSFile::getPropsFromPath()
+$props: (array|null) File properties, as returned by
+  MWFileProps::getPropsFromPath(). Note this is not always guaranteed to be set,
+  e.g. in test scenarios. Call MWFileProps::getPropsFromPath() yourself in case
+  you need the information.
 &$error: output: If the file stashing should be prevented, set this to the
   reason in the form of [ messagename, param1, param2, ... ] or a
   MessageSpecifier instance (you might want to use ApiMessage to provide machine
@@ -3597,7 +3600,10 @@ MIME type (same as UploadVerifyFile) and the information entered by the user
 (upload comment, file page contents etc.).
 $upload: (object) An instance of UploadBase, with all info about the upload
 $user: (object) An instance of User, the user uploading this file
-$props: (array) File properties, as returned by FSFile::getPropsFromPath()
+$props: (array|null) File properties, as returned by
+  MWFileProps::getPropsFromPath(). Note this is not always guaranteed to be set,
+  e.g. in test scenarios. Call MWFileProps::getPropsFromPath() yourself in case
+  you need the information.
 $comment: (string) Upload log comment (also used as edit summary)
 $pageText: (string) File description page text (only used for new uploads)
 &$error: output: If the file upload should be prevented, set this to the reason
index 5f889ad..323c5d3 100644 (file)
@@ -179,8 +179,7 @@ class AjaxResponse {
                        # If CDN caches are configured, tell them to cache the response,
                        # and tell the client to always check with the CDN. Otherwise,
                        # tell the client to use a cached copy, without a way to purge it.
-
-                       if ( $this->mConfig->get( 'UseSquid' ) ) {
+                       if ( $this->mConfig->get( 'UseCdn' ) ) {
                                # Expect explicit purge of the proxy cache, but require end user agents
                                # to revalidate against the proxy on each visit.
                                # Surrogate-Control controls our CDN, Cache-Control downstream caches
diff --git a/includes/Block.php b/includes/Block.php
deleted file mode 100644 (file)
index 5b0d256..0000000
+++ /dev/null
@@ -1,1572 +0,0 @@
-<?php
-/**
- * Class for blocks stored in the database.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- * @file
- */
-
-use Wikimedia\Rdbms\Database;
-use Wikimedia\Rdbms\IDatabase;
-use MediaWiki\Block\AbstractBlock;
-use MediaWiki\Block\BlockRestrictionStore;
-use MediaWiki\Block\Restriction\Restriction;
-use MediaWiki\Block\Restriction\NamespaceRestriction;
-use MediaWiki\Block\Restriction\PageRestriction;
-use MediaWiki\MediaWikiServices;
-
-/**
- * Blocks (as opposed to system blocks) are stored in the database, may
- * give rise to autoblocks and may be tracked with cookies. Blocks are
- * more customizable than system blocks: they may be hardblocks, and
- * they may be sitewide or partial.
- */
-class Block extends AbstractBlock {
-       /** @var bool */
-       public $mAuto;
-
-       /** @var int */
-       public $mParentBlockId;
-
-       /** @var int */
-       private $mId;
-
-       /** @var bool */
-       private $mFromMaster;
-
-       /** @var int Hack for foreign blocking (CentralAuth) */
-       private $forcedTargetID;
-
-       /** @var bool */
-       private $isHardblock;
-
-       /** @var bool */
-       private $isAutoblocking;
-
-       /** @var Restriction[] */
-       private $restrictions;
-
-       /**
-        * Create a new block with specified option parameters on a user, IP or IP range.
-        *
-        * @param array $options Parameters of the block:
-        *     user int             Override target user ID (for foreign users)
-        *     auto bool            Is this an automatic block?
-        *     expiry string        Timestamp of expiration of the block or 'infinity'
-        *     anonOnly bool        Only disallow anonymous actions
-        *     createAccount bool   Disallow creation of new accounts
-        *     enableAutoblock bool Enable automatic blocking
-        *     hideName bool        Hide the target user name
-        *     blockEmail bool      Disallow sending emails
-        *     allowUsertalk bool   Allow the target to edit its own talk page
-        *     sitewide bool        Disallow editing all pages and all contribution
-        *                          actions, except those specifically allowed by
-        *                          other block flags
-        *
-        * @since 1.26 $options array
-        */
-       public function __construct( array $options = [] ) {
-               parent::__construct( $options );
-
-               $defaults = [
-                       'user'            => null,
-                       'auto'            => false,
-                       'expiry'          => '',
-                       'anonOnly'        => false,
-                       'createAccount'   => false,
-                       'enableAutoblock' => false,
-                       'hideName'        => false,
-                       'blockEmail'      => false,
-                       'allowUsertalk'   => false,
-                       'sitewide'        => true,
-               ];
-
-               $options += $defaults;
-
-               if ( $this->target instanceof User && $options['user'] ) {
-                       # Needed for foreign users
-                       $this->forcedTargetID = $options['user'];
-               }
-
-               $this->setExpiry( wfGetDB( DB_REPLICA )->decodeExpiry( $options['expiry'] ) );
-
-               # Boolean settings
-               $this->mAuto = (bool)$options['auto'];
-               $this->setHideName( (bool)$options['hideName'] );
-               $this->isHardblock( !$options['anonOnly'] );
-               $this->isAutoblocking( (bool)$options['enableAutoblock'] );
-               $this->isSitewide( (bool)$options['sitewide'] );
-               $this->isEmailBlocked( (bool)$options['blockEmail'] );
-               $this->isCreateAccountBlocked( (bool)$options['createAccount'] );
-               $this->isUsertalkEditAllowed( (bool)$options['allowUsertalk'] );
-
-               $this->mFromMaster = false;
-       }
-
-       /**
-        * Load a block from the block id.
-        *
-        * @param int $id Block id to search for
-        * @return Block|null
-        */
-       public static function newFromID( $id ) {
-               $dbr = wfGetDB( DB_REPLICA );
-               $blockQuery = self::getQueryInfo();
-               $res = $dbr->selectRow(
-                       $blockQuery['tables'],
-                       $blockQuery['fields'],
-                       [ 'ipb_id' => $id ],
-                       __METHOD__,
-                       [],
-                       $blockQuery['joins']
-               );
-               if ( $res ) {
-                       return self::newFromRow( $res );
-               } else {
-                       return null;
-               }
-       }
-
-       /**
-        * Return the list of ipblocks fields that should be selected to create
-        * a new block.
-        * @deprecated since 1.31, use self::getQueryInfo() instead.
-        * @return array
-        */
-       public static function selectFields() {
-               global $wgActorTableSchemaMigrationStage;
-
-               if ( $wgActorTableSchemaMigrationStage & SCHEMA_COMPAT_READ_NEW ) {
-                       // If code is using this instead of self::getQueryInfo(), there's a
-                       // decent chance it's going to try to directly access
-                       // $row->ipb_by or $row->ipb_by_text and we can't give it
-                       // useful values here once those aren't being used anymore.
-                       throw new BadMethodCallException(
-                               'Cannot use ' . __METHOD__
-                                       . ' when $wgActorTableSchemaMigrationStage has SCHEMA_COMPAT_READ_NEW'
-                       );
-               }
-
-               wfDeprecated( __METHOD__, '1.31' );
-               return [
-                       'ipb_id',
-                       'ipb_address',
-                       'ipb_by',
-                       'ipb_by_text',
-                       'ipb_by_actor' => 'NULL',
-                       'ipb_timestamp',
-                       'ipb_auto',
-                       'ipb_anon_only',
-                       'ipb_create_account',
-                       'ipb_enable_autoblock',
-                       'ipb_expiry',
-                       'ipb_deleted',
-                       'ipb_block_email',
-                       'ipb_allow_usertalk',
-                       'ipb_parent_block_id',
-                       'ipb_sitewide',
-               ] + CommentStore::getStore()->getFields( 'ipb_reason' );
-       }
-
-       /**
-        * Return the tables, fields, and join conditions to be selected to create
-        * a new block object.
-        * @since 1.31
-        * @return array With three keys:
-        *   - tables: (string[]) to include in the `$table` to `IDatabase->select()`
-        *   - fields: (string[]) to include in the `$vars` to `IDatabase->select()`
-        *   - joins: (array) to include in the `$join_conds` to `IDatabase->select()`
-        */
-       public static function getQueryInfo() {
-               $commentQuery = CommentStore::getStore()->getJoin( 'ipb_reason' );
-               $actorQuery = ActorMigration::newMigration()->getJoin( 'ipb_by' );
-               return [
-                       'tables' => [ 'ipblocks' ] + $commentQuery['tables'] + $actorQuery['tables'],
-                       'fields' => [
-                               'ipb_id',
-                               'ipb_address',
-                               'ipb_timestamp',
-                               'ipb_auto',
-                               'ipb_anon_only',
-                               'ipb_create_account',
-                               'ipb_enable_autoblock',
-                               'ipb_expiry',
-                               'ipb_deleted',
-                               'ipb_block_email',
-                               'ipb_allow_usertalk',
-                               'ipb_parent_block_id',
-                               'ipb_sitewide',
-                       ] + $commentQuery['fields'] + $actorQuery['fields'],
-                       'joins' => $commentQuery['joins'] + $actorQuery['joins'],
-               ];
-       }
-
-       /**
-        * Check if two blocks are effectively equal.  Doesn't check irrelevant things like
-        * the blocking user or the block timestamp, only things which affect the blocked user
-        *
-        * @param Block $block
-        *
-        * @return bool
-        */
-       public function equals( Block $block ) {
-               return (
-                       (string)$this->target == (string)$block->target
-                       && $this->type == $block->type
-                       && $this->mAuto == $block->mAuto
-                       && $this->isHardblock() == $block->isHardblock()
-                       && $this->isCreateAccountBlocked() == $block->isCreateAccountBlocked()
-                       && $this->getExpiry() == $block->getExpiry()
-                       && $this->isAutoblocking() == $block->isAutoblocking()
-                       && $this->getHideName() == $block->getHideName()
-                       && $this->isEmailBlocked() == $block->isEmailBlocked()
-                       && $this->isUsertalkEditAllowed() == $block->isUsertalkEditAllowed()
-                       && $this->getReason() == $block->getReason()
-                       && $this->isSitewide() == $block->isSitewide()
-                       // Block::getRestrictions() may perform a database query, so keep it at
-                       // the end.
-                       && $this->getBlockRestrictionStore()->equals(
-                               $this->getRestrictions(), $block->getRestrictions()
-                       )
-               );
-       }
-
-       /**
-        * Load a block from the database which affects the already-set $this->target:
-        *     1) A block directly on the given user or IP
-        *     2) A rangeblock encompassing the given IP (smallest first)
-        *     3) An autoblock on the given IP
-        * @param User|string|null $vagueTarget Also search for blocks affecting this target.  Doesn't
-        *     make any sense to use TYPE_AUTO / TYPE_ID here. Leave blank to skip IP lookups.
-        * @throws MWException
-        * @return bool Whether a relevant block was found
-        */
-       protected function newLoad( $vagueTarget = null ) {
-               $db = wfGetDB( $this->mFromMaster ? DB_MASTER : DB_REPLICA );
-
-               if ( $this->type !== null ) {
-                       $conds = [
-                               'ipb_address' => [ (string)$this->target ],
-                       ];
-               } else {
-                       $conds = [ 'ipb_address' => [] ];
-               }
-
-               # Be aware that the != '' check is explicit, since empty values will be
-               # passed by some callers (T31116)
-               if ( $vagueTarget != '' ) {
-                       list( $target, $type ) = self::parseTarget( $vagueTarget );
-                       switch ( $type ) {
-                               case self::TYPE_USER:
-                                       # Slightly weird, but who are we to argue?
-                                       $conds['ipb_address'][] = (string)$target;
-                                       break;
-
-                               case self::TYPE_IP:
-                                       $conds['ipb_address'][] = (string)$target;
-                                       $conds[] = self::getRangeCond( IP::toHex( $target ) );
-                                       $conds = $db->makeList( $conds, LIST_OR );
-                                       break;
-
-                               case self::TYPE_RANGE:
-                                       list( $start, $end ) = IP::parseRange( $target );
-                                       $conds['ipb_address'][] = (string)$target;
-                                       $conds[] = self::getRangeCond( $start, $end );
-                                       $conds = $db->makeList( $conds, LIST_OR );
-                                       break;
-
-                               default:
-                                       throw new MWException( "Tried to load block with invalid type" );
-                       }
-               }
-
-               $blockQuery = self::getQueryInfo();
-               $res = $db->select(
-                       $blockQuery['tables'], $blockQuery['fields'], $conds, __METHOD__, [], $blockQuery['joins']
-               );
-
-               # This result could contain a block on the user, a block on the IP, and a russian-doll
-               # set of rangeblocks.  We want to choose the most specific one, so keep a leader board.
-               $bestRow = null;
-
-               # Lower will be better
-               $bestBlockScore = 100;
-
-               foreach ( $res as $row ) {
-                       $block = self::newFromRow( $row );
-
-                       # Don't use expired blocks
-                       if ( $block->isExpired() ) {
-                               continue;
-                       }
-
-                       # Don't use anon only blocks on users
-                       if ( $this->type == self::TYPE_USER && !$block->isHardblock() ) {
-                               continue;
-                       }
-
-                       if ( $block->getType() == self::TYPE_RANGE ) {
-                               # This is the number of bits that are allowed to vary in the block, give
-                               # or take some floating point errors
-                               $target = $block->getTarget();
-                               $max = IP::isIPv6( $target ) ? 128 : 32;
-                               list( $network, $bits ) = IP::parseCIDR( $target );
-                               $size = $max - $bits;
-
-                               # Rank a range block covering a single IP equally with a single-IP block
-                               $score = self::TYPE_RANGE - 1 + ( $size / $max );
-
-                       } else {
-                               $score = $block->getType();
-                       }
-
-                       if ( $score < $bestBlockScore ) {
-                               $bestBlockScore = $score;
-                               $bestRow = $row;
-                       }
-               }
-
-               if ( $bestRow !== null ) {
-                       $this->initFromRow( $bestRow );
-                       return true;
-               } else {
-                       return false;
-               }
-       }
-
-       /**
-        * Get a set of SQL conditions which will select rangeblocks encompassing a given range
-        * @param string $start Hexadecimal IP representation
-        * @param string|null $end Hexadecimal IP representation, or null to use $start = $end
-        * @return string
-        */
-       public static function getRangeCond( $start, $end = null ) {
-               if ( $end === null ) {
-                       $end = $start;
-               }
-               # Per T16634, we want to include relevant active rangeblocks; for
-               # rangeblocks, we want to include larger ranges which enclose the given
-               # range. We know that all blocks must be smaller than $wgBlockCIDRLimit,
-               # so we can improve performance by filtering on a LIKE clause
-               $chunk = self::getIpFragment( $start );
-               $dbr = wfGetDB( DB_REPLICA );
-               $like = $dbr->buildLike( $chunk, $dbr->anyString() );
-
-               # Fairly hard to make a malicious SQL statement out of hex characters,
-               # but stranger things have happened...
-               $safeStart = $dbr->addQuotes( $start );
-               $safeEnd = $dbr->addQuotes( $end );
-
-               return $dbr->makeList(
-                       [
-                               "ipb_range_start $like",
-                               "ipb_range_start <= $safeStart",
-                               "ipb_range_end >= $safeEnd",
-                       ],
-                       LIST_AND
-               );
-       }
-
-       /**
-        * Get the component of an IP address which is certain to be the same between an IP
-        * address and a rangeblock containing that IP address.
-        * @param string $hex Hexadecimal IP representation
-        * @return string
-        */
-       protected static function getIpFragment( $hex ) {
-               global $wgBlockCIDRLimit;
-               if ( substr( $hex, 0, 3 ) == 'v6-' ) {
-                       return 'v6-' . substr( substr( $hex, 3 ), 0, floor( $wgBlockCIDRLimit['IPv6'] / 4 ) );
-               } else {
-                       return substr( $hex, 0, floor( $wgBlockCIDRLimit['IPv4'] / 4 ) );
-               }
-       }
-
-       /**
-        * Given a database row from the ipblocks table, initialize
-        * member variables
-        * @param stdClass $row A row from the ipblocks table
-        */
-       protected function initFromRow( $row ) {
-               $this->setTarget( $row->ipb_address );
-               $this->setBlocker( User::newFromAnyId(
-                       $row->ipb_by, $row->ipb_by_text, $row->ipb_by_actor ?? null
-               ) );
-
-               $this->setTimestamp( wfTimestamp( TS_MW, $row->ipb_timestamp ) );
-               $this->mAuto = $row->ipb_auto;
-               $this->setHideName( $row->ipb_deleted );
-               $this->mId = (int)$row->ipb_id;
-               $this->mParentBlockId = $row->ipb_parent_block_id;
-
-               // I wish I didn't have to do this
-               $db = wfGetDB( DB_REPLICA );
-               $this->setExpiry( $db->decodeExpiry( $row->ipb_expiry ) );
-               $this->setReason(
-                       CommentStore::getStore()
-                       // Legacy because $row may have come from self::selectFields()
-                       ->getCommentLegacy( $db, 'ipb_reason', $row )->text
-               );
-
-               $this->isHardblock( !$row->ipb_anon_only );
-               $this->isAutoblocking( $row->ipb_enable_autoblock );
-               $this->isSitewide( (bool)$row->ipb_sitewide );
-
-               $this->isCreateAccountBlocked( $row->ipb_create_account );
-               $this->isEmailBlocked( $row->ipb_block_email );
-               $this->isUsertalkEditAllowed( $row->ipb_allow_usertalk );
-       }
-
-       /**
-        * Create a new Block object from a database row
-        * @param stdClass $row Row from the ipblocks table
-        * @return Block
-        */
-       public static function newFromRow( $row ) {
-               $block = new Block;
-               $block->initFromRow( $row );
-               return $block;
-       }
-
-       /**
-        * Delete the row from the IP blocks table.
-        *
-        * @throws MWException
-        * @return bool
-        */
-       public function delete() {
-               if ( wfReadOnly() ) {
-                       return false;
-               }
-
-               if ( !$this->getId() ) {
-                       throw new MWException( "Block::delete() requires that the mId member be filled\n" );
-               }
-
-               $dbw = wfGetDB( DB_MASTER );
-
-               $this->getBlockRestrictionStore()->deleteByParentBlockId( $this->getId() );
-               $dbw->delete( 'ipblocks', [ 'ipb_parent_block_id' => $this->getId() ], __METHOD__ );
-
-               $this->getBlockRestrictionStore()->deleteByBlockId( $this->getId() );
-               $dbw->delete( 'ipblocks', [ 'ipb_id' => $this->getId() ], __METHOD__ );
-
-               return $dbw->affectedRows() > 0;
-       }
-
-       /**
-        * Insert a block into the block table. Will fail if there is a conflicting
-        * block (same name and options) already in the database.
-        *
-        * @param IDatabase|null $dbw If you have one available
-        * @return bool|array False on failure, assoc array on success:
-        *      ('id' => block ID, 'autoIds' => array of autoblock IDs)
-        */
-       public function insert( $dbw = null ) {
-               global $wgBlockDisablesLogin;
-
-               if ( !$this->getBlocker() || $this->getBlocker()->getName() === '' ) {
-                       throw new MWException( 'Cannot insert a block without a blocker set' );
-               }
-
-               wfDebug( "Block::insert; timestamp {$this->mTimestamp}\n" );
-
-               if ( $dbw === null ) {
-                       $dbw = wfGetDB( DB_MASTER );
-               }
-
-               self::purgeExpired();
-
-               $row = $this->getDatabaseArray( $dbw );
-
-               $dbw->insert( 'ipblocks', $row, __METHOD__, [ 'IGNORE' ] );
-               $affected = $dbw->affectedRows();
-               if ( $affected ) {
-                       $this->setId( $dbw->insertId() );
-                       if ( $this->restrictions ) {
-                               $this->getBlockRestrictionStore()->insert( $this->restrictions );
-                       }
-               }
-
-               # Don't collide with expired blocks.
-               # Do this after trying to insert to avoid locking.
-               if ( !$affected ) {
-                       # T96428: The ipb_address index uses a prefix on a field, so
-                       # use a standard SELECT + DELETE to avoid annoying gap locks.
-                       $ids = $dbw->selectFieldValues( 'ipblocks',
-                               'ipb_id',
-                               [
-                                       'ipb_address' => $row['ipb_address'],
-                                       'ipb_user' => $row['ipb_user'],
-                                       'ipb_expiry < ' . $dbw->addQuotes( $dbw->timestamp() )
-                               ],
-                               __METHOD__
-                       );
-                       if ( $ids ) {
-                               $dbw->delete( 'ipblocks', [ 'ipb_id' => $ids ], __METHOD__ );
-                               $this->getBlockRestrictionStore()->deleteByBlockId( $ids );
-                               $dbw->insert( 'ipblocks', $row, __METHOD__, [ 'IGNORE' ] );
-                               $affected = $dbw->affectedRows();
-                               $this->setId( $dbw->insertId() );
-                               if ( $this->restrictions ) {
-                                       $this->getBlockRestrictionStore()->insert( $this->restrictions );
-                               }
-                       }
-               }
-
-               if ( $affected ) {
-                       $auto_ipd_ids = $this->doRetroactiveAutoblock();
-
-                       if ( $wgBlockDisablesLogin && $this->target instanceof User ) {
-                               // Change user login token to force them to be logged out.
-                               $this->target->setToken();
-                               $this->target->saveSettings();
-                       }
-
-                       return [ 'id' => $this->mId, 'autoIds' => $auto_ipd_ids ];
-               }
-
-               return false;
-       }
-
-       /**
-        * Update a block in the DB with new parameters.
-        * The ID field needs to be loaded first.
-        *
-        * @return bool|array False on failure, array on success:
-        *   ('id' => block ID, 'autoIds' => array of autoblock IDs)
-        */
-       public function update() {
-               wfDebug( "Block::update; timestamp {$this->mTimestamp}\n" );
-               $dbw = wfGetDB( DB_MASTER );
-
-               $dbw->startAtomic( __METHOD__ );
-
-               $result = $dbw->update(
-                       'ipblocks',
-                       $this->getDatabaseArray( $dbw ),
-                       [ 'ipb_id' => $this->getId() ],
-                       __METHOD__
-               );
-
-               // Only update the restrictions if they have been modified.
-               if ( $this->restrictions !== null ) {
-                       // An empty array should remove all of the restrictions.
-                       if ( empty( $this->restrictions ) ) {
-                               $success = $this->getBlockRestrictionStore()->deleteByBlockId( $this->getId() );
-                       } else {
-                               $success = $this->getBlockRestrictionStore()->update( $this->restrictions );
-                       }
-                       // Update the result. The first false is the result, otherwise, true.
-                       $result = $result && $success;
-               }
-
-               if ( $this->isAutoblocking() ) {
-                       // update corresponding autoblock(s) (T50813)
-                       $dbw->update(
-                               'ipblocks',
-                               $this->getAutoblockUpdateArray( $dbw ),
-                               [ 'ipb_parent_block_id' => $this->getId() ],
-                               __METHOD__
-                       );
-
-                       // Only update the restrictions if they have been modified.
-                       if ( $this->restrictions !== null ) {
-                               $this->getBlockRestrictionStore()->updateByParentBlockId( $this->getId(), $this->restrictions );
-                       }
-               } else {
-                       // autoblock no longer required, delete corresponding autoblock(s)
-                       $this->getBlockRestrictionStore()->deleteByParentBlockId( $this->getId() );
-                       $dbw->delete(
-                               'ipblocks',
-                               [ 'ipb_parent_block_id' => $this->getId() ],
-                               __METHOD__
-                       );
-               }
-
-               $dbw->endAtomic( __METHOD__ );
-
-               if ( $result ) {
-                       $auto_ipd_ids = $this->doRetroactiveAutoblock();
-                       return [ 'id' => $this->mId, 'autoIds' => $auto_ipd_ids ];
-               }
-
-               return $result;
-       }
-
-       /**
-        * Get an array suitable for passing to $dbw->insert() or $dbw->update()
-        * @param IDatabase $dbw
-        * @return array
-        */
-       protected function getDatabaseArray( IDatabase $dbw ) {
-               $expiry = $dbw->encodeExpiry( $this->getExpiry() );
-
-               if ( $this->forcedTargetID ) {
-                       $uid = $this->forcedTargetID;
-               } else {
-                       $uid = $this->target instanceof User ? $this->target->getId() : 0;
-               }
-
-               $a = [
-                       'ipb_address'          => (string)$this->target,
-                       'ipb_user'             => $uid,
-                       'ipb_timestamp'        => $dbw->timestamp( $this->getTimestamp() ),
-                       'ipb_auto'             => $this->mAuto,
-                       'ipb_anon_only'        => !$this->isHardblock(),
-                       'ipb_create_account'   => $this->isCreateAccountBlocked(),
-                       'ipb_enable_autoblock' => $this->isAutoblocking(),
-                       'ipb_expiry'           => $expiry,
-                       'ipb_range_start'      => $this->getRangeStart(),
-                       'ipb_range_end'        => $this->getRangeEnd(),
-                       'ipb_deleted'          => intval( $this->getHideName() ), // typecast required for SQLite
-                       'ipb_block_email'      => $this->isEmailBlocked(),
-                       'ipb_allow_usertalk'   => $this->isUsertalkEditAllowed(),
-                       'ipb_parent_block_id'  => $this->mParentBlockId,
-                       'ipb_sitewide'         => $this->isSitewide(),
-               ] + CommentStore::getStore()->insert( $dbw, 'ipb_reason', $this->getReason() )
-                       + ActorMigration::newMigration()->getInsertValues( $dbw, 'ipb_by', $this->getBlocker() );
-
-               return $a;
-       }
-
-       /**
-        * @param IDatabase $dbw
-        * @return array
-        */
-       protected function getAutoblockUpdateArray( IDatabase $dbw ) {
-               return [
-                       'ipb_create_account'   => $this->isCreateAccountBlocked(),
-                       'ipb_deleted'          => (int)$this->getHideName(), // typecast required for SQLite
-                       'ipb_allow_usertalk'   => $this->isUsertalkEditAllowed(),
-                       'ipb_sitewide'         => $this->isSitewide(),
-               ] + CommentStore::getStore()->insert( $dbw, 'ipb_reason', $this->getReason() )
-                       + ActorMigration::newMigration()->getInsertValues( $dbw, 'ipb_by', $this->getBlocker() );
-       }
-
-       /**
-        * Retroactively autoblocks the last IP used by the user (if it is a user)
-        * blocked by this Block.
-        *
-        * @return array Block IDs of retroactive autoblocks made
-        */
-       protected function doRetroactiveAutoblock() {
-               $blockIds = [];
-               # If autoblock is enabled, autoblock the LAST IP(s) used
-               if ( $this->isAutoblocking() && $this->getType() == self::TYPE_USER ) {
-                       wfDebug( "Doing retroactive autoblocks for " . $this->getTarget() . "\n" );
-
-                       $continue = Hooks::run(
-                               'PerformRetroactiveAutoblock', [ $this, &$blockIds ] );
-
-                       if ( $continue ) {
-                               self::defaultRetroactiveAutoblock( $this, $blockIds );
-                       }
-               }
-               return $blockIds;
-       }
-
-       /**
-        * Retroactively autoblocks the last IP used by the user (if it is a user)
-        * blocked by this Block. This will use the recentchanges table.
-        *
-        * @param Block $block
-        * @param array &$blockIds
-        */
-       protected static function defaultRetroactiveAutoblock( Block $block, array &$blockIds ) {
-               global $wgPutIPinRC;
-
-               // No IPs are in recentchanges table, so nothing to select
-               if ( !$wgPutIPinRC ) {
-                       return;
-               }
-
-               // Autoblocks only apply to TYPE_USER
-               if ( $block->getType() !== self::TYPE_USER ) {
-                       return;
-               }
-               $target = $block->getTarget(); // TYPE_USER => always a User object
-
-               $dbr = wfGetDB( DB_REPLICA );
-               $rcQuery = ActorMigration::newMigration()->getWhere( $dbr, 'rc_user', $target, false );
-
-               $options = [ 'ORDER BY' => 'rc_timestamp DESC' ];
-
-               // Just the last IP used.
-               $options['LIMIT'] = 1;
-
-               $res = $dbr->select(
-                       [ 'recentchanges' ] + $rcQuery['tables'],
-                       [ 'rc_ip' ],
-                       $rcQuery['conds'],
-                       __METHOD__,
-                       $options,
-                       $rcQuery['joins']
-               );
-
-               if ( !$res->numRows() ) {
-                       # No results, don't autoblock anything
-                       wfDebug( "No IP found to retroactively autoblock\n" );
-               } else {
-                       foreach ( $res as $row ) {
-                               if ( $row->rc_ip ) {
-                                       $id = $block->doAutoblock( $row->rc_ip );
-                                       if ( $id ) {
-                                               $blockIds[] = $id;
-                                       }
-                               }
-                       }
-               }
-       }
-
-       /**
-        * Checks whether a given IP is on the autoblock whitelist.
-        * TODO: this probably belongs somewhere else, but not sure where...
-        *
-        * @param string $ip The IP to check
-        * @return bool
-        */
-       public static function isWhitelistedFromAutoblocks( $ip ) {
-               // Try to get the autoblock_whitelist from the cache, as it's faster
-               // than getting the msg raw and explode()'ing it.
-               $cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
-               $lines = $cache->getWithSetCallback(
-                       $cache->makeKey( 'ip-autoblock', 'whitelist' ),
-                       $cache::TTL_DAY,
-                       function ( $curValue, &$ttl, array &$setOpts ) {
-                               $setOpts += Database::getCacheSetOptions( wfGetDB( DB_REPLICA ) );
-
-                               return explode( "\n",
-                                       wfMessage( 'autoblock_whitelist' )->inContentLanguage()->plain() );
-                       }
-               );
-
-               wfDebug( "Checking the autoblock whitelist..\n" );
-
-               foreach ( $lines as $line ) {
-                       # List items only
-                       if ( substr( $line, 0, 1 ) !== '*' ) {
-                               continue;
-                       }
-
-                       $wlEntry = substr( $line, 1 );
-                       $wlEntry = trim( $wlEntry );
-
-                       wfDebug( "Checking $ip against $wlEntry..." );
-
-                       # Is the IP in this range?
-                       if ( IP::isInRange( $ip, $wlEntry ) ) {
-                               wfDebug( " IP $ip matches $wlEntry, not autoblocking\n" );
-                               return true;
-                       } else {
-                               wfDebug( " No match\n" );
-                       }
-               }
-
-               return false;
-       }
-
-       /**
-        * Autoblocks the given IP, referring to this Block.
-        *
-        * @param string $autoblockIP The IP to autoblock.
-        * @return int|bool Block ID if an autoblock was inserted, false if not.
-        */
-       public function doAutoblock( $autoblockIP ) {
-               # If autoblocks are disabled, go away.
-               if ( !$this->isAutoblocking() ) {
-                       return false;
-               }
-
-               # Check for presence on the autoblock whitelist.
-               if ( self::isWhitelistedFromAutoblocks( $autoblockIP ) ) {
-                       return false;
-               }
-
-               // Avoid PHP 7.1 warning of passing $this by reference
-               $block = $this;
-               # Allow hooks to cancel the autoblock.
-               if ( !Hooks::run( 'AbortAutoblock', [ $autoblockIP, &$block ] ) ) {
-                       wfDebug( "Autoblock aborted by hook.\n" );
-                       return false;
-               }
-
-               # It's okay to autoblock. Go ahead and insert/update the block...
-
-               # Do not add a *new* block if the IP is already blocked.
-               $ipblock = self::newFromTarget( $autoblockIP );
-               if ( $ipblock ) {
-                       # Check if the block is an autoblock and would exceed the user block
-                       # if renewed. If so, do nothing, otherwise prolong the block time...
-                       if ( $ipblock->mAuto && // @todo Why not compare $ipblock->mExpiry?
-                               $this->getExpiry() > self::getAutoblockExpiry( $ipblock->getTimestamp() )
-                       ) {
-                               # Reset block timestamp to now and its expiry to
-                               # $wgAutoblockExpiry in the future
-                               $ipblock->updateTimestamp();
-                       }
-                       return false;
-               }
-
-               # Make a new block object with the desired properties.
-               $autoblock = new Block;
-               wfDebug( "Autoblocking {$this->getTarget()}@" . $autoblockIP . "\n" );
-               $autoblock->setTarget( $autoblockIP );
-               $autoblock->setBlocker( $this->getBlocker() );
-               $autoblock->setReason(
-                       wfMessage( 'autoblocker', $this->getTarget(), $this->getReason() )
-                               ->inContentLanguage()->plain()
-               );
-               $timestamp = wfTimestampNow();
-               $autoblock->setTimestamp( $timestamp );
-               $autoblock->mAuto = 1;
-               $autoblock->isCreateAccountBlocked( $this->isCreateAccountBlocked() );
-               # Continue suppressing the name if needed
-               $autoblock->setHideName( $this->getHideName() );
-               $autoblock->isUsertalkEditAllowed( $this->isUsertalkEditAllowed() );
-               $autoblock->mParentBlockId = $this->mId;
-               $autoblock->isSitewide( $this->isSitewide() );
-               $autoblock->setRestrictions( $this->getRestrictions() );
-
-               if ( $this->getExpiry() == 'infinity' ) {
-                       # Original block was indefinite, start an autoblock now
-                       $autoblock->setExpiry( self::getAutoblockExpiry( $timestamp ) );
-               } else {
-                       # If the user is already blocked with an expiry date, we don't
-                       # want to pile on top of that.
-                       $autoblock->setExpiry( min( $this->getExpiry(), self::getAutoblockExpiry( $timestamp ) ) );
-               }
-
-               # Insert the block...
-               $status = $autoblock->insert();
-               return $status
-                       ? $status['id']
-                       : false;
-       }
-
-       /**
-        * Check if a block has expired. Delete it if it is.
-        * @return bool
-        */
-       public function deleteIfExpired() {
-               if ( $this->isExpired() ) {
-                       wfDebug( "Block::deleteIfExpired() -- deleting\n" );
-                       $this->delete();
-                       $retVal = true;
-               } else {
-                       wfDebug( "Block::deleteIfExpired() -- not expired\n" );
-                       $retVal = false;
-               }
-
-               return $retVal;
-       }
-
-       /**
-        * Has the block expired?
-        * @return bool
-        */
-       public function isExpired() {
-               $timestamp = wfTimestampNow();
-               wfDebug( "Block::isExpired() checking current " . $timestamp . " vs $this->mExpiry\n" );
-
-               if ( !$this->getExpiry() ) {
-                       return false;
-               } else {
-                       return $timestamp > $this->getExpiry();
-               }
-       }
-
-       /**
-        * Is the block address valid (i.e. not a null string?)
-        *
-        * @deprecated since 1.33 No longer needed in core.
-        * @return bool
-        */
-       public function isValid() {
-               wfDeprecated( __METHOD__, '1.33' );
-               return $this->getTarget() != null;
-       }
-
-       /**
-        * Update the timestamp on autoblocks.
-        */
-       public function updateTimestamp() {
-               if ( $this->mAuto ) {
-                       $this->setTimestamp( wfTimestamp() );
-                       $this->setExpiry( self::getAutoblockExpiry( $this->getTimestamp() ) );
-
-                       $dbw = wfGetDB( DB_MASTER );
-                       $dbw->update( 'ipblocks',
-                               [ /* SET */
-                                       'ipb_timestamp' => $dbw->timestamp( $this->getTimestamp() ),
-                                       'ipb_expiry' => $dbw->timestamp( $this->getExpiry() ),
-                               ],
-                               [ /* WHERE */
-                                       'ipb_id' => $this->getId(),
-                               ],
-                               __METHOD__
-                       );
-               }
-       }
-
-       /**
-        * Get the IP address at the start of the range in Hex form
-        * @throws MWException
-        * @return string IP in Hex form
-        */
-       public function getRangeStart() {
-               switch ( $this->type ) {
-                       case self::TYPE_USER:
-                               return '';
-                       case self::TYPE_IP:
-                               return IP::toHex( $this->target );
-                       case self::TYPE_RANGE:
-                               list( $start, /*...*/ ) = IP::parseRange( $this->target );
-                               return $start;
-                       default:
-                               throw new MWException( "Block with invalid type" );
-               }
-       }
-
-       /**
-        * Get the IP address at the end of the range in Hex form
-        * @throws MWException
-        * @return string IP in Hex form
-        */
-       public function getRangeEnd() {
-               switch ( $this->type ) {
-                       case self::TYPE_USER:
-                               return '';
-                       case self::TYPE_IP:
-                               return IP::toHex( $this->target );
-                       case self::TYPE_RANGE:
-                               list( /*...*/, $end ) = IP::parseRange( $this->target );
-                               return $end;
-                       default:
-                               throw new MWException( "Block with invalid type" );
-               }
-       }
-
-       /**
-        * @inheritDoc
-        */
-       public function getId() {
-               return $this->mId;
-       }
-
-       /**
-        * Set the block ID
-        *
-        * @param int $blockId
-        * @return int
-        */
-       private function setId( $blockId ) {
-               $this->mId = (int)$blockId;
-
-               if ( is_array( $this->restrictions ) ) {
-                       $this->restrictions = $this->getBlockRestrictionStore()->setBlockId(
-                               $blockId, $this->restrictions
-                       );
-               }
-
-               return $this;
-       }
-
-       /**
-        * Get/set a flag determining whether the master is used for reads
-        *
-        * @param bool|null $x
-        * @return bool
-        */
-       public function fromMaster( $x = null ) {
-               return wfSetVar( $this->mFromMaster, $x );
-       }
-
-       /**
-        * Get/set whether the Block is a hardblock (affects logged-in users on a given IP/range)
-        * @param bool|null $x
-        * @return bool
-        */
-       public function isHardblock( $x = null ) {
-               wfSetVar( $this->isHardblock, $x );
-
-               # You can't *not* hardblock a user
-               return $this->getType() == self::TYPE_USER
-                       ? true
-                       : $this->isHardblock;
-       }
-
-       /**
-        * @param null|bool $x
-        * @return bool
-        */
-       public function isAutoblocking( $x = null ) {
-               wfSetVar( $this->isAutoblocking, $x );
-
-               # You can't put an autoblock on an IP or range as we don't have any history to
-               # look over to get more IPs from
-               return $this->getType() == self::TYPE_USER
-                       ? $this->isAutoblocking
-                       : false;
-       }
-
-       /**
-        * Get the block name, but with autoblocked IPs hidden as per standard privacy policy
-        * @return string Text is escaped
-        */
-       public function getRedactedName() {
-               if ( $this->mAuto ) {
-                       return Html::element(
-                               'span',
-                               [ 'class' => 'mw-autoblockid' ],
-                               wfMessage( 'autoblockid', $this->mId )->text()
-                       );
-               } else {
-                       return htmlspecialchars( $this->getTarget() );
-               }
-       }
-
-       /**
-        * Get a timestamp of the expiry for autoblocks
-        *
-        * @param string|int $timestamp
-        * @return string
-        */
-       public static function getAutoblockExpiry( $timestamp ) {
-               global $wgAutoblockExpiry;
-
-               return wfTimestamp( TS_MW, wfTimestamp( TS_UNIX, $timestamp ) + $wgAutoblockExpiry );
-       }
-
-       /**
-        * Purge expired blocks from the ipblocks table
-        */
-       public static function purgeExpired() {
-               if ( wfReadOnly() ) {
-                       return;
-               }
-
-               DeferredUpdates::addUpdate( new AutoCommitUpdate(
-                       wfGetDB( DB_MASTER ),
-                       __METHOD__,
-                       function ( IDatabase $dbw, $fname ) {
-                               $ids = $dbw->selectFieldValues( 'ipblocks',
-                                       'ipb_id',
-                                       [ 'ipb_expiry < ' . $dbw->addQuotes( $dbw->timestamp() ) ],
-                                       $fname
-                               );
-                               if ( $ids ) {
-                                       $blockRestrictionStore = MediaWikiServices::getInstance()->getBlockRestrictionStore();
-                                       $blockRestrictionStore->deleteByBlockId( $ids );
-
-                                       $dbw->delete( 'ipblocks', [ 'ipb_id' => $ids ], $fname );
-                               }
-                       }
-               ) );
-       }
-
-       /**
-        * Given a target and the target's type, get an existing Block object if possible.
-        * @param string|User|int $specificTarget A block target, which may be one of several types:
-        *     * A user to block, in which case $target will be a User
-        *     * An IP to block, in which case $target will be a User generated by using
-        *       User::newFromName( $ip, false ) to turn off name validation
-        *     * An IP range, in which case $target will be a String "123.123.123.123/18" etc
-        *     * The ID of an existing block, in the format "#12345" (since pure numbers are valid
-        *       usernames
-        *     Calling this with a user, IP address or range will not select autoblocks, and will
-        *     only select a block where the targets match exactly (so looking for blocks on
-        *     1.2.3.4 will not select 1.2.0.0/16 or even 1.2.3.4/32)
-        * @param string|User|int|null $vagueTarget As above, but we will search for *any* block which
-        *     affects that target (so for an IP address, get ranges containing that IP; and also
-        *     get any relevant autoblocks). Leave empty or blank to skip IP-based lookups.
-        * @param bool $fromMaster Whether to use the DB_MASTER database
-        * @return Block|null (null if no relevant block could be found).  The target and type
-        *     of the returned Block will refer to the actual block which was found, which might
-        *     not be the same as the target you gave if you used $vagueTarget!
-        */
-       public static function newFromTarget( $specificTarget, $vagueTarget = null, $fromMaster = false ) {
-               list( $target, $type ) = self::parseTarget( $specificTarget );
-               if ( $type == self::TYPE_ID || $type == self::TYPE_AUTO ) {
-                       return self::newFromID( $target );
-
-               } elseif ( $target === null && $vagueTarget == '' ) {
-                       # We're not going to find anything useful here
-                       # Be aware that the == '' check is explicit, since empty values will be
-                       # passed by some callers (T31116)
-                       return null;
-
-               } elseif ( in_array(
-                       $type,
-                       [ self::TYPE_USER, self::TYPE_IP, self::TYPE_RANGE, null ] )
-               ) {
-                       $block = new Block();
-                       $block->fromMaster( $fromMaster );
-
-                       if ( $type !== null ) {
-                               $block->setTarget( $target );
-                       }
-
-                       if ( $block->newLoad( $vagueTarget ) ) {
-                               return $block;
-                       }
-               }
-               return null;
-       }
-
-       /**
-        * Get all blocks that match any IP from an array of IP addresses
-        *
-        * @param array $ipChain List of IPs (strings), usually retrieved from the
-        *     X-Forwarded-For header of the request
-        * @param bool $isAnon Exclude anonymous-only blocks if false
-        * @param bool $fromMaster Whether to query the master or replica DB
-        * @return array Array of Blocks
-        * @since 1.22
-        */
-       public static function getBlocksForIPList( array $ipChain, $isAnon, $fromMaster = false ) {
-               if ( $ipChain === [] ) {
-                       return [];
-               }
-
-               $conds = [];
-               $proxyLookup = MediaWikiServices::getInstance()->getProxyLookup();
-               foreach ( array_unique( $ipChain ) as $ipaddr ) {
-                       # Discard invalid IP addresses. Since XFF can be spoofed and we do not
-                       # necessarily trust the header given to us, make sure that we are only
-                       # checking for blocks on well-formatted IP addresses (IPv4 and IPv6).
-                       # Do not treat private IP spaces as special as it may be desirable for wikis
-                       # to block those IP ranges in order to stop misbehaving proxies that spoof XFF.
-                       if ( !IP::isValid( $ipaddr ) ) {
-                               continue;
-                       }
-                       # Don't check trusted IPs (includes local squids which will be in every request)
-                       if ( $proxyLookup->isTrustedProxy( $ipaddr ) ) {
-                               continue;
-                       }
-                       # Check both the original IP (to check against single blocks), as well as build
-                       # the clause to check for rangeblocks for the given IP.
-                       $conds['ipb_address'][] = $ipaddr;
-                       $conds[] = self::getRangeCond( IP::toHex( $ipaddr ) );
-               }
-
-               if ( $conds === [] ) {
-                       return [];
-               }
-
-               if ( $fromMaster ) {
-                       $db = wfGetDB( DB_MASTER );
-               } else {
-                       $db = wfGetDB( DB_REPLICA );
-               }
-               $conds = $db->makeList( $conds, LIST_OR );
-               if ( !$isAnon ) {
-                       $conds = [ $conds, 'ipb_anon_only' => 0 ];
-               }
-               $blockQuery = self::getQueryInfo();
-               $rows = $db->select(
-                       $blockQuery['tables'],
-                       array_merge( [ 'ipb_range_start', 'ipb_range_end' ], $blockQuery['fields'] ),
-                       $conds,
-                       __METHOD__,
-                       [],
-                       $blockQuery['joins']
-               );
-
-               $blocks = [];
-               foreach ( $rows as $row ) {
-                       $block = self::newFromRow( $row );
-                       if ( !$block->isExpired() ) {
-                               $blocks[] = $block;
-                       }
-               }
-
-               return $blocks;
-       }
-
-       /**
-        * From a list of multiple blocks, find the most exact and strongest Block.
-        *
-        * The logic for finding the "best" block is:
-        *  - Blocks that match the block's target IP are preferred over ones in a range
-        *  - Hardblocks are chosen over softblocks that prevent account creation
-        *  - Softblocks that prevent account creation are chosen over other softblocks
-        *  - Other softblocks are chosen over autoblocks
-        *  - If there are multiple exact or range blocks at the same level, the one chosen
-        *    is random
-        * This should be used when $blocks where retrieved from the user's IP address
-        * and $ipChain is populated from the same IP address information.
-        *
-        * @param array $blocks Array of Block objects
-        * @param array $ipChain List of IPs (strings). This is used to determine how "close"
-        *     a block is to the server, and if a block matches exactly, or is in a range.
-        *     The order is furthest from the server to nearest e.g., (Browser, proxy1, proxy2,
-        *     local-squid, ...)
-        * @throws MWException
-        * @return Block|null The "best" block from the list
-        */
-       public static function chooseBlock( array $blocks, array $ipChain ) {
-               if ( $blocks === [] ) {
-                       return null;
-               } elseif ( count( $blocks ) == 1 ) {
-                       return $blocks[0];
-               }
-
-               // Sort hard blocks before soft ones and secondarily sort blocks
-               // that disable account creation before those that don't.
-               usort( $blocks, function ( Block $a, Block $b ) {
-                       $aWeight = (int)$a->isHardblock() . (int)$a->appliesToRight( 'createaccount' );
-                       $bWeight = (int)$b->isHardblock() . (int)$b->appliesToRight( 'createaccount' );
-                       return strcmp( $bWeight, $aWeight ); // highest weight first
-               } );
-
-               $blocksListExact = [
-                       'hard' => false,
-                       'disable_create' => false,
-                       'other' => false,
-                       'auto' => false
-               ];
-               $blocksListRange = [
-                       'hard' => false,
-                       'disable_create' => false,
-                       'other' => false,
-                       'auto' => false
-               ];
-               $ipChain = array_reverse( $ipChain );
-
-               /** @var Block $block */
-               foreach ( $blocks as $block ) {
-                       // Stop searching if we have already have a "better" block. This
-                       // is why the order of the blocks matters
-                       if ( !$block->isHardblock() && $blocksListExact['hard'] ) {
-                               break;
-                       } elseif ( !$block->appliesToRight( 'createaccount' ) && $blocksListExact['disable_create'] ) {
-                               break;
-                       }
-
-                       foreach ( $ipChain as $checkip ) {
-                               $checkipHex = IP::toHex( $checkip );
-                               if ( (string)$block->getTarget() === $checkip ) {
-                                       if ( $block->isHardblock() ) {
-                                               $blocksListExact['hard'] = $blocksListExact['hard'] ?: $block;
-                                       } elseif ( $block->appliesToRight( 'createaccount' ) ) {
-                                               $blocksListExact['disable_create'] = $blocksListExact['disable_create'] ?: $block;
-                                       } elseif ( $block->mAuto ) {
-                                               $blocksListExact['auto'] = $blocksListExact['auto'] ?: $block;
-                                       } else {
-                                               $blocksListExact['other'] = $blocksListExact['other'] ?: $block;
-                                       }
-                                       // We found closest exact match in the ip list, so go to the next Block
-                                       break;
-                               } elseif ( array_filter( $blocksListExact ) == []
-                                       && $block->getRangeStart() <= $checkipHex
-                                       && $block->getRangeEnd() >= $checkipHex
-                               ) {
-                                       if ( $block->isHardblock() ) {
-                                               $blocksListRange['hard'] = $blocksListRange['hard'] ?: $block;
-                                       } elseif ( $block->appliesToRight( 'createaccount' ) ) {
-                                               $blocksListRange['disable_create'] = $blocksListRange['disable_create'] ?: $block;
-                                       } elseif ( $block->mAuto ) {
-                                               $blocksListRange['auto'] = $blocksListRange['auto'] ?: $block;
-                                       } else {
-                                               $blocksListRange['other'] = $blocksListRange['other'] ?: $block;
-                                       }
-                                       break;
-                               }
-                       }
-               }
-
-               if ( array_filter( $blocksListExact ) == [] ) {
-                       $blocksList = &$blocksListRange;
-               } else {
-                       $blocksList = &$blocksListExact;
-               }
-
-               $chosenBlock = null;
-               if ( $blocksList['hard'] ) {
-                       $chosenBlock = $blocksList['hard'];
-               } elseif ( $blocksList['disable_create'] ) {
-                       $chosenBlock = $blocksList['disable_create'];
-               } elseif ( $blocksList['other'] ) {
-                       $chosenBlock = $blocksList['other'];
-               } elseif ( $blocksList['auto'] ) {
-                       $chosenBlock = $blocksList['auto'];
-               } else {
-                       throw new MWException( "Proxy block found, but couldn't be classified." );
-               }
-
-               return $chosenBlock;
-       }
-
-       /**
-        * @inheritDoc
-        *
-        * Autoblocks have whichever type corresponds to their target, so to detect if a block is an
-        * autoblock, we have to check the mAuto property instead.
-        */
-       public function getType() {
-               return $this->mAuto
-                       ? self::TYPE_AUTO
-                       : parent::getType();
-       }
-
-       /**
-        * Set the 'BlockID' cookie to this block's ID and expiry time. The cookie's expiry will be
-        * the same as the block's, to a maximum of 24 hours.
-        *
-        * @since 1.29
-        *
-        * @param WebResponse $response The response on which to set the cookie.
-        */
-       public function setCookie( WebResponse $response ) {
-               // Calculate the default expiry time.
-               $maxExpiryTime = wfTimestamp( TS_MW, wfTimestamp() + ( 24 * 60 * 60 ) );
-
-               // Use the Block's expiry time only if it's less than the default.
-               $expiryTime = $this->getExpiry();
-               if ( $expiryTime === 'infinity' || $expiryTime > $maxExpiryTime ) {
-                       $expiryTime = $maxExpiryTime;
-               }
-
-               // Set the cookie. Reformat the MediaWiki datetime as a Unix timestamp for the cookie.
-               $expiryValue = DateTime::createFromFormat( 'YmdHis', $expiryTime )->format( 'U' );
-               $cookieOptions = [ 'httpOnly' => false ];
-               $cookieValue = $this->getCookieValue();
-               $response->setCookie( 'BlockID', $cookieValue, $expiryValue, $cookieOptions );
-       }
-
-       /**
-        * Unset the 'BlockID' cookie.
-        *
-        * @since 1.29
-        *
-        * @param WebResponse $response The response on which to unset the cookie.
-        */
-       public static function clearCookie( WebResponse $response ) {
-               $response->clearCookie( 'BlockID', [ 'httpOnly' => false ] );
-       }
-
-       /**
-        * Get the BlockID cookie's value for this block. This is usually the block ID concatenated
-        * with an HMAC in order to avoid spoofing (T152951), but if wgSecretKey is not set will just
-        * be the block ID.
-        *
-        * @since 1.29
-        *
-        * @return string The block ID, probably concatenated with "!" and the HMAC.
-        */
-       public function getCookieValue() {
-               $config = RequestContext::getMain()->getConfig();
-               $id = $this->getId();
-               $secretKey = $config->get( 'SecretKey' );
-               if ( !$secretKey ) {
-                       // If there's no secret key, don't append a HMAC.
-                       return $id;
-               }
-               $hmac = MWCryptHash::hmac( $id, $secretKey, false );
-               $cookieValue = $id . '!' . $hmac;
-               return $cookieValue;
-       }
-
-       /**
-        * Get the stored ID from the 'BlockID' cookie. The cookie's value is usually a combination of
-        * the ID and a HMAC (see Block::setCookie), but will sometimes only be the ID.
-        *
-        * @since 1.29
-        *
-        * @param string $cookieValue The string in which to find the ID.
-        *
-        * @return int|null The block ID, or null if the HMAC is present and invalid.
-        */
-       public static function getIdFromCookieValue( $cookieValue ) {
-               // Extract the ID prefix from the cookie value (may be the whole value, if no bang found).
-               $bangPos = strpos( $cookieValue, '!' );
-               $id = ( $bangPos === false ) ? $cookieValue : substr( $cookieValue, 0, $bangPos );
-               // Get the site-wide secret key.
-               $config = RequestContext::getMain()->getConfig();
-               $secretKey = $config->get( 'SecretKey' );
-               if ( !$secretKey ) {
-                       // If there's no secret key, just use the ID as given.
-                       return $id;
-               }
-               $storedHmac = substr( $cookieValue, $bangPos + 1 );
-               $calculatedHmac = MWCryptHash::hmac( $id, $secretKey, false );
-               if ( $calculatedHmac === $storedHmac ) {
-                       return $id;
-               } else {
-                       return null;
-               }
-       }
-
-       /**
-        * @inheritDoc
-        *
-        * Build different messages for autoblocks and partial blocks.
-        */
-       public function getPermissionsError( IContextSource $context ) {
-               $params = $this->getBlockErrorParams( $context );
-
-               $msg = 'blockedtext';
-               if ( $this->mAuto ) {
-                       $msg = 'autoblockedtext';
-               } elseif ( !$this->isSitewide() ) {
-                       $msg = 'blockedtext-partial';
-               }
-
-               array_unshift( $params, $msg );
-
-               return $params;
-       }
-
-       /**
-        * Get Restrictions.
-        *
-        * Getting the restrictions will perform a database query if the restrictions
-        * are not already loaded.
-        *
-        * @since 1.33
-        * @return Restriction[]
-        */
-       public function getRestrictions() {
-               if ( $this->restrictions === null ) {
-                       // If the block id has not been set, then do not attempt to load the
-                       // restrictions.
-                       if ( !$this->mId ) {
-                               return [];
-                       }
-                       $this->restrictions = $this->getBlockRestrictionStore()->loadByBlockId( $this->mId );
-               }
-
-               return $this->restrictions;
-       }
-
-       /**
-        * Set Restrictions.
-        *
-        * @since 1.33
-        * @param Restriction[] $restrictions
-        * @return self
-        */
-       public function setRestrictions( array $restrictions ) {
-               $this->restrictions = array_filter( $restrictions, function ( $restriction ) {
-                       return $restriction instanceof Restriction;
-               } );
-
-               return $this;
-       }
-
-       /**
-        * @inheritDoc
-        */
-       public function appliesToTitle( Title $title ) {
-               if ( $this->isSitewide() ) {
-                       return true;
-               }
-
-               $restrictions = $this->getRestrictions();
-               foreach ( $restrictions as $restriction ) {
-                       if ( $restriction->matches( $title ) ) {
-                               return true;
-                       }
-               }
-
-               return false;
-       }
-
-       /**
-        * @inheritDoc
-        */
-       public function appliesToNamespace( $ns ) {
-               if ( $this->isSitewide() ) {
-                       return true;
-               }
-
-               // Blocks do not apply to virtual namespaces.
-               if ( $ns < 0 ) {
-                       return false;
-               }
-
-               $restriction = $this->findRestriction( NamespaceRestriction::TYPE, $ns );
-
-               return (bool)$restriction;
-       }
-
-       /**
-        * @inheritDoc
-        */
-       public function appliesToPage( $pageId ) {
-               if ( $this->isSitewide() ) {
-                       return true;
-               }
-
-               // If the pageId is not over zero, the block cannot apply to it.
-               if ( $pageId <= 0 ) {
-                       return false;
-               }
-
-               $restriction = $this->findRestriction( PageRestriction::TYPE, $pageId );
-
-               return (bool)$restriction;
-       }
-
-       /**
-        * Find Restriction by type and value.
-        *
-        * @param string $type
-        * @param int $value
-        * @return Restriction|null
-        */
-       private function findRestriction( $type, $value ) {
-               $restrictions = $this->getRestrictions();
-               foreach ( $restrictions as $restriction ) {
-                       if ( $restriction->getType() !== $type ) {
-                               continue;
-                       }
-
-                       if ( $restriction->getValue() === $value ) {
-                               return $restriction;
-                       }
-               }
-
-               return null;
-       }
-
-       /**
-        * @inheritDoc
-        */
-       public function shouldTrackWithCookie( $isAnon ) {
-               $config = RequestContext::getMain()->getConfig();
-               switch ( $this->getType() ) {
-                       case self::TYPE_IP:
-                       case self::TYPE_RANGE:
-                               return $isAnon && $config->get( 'CookieSetOnIpBlock' );
-                       case self::TYPE_USER:
-                               return !$isAnon && $config->get( 'CookieSetOnAutoblock' ) && $this->isAutoblocking();
-                       default:
-                               return false;
-               }
-       }
-
-       /**
-        * Get a BlockRestrictionStore instance
-        *
-        * @return BlockRestrictionStore
-        */
-       private function getBlockRestrictionStore() : BlockRestrictionStore {
-               return MediaWikiServices::getInstance()->getBlockRestrictionStore();
-       }
-}
index 69da9c7..eed732b 100644 (file)
@@ -2701,7 +2701,8 @@ $wgExtensionInfoMTime = false;
  * @name   HTTP proxy (CDN) settings
  *
  * Many of these settings apply to any HTTP proxy used in front of MediaWiki,
- * although they are referred to as Squid settings for historical reasons.
+ * although they are sometimes still referred to as Squid settings for
+ * historical reasons.
  *
  * Achieving a high hit ratio with an HTTP proxy requires special
  * configuration. See https://www.mediawiki.org/wiki/Manual:Squid_caching for
@@ -2713,8 +2714,10 @@ $wgExtensionInfoMTime = false;
 /**
  * Enable/disable CDN.
  * See https://www.mediawiki.org/wiki/Manual:Squid_caching
+ *
+ * @since 1.34 Renamed from $wgUseSquid.
  */
-$wgUseSquid = false;
+$wgUseCdn = false;
 
 /**
  * If you run Squid3 with ESI support, enable this (default:false):
@@ -2756,12 +2759,15 @@ $wgInternalServer = false;
  * out s-maxage in the CDN config.
  *
  * 18000 seconds = 5 hours, more cache hits with 2678400 = 31 days.
+ *
+ * @since 1.34 Renamed from $wgSquidMaxage
  */
-$wgSquidMaxage = 18000;
+$wgCdnMaxAge = 18000;
 
 /**
  * Cache timeout for the CDN when DB replica DB lag is high
- * @see $wgSquidMaxage
+ * @see $wgCdnMaxAge
+ *
  * @since 1.27
  */
 $wgCdnMaxageLagged = 30;
@@ -2784,7 +2790,7 @@ $wgCdnReboundPurgeDelay = 0;
 
 /**
  * Cache timeout for the CDN when a response is known to be wrong or incomplete (due to load)
- * @see $wgSquidMaxage
+ * @see $wgCdnMaxAge
  * @since 1.27
  */
 $wgCdnMaxageSubstitute = 60;
@@ -2803,20 +2809,24 @@ $wgForcedRawSMaxage = 300;
  * headers sent/modified from these proxies when obtaining the remote IP address
  *
  * For a list of trusted servers which *aren't* purged, see $wgSquidServersNoPurge.
+ *
+ * @since 1.34 Renamed from $wgSquidServers.
  */
-$wgSquidServers = [];
+$wgCdnServers = [];
 
 /**
- * As above, except these servers aren't purged on page changes; use to set a
- * list of trusted proxies, etc. Supports both individual IP addresses and
- * CIDR blocks.
+ * As with $wgCdnServers, except these servers aren't purged on page changes;
+ * use to set a list of trusted proxies, etc. Supports both individual IP
+ * addresses and CIDR blocks.
+ *
  * @since 1.23 Supports CIDR ranges
+ * @since 1.34 Renamed from $wgSquidServersNoPurge
  */
-$wgSquidServersNoPurge = [];
+$wgCdnServersNoPurge = [];
 
 /**
  * Whether to use a Host header in purge requests sent to the proxy servers
- * configured in $wgSquidServers. Set this to false to support Squid
+ * configured in $wgCdnServers. Set this to false to support a CDN
  * configured in forward-proxy mode.
  *
  * If this is set to true, a Host header will be sent, and only the path
@@ -6505,7 +6515,7 @@ $wgCachePrefix = false;
 /**
  * Display the new debugging toolbar. This also enables profiling on database
  * queries and other useful output.
- * Will be ignored if $wgUseFileCache or $wgUseSquid is enabled.
+ * Will be ignored if $wgUseFileCache or $wgUseCdn is enabled.
  *
  * @since 1.19
  */
@@ -8497,6 +8507,7 @@ $wgExternalDiffEngine = false;
  * See $wgExternalDiffEngine.
  *
  * @since 1.30
+ * @deprecated since 1.34
  */
 $wgWikiDiff2MovedParagraphDetectionCutoff = 0;
 
@@ -9082,6 +9093,17 @@ $wgReportToEndpoints = [];
  */
 $wgFeaturePolicyReportOnly = [];
 
+/**
+ * Options for Special:Search completion widget form created by SearchFormWidget class.
+ * Settings that can be used:
+ * - showDescriptions: true/false - whether to show opensearch description results
+ * - performSearchOnClick:  true/false - whether to perform search on click
+ * See also TitleWidget.js UI widget.
+ * @since 1.34
+ * @var array
+ */
+$wgSpecialSearchFormOptions = [];
+
 /**
  * For really cool vim folding this needs to be at the end:
  * vim: foldmarker=@{,@} foldmethod=marker
index 7908fcc..0bcc893 100644 (file)
@@ -20,6 +20,7 @@
  * @file
  */
 
+use MediaWiki\Block\DatabaseBlock;
 use MediaWiki\EditPage\TextboxBuilder;
 use MediaWiki\EditPage\TextConflictHelper;
 use MediaWiki\Logger\LoggerFactory;
@@ -565,14 +566,6 @@ class EditPage {
                $this->enableApiEditOverride = $enableOverride;
        }
 
-       /**
-        * @deprecated since 1.29, call edit directly
-        */
-       public function submit() {
-               wfDeprecated( __METHOD__, '1.29' );
-               $this->edit();
-       }
-
        /**
         * This is the function that gets called for "action=edit". It
         * sets up various member variables, then passes execution to
@@ -1483,8 +1476,9 @@ class EditPage {
 
                $user = $this->context->getUser();
                $title = Title::newFromText( $preload );
+
                # Check for existence to avoid getting MediaWiki:Noarticletext
-               if ( $title === null || !$title->exists() || !$title->userCan( 'read', $user ) ) {
+               if ( !$this->isPageExistingAndViewable( $title, $user ) ) {
                        // TODO: somehow show a warning to the user!
                        return $handler->makeEmptyContent();
                }
@@ -1493,7 +1487,7 @@ class EditPage {
                if ( $page->isRedirect() ) {
                        $title = $page->getRedirectTarget();
                        # Same as before
-                       if ( $title === null || !$title->exists() || !$title->userCan( 'read', $user ) ) {
+                       if ( !$this->isPageExistingAndViewable( $title, $user ) ) {
                                // TODO: somehow show a warning to the user!
                                return $handler->makeEmptyContent();
                        }
@@ -1526,6 +1520,21 @@ class EditPage {
                return $content->preloadTransform( $title, $parserOptions, $params );
        }
 
+       /**
+        * Verify if a given title exists and the given user is allowed to view it
+        *
+        * @see EditPage::getPreloadedContent()
+        * @param Title|null $title
+        * @param User $user
+        * @return bool
+        * @throws Exception
+        */
+       private function isPageExistingAndViewable( $title, User $user ) {
+               $permissionManager = MediaWikiServices::getInstance()->getPermissionManager();
+
+               return $title && $title->exists() && $permissionManager->userCan( 'read', $user, $title );
+       }
+
        /**
         * Make sure the form isn't faking a user's credentials.
         *
@@ -1988,6 +1997,8 @@ ERROR;
                        }
                }
 
+               $permissionManager = MediaWikiServices::getInstance()->getPermissionManager();
+
                $changingContentModel = false;
                if ( $this->contentModel !== $this->mTitle->getContentModel() ) {
                        if ( !$config->get( 'ContentHandlerUseDB' ) ) {
@@ -2001,10 +2012,19 @@ ERROR;
                        // Make sure the user can edit the page under the new content model too
                        $titleWithNewContentModel = clone $this->mTitle;
                        $titleWithNewContentModel->setContentModel( $this->contentModel );
-                       if ( !$titleWithNewContentModel->userCan( 'editcontentmodel', $user )
-                               || !$titleWithNewContentModel->userCan( 'edit', $user )
+
+                       $canEditModel = $permissionManager->userCan(
+                               'editcontentmodel',
+                               $user,
+                               $titleWithNewContentModel
+                       );
+
+                       if (
+                               !$canEditModel
+                               || !$permissionManager->userCan( 'edit', $user, $titleWithNewContentModel )
                        ) {
                                $status->setResult( false, self::AS_NO_CHANGE_CONTENT_MODEL );
+
                                return $status;
                        }
 
@@ -2048,7 +2068,7 @@ ERROR;
 
                if ( $new ) {
                        // Late check for create permission, just in case *PARANOIA*
-                       if ( !$this->mTitle->userCan( 'create', $user ) ) {
+                       if ( !$permissionManager->userCan( 'create', $user, $this->mTitle ) ) {
                                $status->fatal( 'nocreatetext' );
                                $status->value = self::AS_NO_CREATE_PERMISSION;
                                wfDebug( __METHOD__ . ": no create permission\n" );
@@ -2595,13 +2615,13 @@ ERROR;
                        $username = explode( '/', $this->mTitle->getText(), 2 )[0];
                        $user = User::newFromName( $username, false /* allow IP users */ );
                        $ip = User::isIP( $username );
-                       $block = Block::newFromTarget( $user, $user );
+                       $block = DatabaseBlock::newFromTarget( $user, $user );
                        if ( !( $user && $user->isLoggedIn() ) && !$ip ) { # User does not exist
                                $out->wrapWikiMsg( "<div class=\"mw-userpage-userdoesnotexist error\">\n$1\n</div>",
                                        [ 'userpage-userdoesnotexist', wfEscapeWikiText( $username ) ] );
                        } elseif (
                                !is_null( $block ) &&
-                               $block->getType() != Block::TYPE_AUTO &&
+                               $block->getType() != DatabaseBlock::TYPE_AUTO &&
                                ( $block->isSitewide() || $user->isBlockedFrom( $this->mTitle ) )
                        ) {
                                // Show log extract if the user is sitewide blocked or is partially
@@ -2672,7 +2692,7 @@ ERROR;
        protected function showCustomIntro() {
                if ( $this->editintro ) {
                        $title = Title::newFromText( $this->editintro );
-                       if ( $title instanceof Title && $title->exists() && $title->userCan( 'read' ) ) {
+                       if ( $this->isPageExistingAndViewable( $title, $this->context->getUser() ) ) {
                                // Added using template syntax, to take <noinclude>'s into account.
                                $this->context->getOutput()->addWikiTextAsContent(
                                        '<div class="mw-editintro">{{:' . $title->getFullText() . '}}</div>',
index 0a88b23..59efc98 100644 (file)
@@ -20,7 +20,6 @@
  * @file
  * @ingroup Feed
  */
-use MediaWiki\MediaWikiServices;
 
 /**
  * Helper functions for feeds
@@ -29,25 +28,6 @@ use MediaWiki\MediaWikiServices;
  */
 class FeedUtils {
 
-       /**
-        * Check whether feed's cache should be cleared; for changes feeds
-        * If the feed should be purged; $timekey and $key will be removed from cache
-        *
-        * @param string $timekey Cache key of the timestamp of the last item
-        * @param string $key Cache key of feed's content
-        */
-       public static function checkPurge( $timekey, $key ) {
-               global $wgRequest, $wgUser;
-
-               $purge = $wgRequest->getVal( 'action' ) === 'purge';
-               // Allow users with 'purge' right to clear feed caches
-               if ( $purge && $wgUser->isAllowed( 'purge' ) ) {
-                       $cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
-                       $cache->delete( $timekey, 1 );
-                       $cache->delete( $key, 1 );
-               }
-       }
-
        /**
         * Check whether feeds can be used and that $type is a valid feed type
         *
index a4e94da..6ad9b31 100644 (file)
@@ -91,7 +91,7 @@ class LinkFilter {
 
        /**
         * Canonicalize a hostname for el_index
-        * @param string $hose
+        * @param string $host
         * @return string
         */
        private static function indexifyHost( $host ) {
index ff4c786..3f50c97 100644 (file)
@@ -895,7 +895,7 @@ class Linker {
         */
        public static function userLink( $userId, $userName, $altUserName = false ) {
                if ( $userName === '' ) {
-                       wfLogWarning( __METHOD__ . ' received an empty username. Are there database errors ' .
+                       wfDebug( __METHOD__ . ' received an empty username. Are there database errors ' .
                                'that need to be fixed?' );
                        return wfMessage( 'empty-username' )->parse();
                }
@@ -943,7 +943,7 @@ class Linker {
                $useParentheses = true
        ) {
                if ( $userText === '' ) {
-                       wfLogWarning( __METHOD__ . ' received an empty username. Are there database errors ' .
+                       wfDebug( __METHOD__ . ' received an empty username. Are there database errors ' .
                                'that need to be fixed?' );
                        return ' ' . wfMessage( 'empty-username' )->parse();
                }
@@ -1031,7 +1031,7 @@ class Linker {
         */
        public static function userTalkLink( $userId, $userText ) {
                if ( $userText === '' ) {
-                       wfLogWarning( __METHOD__ . ' received an empty username. Are there database errors ' .
+                       wfDebug( __METHOD__ . ' received an empty username. Are there database errors ' .
                                'that need to be fixed?' );
                        return wfMessage( 'empty-username' )->parse();
                }
@@ -1053,7 +1053,7 @@ class Linker {
         */
        public static function blockLink( $userId, $userText ) {
                if ( $userText === '' ) {
-                       wfLogWarning( __METHOD__ . ' received an empty username. Are there database errors ' .
+                       wfDebug( __METHOD__ . ' received an empty username. Are there database errors ' .
                                'that need to be fixed?' );
                        return wfMessage( 'empty-username' )->parse();
                }
@@ -1232,6 +1232,14 @@ class Linker {
                                                $sectionText = str_replace( '[[', '&#91;[', $auto );
 
                                                $section = substr( Parser::guessSectionNameFromStrippedText( $section ), 1 );
+                                               // Support: HHVM (T222857)
+                                               // The guessSectionNameFromStrippedText method returns a non-empty string
+                                               // that starts with "#". Before PHP 7 (and still on HHVM) substr() would
+                                               // return false if the start offset is the end of the string.
+                                               // On PHP 7+, it gracefully returns empty string instead.
+                                               if ( $section === false ) {
+                                                       $section = '';
+                                               }
                                                if ( $local ) {
                                                        $sectionTitle = new TitleValue( NS_MAIN, '', $section );
                                                } else {
index 69bafaf..ca77121 100644 (file)
@@ -486,14 +486,14 @@ class MediaWiki {
                        }
 
                        # Let CDN cache things if we can purge them.
-                       if ( $this->config->get( 'UseSquid' ) &&
+                       if ( $this->config->get( 'UseCdn' ) &&
                                in_array(
                                        // Use PROTO_INTERNAL because that's what getCdnUrls() uses
                                        wfExpandUrl( $request->getRequestURL(), PROTO_INTERNAL ),
                                        $requestTitle->getCdnUrls()
                                )
                        ) {
-                               $output->setCdnMaxage( $this->config->get( 'SquidMaxage' ) );
+                               $output->setCdnMaxage( $this->config->get( 'CdnMaxAge' ) );
                        }
 
                        $action->show();
@@ -597,7 +597,7 @@ class MediaWiki {
                wfDebug( __METHOD__ . ': primary transaction round committed' );
 
                // Run updates that need to block the user or affect output (this is the last chance)
-               DeferredUpdates::doUpdates( 'enqueue', DeferredUpdates::PRESEND );
+               DeferredUpdates::doUpdates( 'run', DeferredUpdates::PRESEND );
                wfDebug( __METHOD__ . ': pre-send deferred updates completed' );
                // T214471: persist the session to avoid race conditions on subsequent requests
                $request->getSession()->save();
index 004ca07..832e24a 100644 (file)
@@ -46,6 +46,14 @@ class MovePage {
                $this->newTitle = $newTitle;
        }
 
+       /**
+        * Check if the user is allowed to perform the move.
+        *
+        * @param User $user
+        * @param string|null $reason To check against summary spam regex. Set to null to skip the check,
+        *   for instance to display errors preemptively before the user has filled in a summary.
+        * @return Status
+        */
        public function checkPermissions( User $user, $reason ) {
                $status = new Status();
 
@@ -63,7 +71,7 @@ class MovePage {
                        }
                }
 
-               if ( EditPage::matchSummarySpamRegex( $reason ) !== false ) {
+               if ( $reason !== null && EditPage::matchSummarySpamRegex( $reason ) !== false ) {
                        // This is kind of lame, won't display nice
                        $status->fatal( 'spamprotectiontext' );
                }
@@ -286,6 +294,132 @@ class MovePage {
                return $this->moveUnsafe( $user, $reason, $createRedirect, $changeTags );
        }
 
+       /**
+        * Move the source page's subpages to be subpages of the target page, without checking user
+        * permissions. The caller is responsible for moving the source page itself. We will still not
+        * do moves that are inherently not allowed, nor will we move more than $wgMaximumMovedPages.
+        *
+        * @param User $user
+        * @param string|null $reason The reason for the move
+        * @param bool|null $createRedirect Whether to create redirects from the old subpages to
+        *  the new ones
+        * @param string[] $changeTags Applied to entries in the move log and redirect page revision
+        * @return Status Good if no errors occurred. Ok if at least one page succeeded. The "value"
+        *  of the top-level status is an array containing the per-title status for each page. For any
+        *  move that succeeded, the "value" of the per-title status is the new page title.
+        */
+       public function moveSubpages(
+               User $user, $reason = null, $createRedirect = true, array $changeTags = []
+       ) {
+               return $this->moveSubpagesInternal( false, $user, $reason, $createRedirect, $changeTags );
+       }
+
+       /**
+        * Move the source page's subpages to be subpages of the target page, with user permission
+        * checks. The caller is responsible for moving the source page itself.
+        *
+        * @param User $user
+        * @param string|null $reason The reason for the move
+        * @param bool|null $createRedirect Whether to create redirects from the old subpages to
+        *  the new ones. Ignored if the user doesn't have the 'suppressredirect' right.
+        * @param string[] $changeTags Applied to entries in the move log and redirect page revision
+        * @return Status Good if no errors occurred. Ok if at least one page succeeded. The "value"
+        *  of the top-level status is an array containing the per-title status for each page. For any
+        *  move that succeeded, the "value" of the per-title status is the new page title.
+        */
+       public function moveSubpagesIfAllowed(
+               User $user, $reason = null, $createRedirect = true, array $changeTags = []
+       ) {
+               return $this->moveSubpagesInternal( true, $user, $reason, $createRedirect, $changeTags );
+       }
+
+       /**
+        * @param bool $checkPermissions
+        * @param User $user
+        * @param string $reason
+        * @param bool $createRedirect
+        * @param array $changeTags
+        * @return Status
+        */
+       private function moveSubpagesInternal(
+               $checkPermissions, User $user, $reason, $createRedirect, array $changeTags
+       ) {
+               global $wgMaximumMovedPages;
+               $services = MediaWikiServices::getInstance();
+
+               if ( $checkPermissions ) {
+                       if ( !$services->getPermissionManager()->userCan(
+                               'move-subpages', $user, $this->oldTitle )
+                       ) {
+                               return Status::newFatal( 'cant-move-subpages' );
+                       }
+               }
+
+               $nsInfo = $services->getNamespaceInfo();
+
+               // Do the source and target namespaces support subpages?
+               if ( !$nsInfo->hasSubpages( $this->oldTitle->getNamespace() ) ) {
+                       return Status::newFatal( 'namespace-nosubpages',
+                               $nsInfo->getCanonicalName( $this->oldTitle->getNamespace() ) );
+               }
+               if ( !$nsInfo->hasSubpages( $this->newTitle->getNamespace() ) ) {
+                       return Status::newFatal( 'namespace-nosubpages',
+                               $nsInfo->getCanonicalName( $this->newTitle->getNamespace() ) );
+               }
+
+               // Return a status for the overall result. Its value will be an array with per-title
+               // status for each subpage. Merge any errors from the per-title statuses into the
+               // top-level status without resetting the overall result.
+               $topStatus = Status::newGood();
+               $perTitleStatus = [];
+               $subpages = $this->oldTitle->getSubpages( $wgMaximumMovedPages + 1 );
+               $count = 0;
+               foreach ( $subpages as $oldSubpage ) {
+                       $count++;
+                       if ( $count > $wgMaximumMovedPages ) {
+                               $status = Status::newFatal( 'movepage-max-pages', $wgMaximumMovedPages );
+                               $perTitleStatus[$oldSubpage->getPrefixedText()] = $status;
+                               $topStatus->merge( $status );
+                               $topStatus->setOk( true );
+                               break;
+                       }
+
+                       // We don't know whether this function was called before or after moving the root page,
+                       // so check both titles
+                       if ( $oldSubpage->getArticleID() == $this->oldTitle->getArticleID() ||
+                               $oldSubpage->getArticleID() == $this->newTitle->getArticleID()
+                       ) {
+                               // When moving a page to a subpage of itself, don't move it twice
+                               continue;
+                       }
+                       $newPageName = preg_replace(
+                                       '#^' . preg_quote( $this->oldTitle->getDBkey(), '#' ) . '#',
+                                       StringUtils::escapeRegexReplacement( $this->newTitle->getDBkey() ), # T23234
+                                       $oldSubpage->getDBkey() );
+                       if ( $oldSubpage->isTalkPage() ) {
+                               $newNs = $this->newTitle->getTalkPage()->getNamespace();
+                       } else {
+                               $newNs = $this->newTitle->getSubjectPage()->getNamespace();
+                       }
+                       // T16385: we need makeTitleSafe because the new page names may be longer than 255
+                       // characters.
+                       $newSubpage = Title::makeTitleSafe( $newNs, $newPageName );
+
+                       $mp = new MovePage( $oldSubpage, $newSubpage );
+                       $method = $checkPermissions ? 'moveIfAllowed' : 'move';
+                       $status = $mp->$method( $user, $reason, $createRedirect, $changeTags );
+                       if ( $status->isOK() ) {
+                               $status->setResult( true, $newSubpage->getPrefixedText() );
+                       }
+                       $perTitleStatus[$oldSubpage->getPrefixedText()] = $status;
+                       $topStatus->merge( $status );
+                       $topStatus->setOk( true );
+               }
+
+               $topStatus->value = $perTitleStatus;
+               return $topStatus;
+       }
+
        /**
         * Moves *without* any sort of safety or sanity checks. Hooks can still fail the move, however.
         *
index 16c3784..ba9e2d7 100644 (file)
@@ -62,7 +62,7 @@ class OutputHandler {
                /// @todo FIXME: this sort of dupes some code in WebRequest::getRequestUrl()
                if ( isset( $_SERVER['REQUEST_URI'] ) ) {
                        // Strip the query string...
-                       list( $path ) = explode( '?', $_SERVER['REQUEST_URI'], 2 );
+                       $path = explode( '?', $_SERVER['REQUEST_URI'], 2 )[0];
                } elseif ( isset( $_SERVER['SCRIPT_NAME'] ) ) {
                        // Probably IIS. QUERY_STRING appears separately.
                        $path = $_SERVER['SCRIPT_NAME'];
index edffc3b..54b3ee5 100644 (file)
@@ -746,10 +746,10 @@ class OutputPage extends ContextSource {
                        'user' => $this->getUser()->getTouched(),
                        'epoch' => $config->get( 'CacheEpoch' )
                ];
-               if ( $config->get( 'UseSquid' ) ) {
+               if ( $config->get( 'UseCdn' ) ) {
                        $modifiedTimes['sepoch'] = wfTimestamp( TS_MW, $this->getCdnCacheEpoch(
                                time(),
-                               $config->get( 'SquidMaxage' )
+                               $config->get( 'CdnMaxAge' )
                        ) );
                }
                Hooks::run( 'OutputPageCheckLastModified', [ &$modifiedTimes, $this ] );
@@ -818,7 +818,7 @@ class OutputPage extends ContextSource {
         * @return int Timestamp
         */
        private function getCdnCacheEpoch( $reqTime, $maxAge ) {
-               // Ensure Last-Modified is never more than (wgSquidMaxage) in the past,
+               // Ensure Last-Modified is never more than $wgCdnMaxAge in the past,
                // because even if the wiki page content hasn't changed since, static
                // resources may have changed (skin HTML, interface messages, urls, etc.)
                // and must roll-over in a timely manner (T46570)
@@ -2248,12 +2248,12 @@ class OutputPage extends ContextSource {
         *
         * @param string|int|float|bool|null $mtime Last-Modified timestamp
         * @param int $minTTL Minimum TTL in seconds [default: 1 minute]
-        * @param int $maxTTL Maximum TTL in seconds [default: $wgSquidMaxage]
+        * @param int $maxTTL Maximum TTL in seconds [default: $wgCdnMaxAge]
         * @since 1.28
         */
        public function adaptCdnTTL( $mtime, $minTTL = 0, $maxTTL = 0 ) {
                $minTTL = $minTTL ?: IExpiringStore::TTL_MINUTE;
-               $maxTTL = $maxTTL ?: $this->getConfig()->get( 'SquidMaxage' );
+               $maxTTL = $maxTTL ?: $this->getConfig()->get( 'CdnMaxAge' );
 
                if ( $mtime === null || $mtime === false ) {
                        return $minTTL; // entity does not exist
@@ -2567,7 +2567,7 @@ class OutputPage extends ContextSource {
 
                if ( $this->mEnableClientCache ) {
                        if (
-                               $config->get( 'UseSquid' ) &&
+                               $config->get( 'UseCdn' ) &&
                                !$response->hasCookies() &&
                                !SessionManager::getGlobalSession()->isPersistent() &&
                                !$this->isPrintable() &&
@@ -2584,7 +2584,7 @@ class OutputPage extends ContextSource {
                                        # start with a shorter timeout for initial testing
                                        # header( 'Surrogate-Control: max-age=2678400+2678400, content="ESI/1.0"');
                                        $response->header(
-                                               "Surrogate-Control: max-age={$config->get( 'SquidMaxage' )}" .
+                                               "Surrogate-Control: max-age={$config->get( 'CdnMaxAge' )}" .
                                                "+{$this->mCdnMaxage}, content=\"ESI/1.0\""
                                        );
                                        $response->header( 'Cache-Control: s-maxage=0, must-revalidate, max-age=0' );
index e443803..0f68a13 100644 (file)
@@ -21,12 +21,12 @@ namespace MediaWiki\Permissions;
 
 use Action;
 use Exception;
-use FatalError;
 use Hooks;
 use MediaWiki\Linker\LinkTarget;
+use MediaWiki\Session\SessionManager;
 use MediaWiki\Special\SpecialPageFactory;
+use MediaWiki\User\UserIdentity;
 use MessageSpecifier;
-use MWException;
 use NamespaceInfo;
 use RequestContext;
 use SpecialPage;
@@ -69,12 +69,121 @@ class PermissionManager {
        /** @var NamespaceInfo */
        private $nsInfo;
 
+       /** @var string[][] Access rights for groups and users in these groups */
+       private $groupPermissions;
+
+       /** @var string[][] Permission keys revoked from users in each group */
+       private $revokePermissions;
+
+       /** @var string[] A list of available rights, in addition to the ones defined by the core */
+       private $availableRights;
+
+       /** @var string[] Cached results of getAllRights() */
+       private $allRights = false;
+
+       /** @var string[][] Cached user rights */
+       private $usersRights = null;
+
+       /** @var string[] Cached rights for isEveryoneAllowed */
+       private $cachedRights = [];
+
+       /**
+        * Array of Strings Core rights.
+        * Each of these should have a corresponding message of the form
+        * "right-$right".
+        * @showinitializer
+        */
+       private $coreRights = [
+               'apihighlimits',
+               'applychangetags',
+               'autoconfirmed',
+               'autocreateaccount',
+               'autopatrol',
+               'bigdelete',
+               'block',
+               'blockemail',
+               'bot',
+               'browsearchive',
+               'changetags',
+               'createaccount',
+               'createpage',
+               'createtalk',
+               'delete',
+               'deletechangetags',
+               'deletedhistory',
+               'deletedtext',
+               'deletelogentry',
+               'deleterevision',
+               'edit',
+               'editcontentmodel',
+               'editinterface',
+               'editprotected',
+               'editmyoptions',
+               'editmyprivateinfo',
+               'editmyusercss',
+               'editmyuserjson',
+               'editmyuserjs',
+               'editmywatchlist',
+               'editsemiprotected',
+               'editsitecss',
+               'editsitejson',
+               'editsitejs',
+               'editusercss',
+               'edituserjson',
+               'edituserjs',
+               'hideuser',
+               'import',
+               'importupload',
+               'ipblock-exempt',
+               'managechangetags',
+               'markbotedits',
+               'mergehistory',
+               'minoredit',
+               'move',
+               'movefile',
+               'move-categorypages',
+               'move-rootuserpages',
+               'move-subpages',
+               'nominornewtalk',
+               'noratelimit',
+               'override-export-depth',
+               'pagelang',
+               'patrol',
+               'patrolmarks',
+               'protect',
+               'purge',
+               'read',
+               'reupload',
+               'reupload-own',
+               'reupload-shared',
+               'rollback',
+               'sendemail',
+               'siteadmin',
+               'suppressionlog',
+               'suppressredirect',
+               'suppressrevision',
+               'unblockself',
+               'undelete',
+               'unwatchedpages',
+               'upload',
+               'upload_by_url',
+               'userrights',
+               'userrights-interwiki',
+               'viewmyprivateinfo',
+               'viewmywatchlist',
+               'viewsuppressed',
+               'writeapi',
+       ];
+
        /**
         * @param SpecialPageFactory $specialPageFactory
         * @param string[] $whitelistRead
         * @param string[] $whitelistReadRegexp
         * @param bool $emailConfirmToEdit
         * @param bool $blockDisablesLogin
+        * @param string[][] $groupPermissions
+        * @param string[][] $revokePermissions
+        * @param string[] $availableRights
         * @param NamespaceInfo $nsInfo
         */
        public function __construct(
@@ -83,6 +192,9 @@ class PermissionManager {
                $whitelistReadRegexp,
                $emailConfirmToEdit,
                $blockDisablesLogin,
+               $groupPermissions,
+               $revokePermissions,
+               $availableRights,
                NamespaceInfo $nsInfo
        ) {
                $this->specialPageFactory = $specialPageFactory;
@@ -90,6 +202,9 @@ class PermissionManager {
                $this->whitelistReadRegexp = $whitelistReadRegexp;
                $this->emailConfirmToEdit = $emailConfirmToEdit;
                $this->blockDisablesLogin = $blockDisablesLogin;
+               $this->groupPermissions = $groupPermissions;
+               $this->revokePermissions = $revokePermissions;
+               $this->availableRights = $availableRights;
                $this->nsInfo = $nsInfo;
        }
 
@@ -111,7 +226,6 @@ class PermissionManager {
         *   - RIGOR_SECURE : does cheap and expensive checks, using the master as needed
         *
         * @return bool
-        * @throws Exception
         */
        public function userCan( $action, User $user, LinkTarget $page, $rigor = self::RIGOR_SECURE ) {
                return !count( $this->getPermissionErrorsInternal( $action, $user, $page, $rigor, true ) );
@@ -133,7 +247,6 @@ class PermissionManager {
         *   whose corresponding errors may be ignored.
         *
         * @return array Array of arrays of the arguments to wfMessage to explain permissions problems.
-        * @throws Exception
         */
        public function getPermissionErrors(
                $action,
@@ -167,8 +280,6 @@ class PermissionManager {
         * @param bool $fromReplica Whether to check the replica DB instead of the master
         *
         * @return bool
-        * @throws FatalError
-        * @throws MWException
         */
        public function isBlockedFrom( User $user, LinkTarget $page, $fromReplica = false ) {
                $blocked = $user->isHidden();
@@ -286,8 +397,6 @@ class PermissionManager {
         * @param LinkTarget $page
         *
         * @return array List of errors
-        * @throws FatalError
-        * @throws MWException
         */
        private function checkPermissionHooks(
                $action,
@@ -363,8 +472,6 @@ class PermissionManager {
         * @param LinkTarget $page
         *
         * @return array List of errors
-        * @throws FatalError
-        * @throws MWException
         */
        private function checkReadPermissions(
                $action,
@@ -497,7 +604,6 @@ class PermissionManager {
         * @param LinkTarget $page
         *
         * @return array List of errors
-        * @throws MWException
         */
        private function checkUserBlock(
                $action,
@@ -583,8 +689,6 @@ class PermissionManager {
         * @param LinkTarget $page
         *
         * @return array List of errors
-        * @throws FatalError
-        * @throws MWException
         */
        private function checkQuickPermissions(
                $action,
@@ -762,6 +866,7 @@ class PermissionManager {
                                        }
                                        if ( $right != '' && !$user->isAllowedAll( 'protect', $right ) ) {
                                                $wikiPages = '';
+                                               /** @var Title $wikiPage */
                                                foreach ( $cascadingSources as $wikiPage ) {
                                                        $wikiPages .= '* [[:' . $wikiPage->getPrefixedText() . "]]\n";
                                                }
@@ -789,7 +894,6 @@ class PermissionManager {
         * @param LinkTarget $page
         *
         * @return array List of errors
-        * @throws Exception
         */
        private function checkActionPermissions(
                $action,
@@ -1052,4 +1156,256 @@ class PermissionManager {
                return $errors;
        }
 
+       /**
+        * Testing a permission
+        *
+        * @since 1.34
+        *
+        * @param UserIdentity $user
+        * @param string $action
+        *
+        * @return bool
+        */
+       public function userHasRight( UserIdentity $user, $action = '' ) {
+               if ( $action === '' ) {
+                       return true; // In the spirit of DWIM
+               }
+               // Use strict parameter to avoid matching numeric 0 accidentally inserted
+               // by misconfiguration: 0 == 'foo'
+               return in_array( $action, $this->getUserPermissions( $user ), true );
+       }
+
+       /**
+        * Get the permissions this user has.
+        *
+        * @since 1.34
+        *
+        * @param UserIdentity $user
+        *
+        * @return string[] permission names
+        */
+       public function getUserPermissions( UserIdentity $user ) {
+               $user = User::newFromIdentity( $user );
+               if ( !isset( $this->usersRights[ $user->getId() ] ) ) {
+                       $this->usersRights[ $user->getId() ] = $this->getGroupPermissions(
+                               $user->getEffectiveGroups()
+                       );
+                       Hooks::run( 'UserGetRights', [ $user, &$this->usersRights[ $user->getId() ] ] );
+
+                       // Deny any rights denied by the user's session, unless this
+                       // endpoint has no sessions.
+                       if ( !defined( 'MW_NO_SESSION' ) ) {
+                               // FIXME: $user->getRequest().. need to be replaced with something else
+                               $allowedRights = $user->getRequest()->getSession()->getAllowedUserRights();
+                               if ( $allowedRights !== null ) {
+                                       $this->usersRights[ $user->getId() ] = array_intersect(
+                                               $this->usersRights[ $user->getId() ],
+                                               $allowedRights
+                                       );
+                               }
+                       }
+
+                       Hooks::run( 'UserGetRightsRemove', [ $user, &$this->usersRights[ $user->getId() ] ] );
+                       // Force reindexation of rights when a hook has unset one of them
+                       $this->usersRights[ $user->getId() ] = array_values(
+                               array_unique( $this->usersRights[ $user->getId() ] )
+                       );
+
+                       if (
+                               $user->isLoggedIn() &&
+                               $this->blockDisablesLogin &&
+                               $user->getBlock()
+                       ) {
+                               $anon = new User;
+                               $this->usersRights[ $user->getId() ] = array_intersect(
+                                       $this->usersRights[ $user->getId() ],
+                                       $this->getUserPermissions( $anon )
+                               );
+                       }
+               }
+               return $this->usersRights[ $user->getId() ];
+       }
+
+       /**
+        * Clears users permissions cache, if specific user is provided it tries to clear
+        * permissions cache only for provided user.
+        *
+        * @since 1.34
+        *
+        * @param User|null $user
+        */
+       public function invalidateUsersRightsCache( $user = null ) {
+               if ( $user !== null ) {
+                       if ( isset( $this->usersRights[ $user->getId() ] ) ) {
+                               unset( $this->usersRights[$user->getId()] );
+                       }
+               } else {
+                       $this->usersRights = null;
+               }
+       }
+
+       /**
+        * Check, if the given group has the given permission
+        *
+        * If you're wanting to check whether all users have a permission, use
+        * PermissionManager::isEveryoneAllowed() instead. That properly checks if it's revoked
+        * from anyone.
+        *
+        * @since 1.34
+        *
+        * @param string $group Group to check
+        * @param string $role Role to check
+        *
+        * @return bool
+        */
+       public function groupHasPermission( $group, $role ) {
+               return isset( $this->groupPermissions[$group][$role] ) &&
+                          $this->groupPermissions[$group][$role] &&
+                          !( isset( $this->revokePermissions[$group][$role] ) &&
+                                 $this->revokePermissions[$group][$role] );
+       }
+
+       /**
+        * Get the permissions associated with a given list of groups
+        *
+        * @since 1.34
+        *
+        * @param array $groups Array of Strings List of internal group names
+        * @return array Array of Strings List of permission key names for given groups combined
+        */
+       public function getGroupPermissions( $groups ) {
+               $rights = [];
+               // grant every granted permission first
+               foreach ( $groups as $group ) {
+                       if ( isset( $this->groupPermissions[$group] ) ) {
+                               $rights = array_merge( $rights,
+                                       // array_filter removes empty items
+                                       array_keys( array_filter( $this->groupPermissions[$group] ) ) );
+                       }
+               }
+               // now revoke the revoked permissions
+               foreach ( $groups as $group ) {
+                       if ( isset( $this->revokePermissions[$group] ) ) {
+                               $rights = array_diff( $rights,
+                                       array_keys( array_filter( $this->revokePermissions[$group] ) ) );
+                       }
+               }
+               return array_unique( $rights );
+       }
+
+       /**
+        * Get all the groups who have a given permission
+        *
+        * @since 1.34
+        *
+        * @param string $role Role to check
+        * @return array Array of Strings List of internal group names with the given permission
+        */
+       public function getGroupsWithPermission( $role ) {
+               $allowedGroups = [];
+               foreach ( array_keys( $this->groupPermissions ) as $group ) {
+                       if ( $this->groupHasPermission( $group, $role ) ) {
+                               $allowedGroups[] = $group;
+                       }
+               }
+               return $allowedGroups;
+       }
+
+       /**
+        * Check if all users may be assumed to have the given permission
+        *
+        * We generally assume so if the right is granted to '*' and isn't revoked
+        * on any group. It doesn't attempt to take grants or other extension
+        * limitations on rights into account in the general case, though, as that
+        * would require it to always return false and defeat the purpose.
+        * Specifically, session-based rights restrictions (such as OAuth or bot
+        * passwords) are applied based on the current session.
+        *
+        * @param string $right Right to check
+        *
+        * @return bool
+        * @since 1.34
+        */
+       public function isEveryoneAllowed( $right ) {
+               // Use the cached results, except in unit tests which rely on
+               // being able change the permission mid-request
+               if ( isset( $this->cachedRights[$right] ) ) {
+                       return $this->cachedRights[$right];
+               }
+
+               if ( !isset( $this->groupPermissions['*'][$right] )
+                        || !$this->groupPermissions['*'][$right] ) {
+                       $this->cachedRights[$right] = false;
+                       return false;
+               }
+
+               // If it's revoked anywhere, then everyone doesn't have it
+               foreach ( $this->revokePermissions as $rights ) {
+                       if ( isset( $rights[$right] ) && $rights[$right] ) {
+                               $this->cachedRights[$right] = false;
+                               return false;
+                       }
+               }
+
+               // Remove any rights that aren't allowed to the global-session user,
+               // unless there are no sessions for this endpoint.
+               if ( !defined( 'MW_NO_SESSION' ) ) {
+
+                       // XXX: think what could be done with the below
+                       $allowedRights = SessionManager::getGlobalSession()->getAllowedUserRights();
+                       if ( $allowedRights !== null && !in_array( $right, $allowedRights, true ) ) {
+                               $this->cachedRights[$right] = false;
+                               return false;
+                       }
+               }
+
+               // Allow extensions to say false
+               if ( !Hooks::run( 'UserIsEveryoneAllowed', [ $right ] ) ) {
+                       $this->cachedRights[$right] = false;
+                       return false;
+               }
+
+               $this->cachedRights[$right] = true;
+               return true;
+       }
+
+       /**
+        * Get a list of all available permissions.
+        *
+        * @since 1.34
+        *
+        * @return string[] Array of permission names
+        */
+       public function getAllPermissions() {
+               if ( $this->allRights === false ) {
+                       if ( count( $this->availableRights ) ) {
+                               $this->allRights = array_unique( array_merge(
+                                       $this->coreRights,
+                                       $this->availableRights
+                               ) );
+                       } else {
+                               $this->allRights = $this->coreRights;
+                       }
+                       Hooks::run( 'UserGetAllRights', [ &$this->allRights ] );
+               }
+               return $this->allRights;
+       }
+
+       /**
+        * Overrides user permissions cache
+        *
+        * @since 1.34
+        *
+        * @param User $user
+        * @param string[]|string $rights
+        *
+        * @throws Exception
+        */
+       public function overrideUserRightsForTesting( $user, $rights = [] ) {
+               if ( !defined( 'MW_PHPUNIT_TEST' ) ) {
+                       throw new Exception( __METHOD__ . ' can not be called outside of tests' );
+               }
+               $this->usersRights[ $user->getId() ] = is_array( $rights ) ? $rights : [ $rights ];
+       }
+
 }
index 9b064ce..75c7435 100644 (file)
@@ -416,13 +416,22 @@ return [
        },
 
        'ParserFactory' => function ( MediaWikiServices $services ) : ParserFactory {
-               return new ParserFactory(
+               $options = new ServiceOptions( Parser::$constructorOptions,
+                       // 'class' and 'preprocessorClass'
                        $services->getMainConfig()->get( 'ParserConf' ),
+                       // Make sure to have defaults in case someone overrode ParserConf with something silly
+                       [ 'class' => Parser::class,
+                               'preprocessorClass' => Parser::getDefaultPreprocessorClass() ],
+                       // Plus a buch of actual config options
+                       $services->getMainConfig()
+               );
+
+               return new ParserFactory(
+                       $options,
                        $services->getMagicWordFactory(),
                        $services->getContentLanguage(),
                        wfUrlProtocols(),
                        $services->getSpecialPageFactory(),
-                       $services->getMainConfig(),
                        $services->getLinkRendererFactory(),
                        $services->getNamespaceInfo()
                );
@@ -454,6 +463,9 @@ return [
                        $config->get( 'WhitelistReadRegexp' ),
                        $config->get( 'EmailConfirmToEdit' ),
                        $config->get( 'BlockDisablesLogin' ),
+                       $config->get( 'GroupPermissions' ),
+                       $config->get( 'RevokePermissions' ),
+                       $config->get( 'AvailableRights' ),
                        $services->getNamespaceInfo()
                );
        },
@@ -475,8 +487,8 @@ return [
        'ProxyLookup' => function ( MediaWikiServices $services ) : ProxyLookup {
                $mainConfig = $services->getMainConfig();
                return new ProxyLookup(
-                       $mainConfig->get( 'SquidServers' ),
-                       $mainConfig->get( 'SquidServersNoPurge' )
+                       $mainConfig->get( 'CdnServers' ),
+                       $mainConfig->get( 'CdnServersNoPurge' )
                );
        },
 
index 071b7c6..f367fc2 100644 (file)
@@ -518,9 +518,61 @@ foreach ( LanguageCode::getNonstandardLanguageCodeMapping() as $code => $bcp47 )
 // To determine the user language, use $wgLang->getCode()
 $wgContLanguageCode = $wgLanguageCode;
 
+// Temporary backwards-compatibility reading of old Squid-named CDN settings as of MediaWiki 1.34,
+// to support sysadmins who fail to update their settings immediately:
+
+if ( isset( $wgUseSquid ) ) {
+       // If the sysadmin is still setting a value of $wgUseSquid to true but $wgUseCdn is the default of
+       // false, to be safe, assume they do want this still, so enable it.
+       if ( !$wgUseCdn && $wgUseSquid ) {
+               $wgUseCdn = $wgUseSquid;
+               wfDeprecated( '$wgUseSquid enabled but $wgUseCdn disabled; enabling CDN functions', '1.34' );
+       }
+} else {
+       // Backwards-compatibility for extensions that read this value.
+       $wgUseSquid = $wgUseCdn;
+}
+
+if ( isset( $wgSquidServers ) ) {
+       // If the sysadmin is still setting a value of $wgSquidServers but $wgCdnServers is the default of
+       // empty, to be safe, assume they do want these servers to be still used, so use them.
+       if ( !empty( $wgSquidServers ) && empty( $wgCdnServers ) ) {
+               $wgCdnServers = $wgSquidServers;
+               wfDeprecated( '$wgSquidServers set, $wgCdnServers empty; using them', '1.34' );
+       }
+} else {
+       // Backwards-compatibility for extensions that read this value.
+       $wgSquidServers = $wgCdnServers;
+}
+
+if ( isset( $wgSquidServersNoPurge ) ) {
+       // If the sysadmin is still setting values in $wgSquidServersNoPurge but $wgCdnServersNoPurge is
+       // the default of empty, to be safe, assume they do want these servers to be still used, so use
+       // them.
+       if ( !empty( $wgSquidServersNoPurge ) && empty( $wgCdnServersNoPurge ) ) {
+               $wgCdnServersNoPurge = $wgSquidServersNoPurge;
+               wfDeprecated( '$wgSquidServersNoPurge set, $wgCdnServersNoPurge empty; using them', '1.34' );
+       }
+} else {
+       // Backwards-compatibility for extensions that read this value.
+       $wgSquidServersNoPurge = $wgCdnServersNoPurge;
+}
+
+if ( isset( $wgSquidMaxage ) ) {
+       // If the sysadmin is still setting a value of $wgSquidMaxage and it's higher than $wgCdnMaxAge,
+       // to be safe, assume they want the higher (lower performance requirement) value, so use that.
+       if ( $wgCdnMaxAge < $wgSquidMaxage ) {
+               $wgCdnMaxAge = $wgSquidMaxage;
+               wfDeprecated( '$wgSquidMaxage set higher than $wgCdnMaxAge; using the higher value', '1.34' );
+       }
+} else {
+       // Backwards-compatibility for extensions that read this value.
+       $wgSquidMaxage = $wgCdnMaxAge;
+}
+
 // Easy to forget to falsify $wgDebugToolbar for static caches.
 // If file cache or CDN cache is on, just disable this (DWIMD).
-if ( $wgUseFileCache || $wgUseSquid ) {
+if ( $wgUseFileCache || $wgUseCdn ) {
        $wgDebugToolbar = false;
 }
 
@@ -605,20 +657,6 @@ if ( $wgDebugToolbar && !$wgCommandLineMode ) {
 // re-created while taking into account any custom settings and extensions.
 MediaWikiServices::resetGlobalInstance( new GlobalVarConfig(), 'quick' );
 
-if ( $wgSharedDB && $wgSharedTables ) {
-       // Apply $wgSharedDB table aliases for the local LB (all non-foreign DB connections)
-       MediaWikiServices::getInstance()->getDBLoadBalancer()->setTableAliases(
-               array_fill_keys(
-                       $wgSharedTables,
-                       [
-                               'dbname' => $wgSharedDB,
-                               'schema' => $wgSharedSchema,
-                               'prefix' => $wgSharedPrefix
-                       ]
-               )
-       );
-}
-
 // Define a constant that indicates that the bootstrapping of the service locator
 // is complete.
 define( 'MW_SERVICE_BOOTSTRAP_COMPLETE', 1 );
@@ -694,6 +732,20 @@ if ( $wgMainWANCache === false ) {
        ];
 }
 
+if ( $wgSharedDB && $wgSharedTables ) {
+       // Apply $wgSharedDB table aliases for the local LB (all non-foreign DB connections)
+       MediaWikiServices::getInstance()->getDBLoadBalancer()->setTableAliases(
+               array_fill_keys(
+                       $wgSharedTables,
+                       [
+                               'dbname' => $wgSharedDB,
+                               'schema' => $wgSharedSchema,
+                               'prefix' => $wgSharedPrefix
+                       ]
+               )
+       );
+}
+
 Profiler::instance()->scopedProfileOut( $ps_default2 );
 
 $ps_misc = Profiler::instance()->scopedProfileIn( $fname . '-misc' );
index bc48a0e..ff5541d 100644 (file)
@@ -1582,10 +1582,10 @@ class DerivedPageDataUpdater implements IDBAccessObject {
                ];
                $deferValues = [ false, DeferredUpdates::PRESEND, DeferredUpdates::POSTSEND ];
                if ( !in_array( $options['defer'], $deferValues, true ) ) {
-                       throw new InvalidArgumentException( 'invalid value for defer: ' . $options['defer'] );
+                       throw new InvalidArgumentException( 'Invalid value for defer: ' . $options['defer'] );
                }
-               Assert::parameterType( 'integer|null', $options['transactionTicket'],
-                       '$options[\'transactionTicket\']' );
+               Assert::parameterType(
+                       'integer|null', $options['transactionTicket'], '$options[\'transactionTicket\']' );
 
                $updates = $this->getSecondaryDataUpdates( $options['recursive'] );
 
@@ -1596,14 +1596,13 @@ class DerivedPageDataUpdater implements IDBAccessObject {
                $causeAction = $this->options['causeAction'] ?? 'unknown';
                $causeAgent = $this->options['causeAgent'] ?? 'unknown';
                $legacyRevision = new Revision( $this->revision );
+               $ticket = $options['transactionTicket'];
 
-               if ( $options['defer'] === false && $options['transactionTicket'] !== null ) {
+               if ( $options['defer'] === false && $ticket !== null ) {
                        // For legacy hook handlers doing updates via LinksUpdateConstructed, make sure
                        // any pending writes they made get flushed before the doUpdate() calls below.
                        // This avoids snapshot-clearing errors in LinksUpdate::acquirePageLock().
-                       $this->loadbalancerFactory->commitAndWaitForReplication(
-                               __METHOD__, $options['transactionTicket']
-                       );
+                       $this->loadbalancerFactory->commitAndWaitForReplication( __METHOD__, $ticket );
                }
 
                foreach ( $updates as $update ) {
@@ -1616,8 +1615,8 @@ class DerivedPageDataUpdater implements IDBAccessObject {
                        }
 
                        if ( $options['defer'] === false ) {
-                               if ( $update instanceof DataUpdate && $options['transactionTicket'] !== null ) {
-                                       $update->setTransactionTicket( $options['transactionTicket'] );
+                               if ( $update instanceof DataUpdate && $ticket !== null ) {
+                                       $update->setTransactionTicket( $ticket );
                                }
                                $update->doUpdate();
                        } else {
index 866f041..3d262d5 100644 (file)
@@ -3429,6 +3429,8 @@ class Title implements LinkTarget, IDBAccessObject {
         * @return array|bool True on success, getUserPermissionsErrors()-like array on failure
         */
        public function isValidMoveOperation( &$nt, $auth = true, $reason = '' ) {
+               wfDeprecated( __METHOD__, '1.25' );
+
                global $wgUser;
 
                if ( !( $nt instanceof Title ) ) {
@@ -3465,6 +3467,8 @@ class Title implements LinkTarget, IDBAccessObject {
        public function moveTo( &$nt, $auth = true, $reason = '', $createRedirect = true,
                array $changeTags = []
        ) {
+               wfDeprecated( __METHOD__, '1.25' );
+
                global $wgUser;
 
                $mp = new MovePage( $this, $nt );
@@ -3480,6 +3484,7 @@ class Title implements LinkTarget, IDBAccessObject {
        /**
         * Move this page's subpages to be subpages of $nt
         *
+        * @deprecated since 1.34, use MovePage instead
         * @param Title $nt Move target
         * @param bool $auth Whether $wgUser's permissions should be checked
         * @param string $reason The reason for the move
@@ -3494,66 +3499,24 @@ class Title implements LinkTarget, IDBAccessObject {
        public function moveSubpages( $nt, $auth = true, $reason = '', $createRedirect = true,
                array $changeTags = []
        ) {
-               global $wgMaximumMovedPages;
-               // Check permissions
-               if ( !$this->userCan( 'move-subpages' ) ) {
-                       return [
-                               [ 'cant-move-subpages' ],
-                       ];
-               }
-               // Do the source and target namespaces support subpages?
-               $nsInfo = MediaWikiServices::getInstance()->getNamespaceInfo();
-               if ( !$nsInfo->hasSubpages( $this->mNamespace ) ) {
-                       return [
-                               [ 'namespace-nosubpages', $nsInfo->getCanonicalName( $this->mNamespace ) ],
-                       ];
-               }
-               if ( !$nsInfo->hasSubpages( $nt->getNamespace() ) ) {
-                       return [
-                               [ 'namespace-nosubpages', $nsInfo->getCanonicalName( $nt->getNamespace() ) ],
-                       ];
-               }
+               wfDeprecated( __METHOD__, '1.34' );
 
-               $subpages = $this->getSubpages( $wgMaximumMovedPages + 1 );
-               $retval = [];
-               $count = 0;
-               foreach ( $subpages as $oldSubpage ) {
-                       $count++;
-                       if ( $count > $wgMaximumMovedPages ) {
-                               $retval[$oldSubpage->getPrefixedText()] = [
-                                       [ 'movepage-max-pages', $wgMaximumMovedPages ],
-                               ];
-                               break;
-                       }
+               global $wgUser;
 
-                       // We don't know whether this function was called before
-                       // or after moving the root page, so check both
-                       // $this and $nt
-                       if ( $oldSubpage->getArticleID() == $this->getArticleID()
-                               || $oldSubpage->getArticleID() == $nt->getArticleID()
-                       ) {
-                               // When moving a page to a subpage of itself,
-                               // don't move it twice
-                               continue;
-                       }
-                       $newPageName = preg_replace(
-                                       '#^' . preg_quote( $this->mDbkeyform, '#' ) . '#',
-                                       StringUtils::escapeRegexReplacement( $nt->getDBkey() ), # T23234
-                                       $oldSubpage->getDBkey() );
-                       if ( $oldSubpage->isTalkPage() ) {
-                               $newNs = $nt->getTalkPage()->getNamespace();
-                       } else {
-                               $newNs = $nt->getSubjectPage()->getNamespace();
-                       }
-                       # T16385: we need makeTitleSafe because the new page names may
-                       # be longer than 255 characters.
-                       $newSubpage = self::makeTitleSafe( $newNs, $newPageName );
+               $mp = new MovePage( $this, $nt );
+               $method = $auth ? 'moveSubpagesIfAllowed' : 'moveSubpages';
+               $result = $mp->$method( $wgUser, $reason, $createRedirect, $changeTags );
+
+               if ( !$result->isOk() ) {
+                       return $result->getErrorsArray();
+               }
 
-                       $success = $oldSubpage->moveTo( $newSubpage, $auth, $reason, $createRedirect, $changeTags );
-                       if ( $success === true ) {
-                               $retval[$oldSubpage->getPrefixedText()] = $newSubpage->getPrefixedText();
+               $retval = [];
+               foreach ( $result->getValue() as $key => $status ) {
+                       if ( $status->isOK() ) {
+                               $retval[$key] = $status->getValue();
                        } else {
-                               $retval[$oldSubpage->getPrefixedText()] = $success;
+                               $retval[$key] = $status->getErrorsArray();
                        }
                }
                return $retval;
@@ -3617,6 +3580,8 @@ class Title implements LinkTarget, IDBAccessObject {
         * @return bool
         */
        public function isValidMoveTarget( $nt ) {
+               wfDeprecated( __METHOD__, '1.25' );
+
                # Is it an existing file?
                if ( $nt->getNamespace() == NS_FILE ) {
                        $file = wfLocalFile( $nt );
index 14f7603..505c9d5 100644 (file)
@@ -67,7 +67,7 @@ class RawAction extends FormlessAction {
 
                $contentType = $this->getContentType();
 
-               $maxage = $request->getInt( 'maxage', $config->get( 'SquidMaxage' ) );
+               $maxage = $request->getInt( 'maxage', $config->get( 'CdnMaxAge' ) );
                $smaxage = $request->getIntOrNull( 'smaxage' );
                if ( $smaxage === null ) {
                        if (
index 7cb2dbf..dd1a6db 100644 (file)
@@ -21,6 +21,7 @@
  */
 
 use MediaWiki\Block\AbstractBlock;
+use MediaWiki\Block\DatabaseBlock;
 use MediaWiki\MediaWikiServices;
 use Wikimedia\Rdbms\IDatabase;
 
@@ -2034,7 +2035,7 @@ abstract class ApiBase extends ContextSource {
         */
        public function dieBlocked( AbstractBlock $block ) {
                // Die using the appropriate message depending on block type
-               if ( $block->getType() == Block::TYPE_AUTO ) {
+               if ( $block->getType() == DatabaseBlock::TYPE_AUTO ) {
                        $this->dieWithError(
                                'apierror-autoblocked',
                                'autoblocked',
index f7c2bce..c71de40 100644 (file)
@@ -20,6 +20,8 @@
  * @file
  */
 
+use MediaWiki\Block\DatabaseBlock;
+
 /**
  * API module that facilitates the blocking of users. Requires API write mode
  * to be enabled.
@@ -82,7 +84,7 @@ class ApiBlock extends ApiBase {
 
                        // T40633 - if the target is a user (not an IP address), but it
                        // doesn't exist or is unusable, error.
-                       if ( $type === Block::TYPE_USER &&
+                       if ( $type === DatabaseBlock::TYPE_USER &&
                                ( $target->isAnon() /* doesn't exist */ || !User::isUsableName( $params['user'] ) )
                        ) {
                                $this->dieWithError( [ 'nosuchusershort', $params['user'] ], 'nosuchuser' );
@@ -136,8 +138,8 @@ class ApiBlock extends ApiBase {
                $res['user'] = $params['user'];
                $res['userID'] = $target instanceof User ? $target->getId() : 0;
 
-               $block = Block::newFromTarget( $target, null, true );
-               if ( $block instanceof Block ) {
+               $block = DatabaseBlock::newFromTarget( $target, null, true );
+               if ( $block instanceof DatabaseBlock ) {
                        $res['expiry'] = ApiResult::formatExpiry( $block->getExpiry(), 'infinite' );
                        $res['id'] = $block->getId();
                } else {
index 588e31a..b845c57 100644 (file)
@@ -148,7 +148,7 @@ class ApiMain extends ApiBase {
        private $mContinuationManager;
        private $mAction;
        private $mEnableWrite;
-       private $mInternalMode, $mSquidMaxage;
+       private $mInternalMode, $mCdnMaxAge;
        /** @var ApiBase */
        private $mModule;
 
@@ -288,7 +288,7 @@ class ApiMain extends ApiBase {
                $this->mContinuationManager = null;
                $this->mEnableWrite = $enableWrite;
 
-               $this->mSquidMaxage = -1; // flag for executeActionWithErrorHandling()
+               $this->mCdnMaxAge = -1; // flag for executeActionWithErrorHandling()
                $this->mCommit = false;
        }
 
@@ -1368,18 +1368,20 @@ class ApiMain extends ApiBase {
                                                $ts->format( 'D M j H:i:s Y' ) === $value ||
                                                $ts->format( 'D M  j H:i:s Y' ) === $value
                                        ) {
+                                               $config = $this->getConfig();
                                                $lastMod = $module->getConditionalRequestData( 'last-modified' );
                                                if ( $lastMod !== null ) {
                                                        // Mix in some MediaWiki modification times
                                                        $modifiedTimes = [
                                                                'page' => $lastMod,
                                                                'user' => $this->getUser()->getTouched(),
-                                                               'epoch' => $this->getConfig()->get( 'CacheEpoch' ),
+                                                               'epoch' => $config->get( 'CacheEpoch' ),
                                                        ];
-                                                       if ( $this->getConfig()->get( 'UseSquid' ) ) {
+
+                                                       if ( $config->get( 'UseCdn' ) ) {
                                                                // T46570: the core page itself may not change, but resources might
                                                                $modifiedTimes['sepoch'] = wfTimestamp(
-                                                                       TS_MW, time() - $this->getConfig()->get( 'SquidMaxage' )
+                                                                       TS_MW, time() - $config->get( 'CdnMaxAge' )
                                                                );
                                                        }
                                                        Hooks::run( 'OutputPageCheckLastModified', [ &$modifiedTimes, $this->getOutput() ] );
@@ -1838,7 +1840,7 @@ class ApiMain extends ApiBase {
         */
        protected function printResult( $httpCode = 0 ) {
                if ( $this->getConfig()->get( 'DebugAPI' ) !== false ) {
-                       $this->addWarning( 'apiwarn-wgDebugAPI' );
+                       $this->addWarning( 'apiwarn-wgdebugapi' );
                }
 
                $printer = $this->mPrinter;
index cc4490e..89ecc43 100644 (file)
@@ -201,22 +201,22 @@ class ApiMove extends ApiBase {
        public function moveSubpages( $fromTitle, $toTitle, $reason, $noredirect, $changeTags = [] ) {
                $retval = [];
 
-               $success = $fromTitle->moveSubpages( $toTitle, true, $reason, !$noredirect, $changeTags );
-               if ( isset( $success[0] ) ) {
-                       $status = $this->errorArrayToStatus( $success );
-                       return [ 'errors' => $this->getErrorFormatter()->arrayFromStatus( $status ) ];
+               $mp = new MovePage( $fromTitle, $toTitle );
+               $result =
+                       $mp->moveSubpagesIfAllowed( $this->getUser(), $reason, !$noredirect, $changeTags );
+               if ( !$result->isOk() ) {
+                       // This means the whole thing failed
+                       return [ 'errors' => $this->getErrorFormatter()->arrayFromStatus( $result ) ];
                }
 
                // At least some pages could be moved
                // Report each of them separately
-               foreach ( $success as $oldTitle => $newTitle ) {
+               foreach ( $result->getValue() as $oldTitle => $status ) {
                        $r = [ 'from' => $oldTitle ];
-                       if ( is_array( $newTitle ) ) {
-                               $status = $this->errorArrayToStatus( $newTitle );
-                               $r['errors'] = $this->getErrorFormatter()->arrayFromStatus( $status );
+                       if ( $status->isOK() ) {
+                               $r['to'] = $status->getValue();
                        } else {
-                               // Success
-                               $r['to'] = $newTitle;
+                               $r['errors'] = $this->getErrorFormatter()->arrayFromStatus( $status );
                        }
                        $retval[] = $r;
                }
index acd11fd..40cd149 100644 (file)
@@ -406,7 +406,7 @@ class ApiQueryAllImages extends ApiQueryGeneratorBase {
        protected function getExamplesMessages() {
                return [
                        'action=query&list=allimages&aifrom=B'
-                               => 'apihelp-query+allimages-example-B',
+                               => 'apihelp-query+allimages-example-b',
                        'action=query&list=allimages&aiprop=user|timestamp|url&' .
                                'aisort=timestamp&aidir=older'
                                => 'apihelp-query+allimages-example-recent',
index fc23caa..1fc5ece 100644 (file)
@@ -291,7 +291,7 @@ class ApiQueryAllLinks extends ApiQueryGeneratorBase {
 
                return [
                        "action=query&list={$name}&{$p}from=B&{$p}prop=ids|title"
-                               => "apihelp-$path-example-B",
+                               => "apihelp-$path-example-b",
                        "action=query&list={$name}&{$p}unique=&{$p}from=B"
                                => "apihelp-$path-example-unique",
                        "action=query&generator={$name}&g{$p}unique=&g{$p}from=B"
index 08f3ea3..ba830ae 100644 (file)
@@ -342,7 +342,7 @@ class ApiQueryAllPages extends ApiQueryGeneratorBase {
        protected function getExamplesMessages() {
                return [
                        'action=query&list=allpages&apfrom=B'
-                               => 'apihelp-query+allpages-example-B',
+                               => 'apihelp-query+allpages-example-b',
                        'action=query&generator=allpages&gaplimit=4&gapfrom=T&prop=info'
                                => 'apihelp-query+allpages-example-generator',
                        'action=query&generator=allpages&gaplimit=2&' .
index 161cfb4..59e92e1 100644 (file)
@@ -393,7 +393,7 @@ class ApiQueryAllUsers extends ApiQueryBase {
        protected function getExamplesMessages() {
                return [
                        'action=query&list=allusers&aufrom=Y'
-                               => 'apihelp-query+allusers-example-Y',
+                               => 'apihelp-query+allusers-example-y',
                ];
        }
 
index 122e02f..2505334 100644 (file)
@@ -501,7 +501,7 @@ abstract class ApiQueryBase extends ApiBase {
        /**
         * Same as addPageSubItems(), but one element of $data at a time
         * @param int $pageId Page ID
-        * @param array $item Data array à la ApiResult
+        * @param mixed $item Data à la ApiResult
         * @param string|null $elemname XML element name. If null, getModuleName()
         *  is used
         * @return bool Whether the element fit in the result
index f526685..8edf00c 100644 (file)
@@ -135,7 +135,7 @@ class ApiQueryProtectedTitles extends ApiQueryGeneratorBase {
 
                                if ( isset( $prop['parsedcomment'] ) ) {
                                        $vals['parsedcomment'] = Linker::formatComment(
-                                               $commentStore->getComment( 'pt_reason', $row )->text, $titles
+                                               $commentStore->getComment( 'pt_reason', $row )->text
                                        );
                                }
 
index fc50289..ee6a264 100644 (file)
@@ -114,7 +114,7 @@ class ApiQueryRevisions extends ApiQueryRevisionsBase {
 
                if ( $revCount > 0 && $enumRevMode ) {
                        $this->dieWithError(
-                               [ 'apierror-revisions-nolist', $this->getModulePrefix() ], 'invalidparammix'
+                               [ 'apierror-revisions-norevids', $this->getModulePrefix() ], 'invalidparammix'
                        );
                }
 
@@ -389,6 +389,10 @@ class ApiQueryRevisions extends ApiQueryRevisionsBase {
 
                $this->addOption( 'LIMIT', $this->limit + 1 );
 
+               // T224017: `rev_timestamp` is never the correct index to use for this module, but
+               // MariaDB (10.1.37-39) sometimes insists on trying to use it anyway. Tell it not to.
+               $this->addOption( 'IGNORE INDEX', [ 'revision' => 'rev_timestamp' ] );
+
                $count = 0;
                $generated = [];
                $hookData = [];
index 1c72b67..5cef194 100644 (file)
@@ -20,6 +20,8 @@
  * @file
  */
 
+use MediaWiki\Block\DatabaseBlock;
+
 /**
  * API module that facilitates the unblocking of users. Requires API write mode
  * to be enabled.
@@ -78,14 +80,14 @@ class ApiUnblock extends ApiBase {
                        'Reason' => $params['reason'],
                        'Tags' => $params['tags']
                ];
-               $block = Block::newFromTarget( $data['Target'] );
+               $block = DatabaseBlock::newFromTarget( $data['Target'] );
                $retval = SpecialUnblock::processUnblock( $data, $this->getContext() );
                if ( $retval !== true ) {
                        $this->dieStatus( $this->errorArrayToStatus( $retval ) );
                }
 
                $res['id'] = $block->getId();
-               $target = $block->getType() == Block::TYPE_AUTO ? '' : $block->getTarget();
+               $target = $block->getType() == DatabaseBlock::TYPE_AUTO ? '' : $block->getTarget();
                $res['user'] = $target instanceof User ? $target->getName() : $target;
                $res['userid'] = $target instanceof User ? $target->getId() : 0;
                $res['reason'] = $params['reason'];
index 830b4d8..0701829 100644 (file)
        "apihelp-query+allfileusages-paramvalue-prop-title": "تضيف عنوان الملف.",
        "apihelp-query+allfileusages-param-limit": "كم عدد مجموع البنود للعودة.",
        "apihelp-query+allfileusages-param-dir": "الاتجاه للإدراج فيه.",
-       "apihelp-query+allfileusages-example-B": "سرد عناوين الملفات، بما في ذلك العناوين المفقودة، مع معرفات الصفحات التي تنتمي إليها، بدءا من <kbd>B</kbd.",
+       "apihelp-query+allfileusages-example-b": "سرد عناوين الملفات، بما في ذلك العناوين المفقودة، مع معرفات الصفحات التي تنتمي إليها، بدءا من <kbd>B</kbd.",
        "apihelp-query+allfileusages-example-unique": "سرد عناوين الملفات الفريدة.",
        "apihelp-query+allfileusages-example-unique-generator": "الحصول على جميع عناوين الملفات، والتعليم على المفقودة.",
        "apihelp-query+allfileusages-example-generator": "الحصول على الصفحات التي تحتوي على الملفات.",
        "apihelp-query+allimages-param-filterbots": "كيفية تصفية الملفات التي تم تحميلها بواسطة بوتات. يمكن استخدامها مع $1sort=timestamp فقط. لا يمكن أن تُستخدَم بجانب $1user.",
        "apihelp-query+allimages-param-mime": "عن أي أنواع MIME تبحث، على سبيل المثال <kbd>image/jpeg</kbd>.",
        "apihelp-query+allimages-param-limit": "كم عدد الصور الإجمالي للعودة.",
-       "apihelp-query+allimages-example-B": "أظهر قائمة الملفات التي تبدأ ب<kbd>B</kbd>.",
+       "apihelp-query+allimages-example-b": "أظهر قائمة الملفات التي تبدأ ب<kbd>B</kbd>.",
        "apihelp-query+allimages-example-recent": "أظهر قائمة الملفات التي تم تحميلها مؤخرا، على غرار [[Special:NewFiles|خاص:ملفات جديدة]].",
        "apihelp-query+allimages-example-mimetypes": "أظهر قائمة الملفات من نوع MIME <kbd>image/png</kbd> أو <kbd>image/gif</kbd>",
        "apihelp-query+allimages-example-generator": "عرض معلومات حول 4 ملفات تبدأ بالحرف <kbd>T</kbd>.",
        "apihelp-query+alllinks-param-namespace": "نطاق للتعداد.",
        "apihelp-query+alllinks-param-limit": "كم عدد مجموع البنود للعودة.",
        "apihelp-query+alllinks-param-dir": "الاتجاه للإدراج فيه.",
-       "apihelp-query+alllinks-example-B": "سرد العناوين المرتبطة، بما في ذلك المفقودة، مع معرفات الصفحات التي تنتمي إليها، بدءا من <kbd>B</kbd.",
+       "apihelp-query+alllinks-example-b": "سرد العناوين المرتبطة، بما في ذلك المفقودة، مع معرفات الصفحات التي تنتمي إليها، بدءا من <kbd>B</kbd.",
        "apihelp-query+alllinks-example-unique": "سرد العناوين المرتبطة الفريدة.",
        "apihelp-query+alllinks-example-unique-generator": "الحصول على جميع العناوين المرتبطة، والتعليم على المفقودة.",
        "apihelp-query+alllinks-example-generator": "يحصل على الصفحات التي تحتوي على وصلات.",
        "apihelp-query+allpages-param-dir": "الاتجاه للإدراج فيه.",
        "apihelp-query+allpages-param-filterlanglinks": "التصفية استنادا إلى ما إذا كانت الصفحة تحتوي على وصلات لغات، لاحظ أن هذا قد لا يفكر في  وصلات اللغات المضافة بواسطة الإضافات.",
        "apihelp-query+allpages-param-prexpiry": "مدة انتهاء الحماية لتصفية الصفحة فيها: \n; غير محددة: احصل على الصفحات التي لها تاريخ انتهاء غير محدود للحماية. \n; واضح: احصل على صفحات ذات مدة حماية محددة فقط.\n; الكل: الحصول على صفحات بأي انتهاء صلاحية للحماية.",
-       "apihelp-query+allpages-example-B": "عرض  قائمة من الصفحات التي تبدأ بالحرف <kbd>B</kbd>.",
+       "apihelp-query+allpages-example-b": "عرض  قائمة من الصفحات التي تبدأ بالحرف <kbd>B</kbd>.",
        "apihelp-query+allpages-example-generator": "عرض معلومات حول 4 صفحات تبدأ بالحرف <kbd>T</kbd>.",
        "apihelp-query+allpages-example-generator-revisions": "عرض محتوى أول صفحتين غير تحويلتين  التي تبدأ من <kbd>Re</kbd.",
        "apihelp-query+allredirects-summary": "أدرج جميع التحويلات إلى نطاق.",
        "apihelp-query+allredirects-param-namespace": "نطاق للتعداد.",
        "apihelp-query+allredirects-param-limit": "كم عدد مجموع البنود للعودة.",
        "apihelp-query+allredirects-param-dir": "الاتجاه للإدراج فيه.",
-       "apihelp-query+allredirects-example-B&qu