wiki.techinc.nl/includes/page/PageLookup.php
Tim Starling 917f0a5996 Replace all instances of "per default" with "by default"
According to the dictionary, "per" (or more conventionally "as per")
means "according to". Refer OED "per" sense II.3.a. For example:

"No value was passed, so return null, as per default".

In this sentence, we are not specifying the default, we are referring
to the default. This correct usage of "per default" was used nowhere
in MediaWiki core as far as I can see.

Instead we have "per default" being used to mean "by default", that is,
giving the value to use when no explicit value was specified.

In OED, the phrase "by default" is blessed with its own section just
for computing usage:

"P.1.e. Computing. As an option or setting adopted automatically by a
computer program whenever an alternative is not specified by the user
or programmer. Cf. sense I.7a."

There are highly similar pre-computing usages of the same phrase,
whereas the phrase "per default" is not mentioned.

As a matter of style, I think "per default" should not be used even
when it is strictly correct, since the common incorrect usage makes it
ambiguous and misleading.

Change-Id: Ibcccc65ead864d082677b472b34ff32ff41c60ae
2024-04-29 10:47:54 +10:00

124 lines
3.6 KiB
PHP

<?php
namespace MediaWiki\Page;
use IDBAccessObject;
use InvalidArgumentException;
use MediaWiki\Linker\LinkTarget;
/**
* Service for looking up information about wiki pages.
*
* Default implementation is PageStore.
*
* @since 1.36
* @ingroup Page
*/
interface PageLookup {
/**
* Returns the PageIdentity for the given LinkTarget. The page does not have to exist.
* Fragments are ignored.
*
* The LinkTarget must refer to a proper page - that is, it must not be a relative section link,
* an interwiki link, or refer to a special page.
*
* @param LinkTarget $link
* @param int $queryFlags
*
* @throws InvalidArgumentException if $link does not refer to a proper page.
* @return ProperPageIdentity
*/
public function getPageForLink(
LinkTarget $link,
int $queryFlags = IDBAccessObject::READ_NORMAL
): ProperPageIdentity;
/**
* Returns the PageRecord of the given page.
*
* @param int $pageId
* @param int $queryFlags
*
* @throws InvalidArgumentException if $pageId is 0 or negative.
* @return ExistingPageRecord|null The page's PageRecord, or null if the page was not found.
*/
public function getPageById(
int $pageId,
int $queryFlags = IDBAccessObject::READ_NORMAL
): ?ExistingPageRecord;
/**
* Returns the PageRecord for the given name and namespace.
*
* @param int $namespace
* @param string $dbKey
* @param int $queryFlags
*
* @return ExistingPageRecord|null The page's PageRecord, or null if the page was not found.
* @throws InvalidArgumentException if $namespace is negative or $dbKey is empty.
*/
public function getPageByName(
int $namespace,
string $dbKey,
int $queryFlags = IDBAccessObject::READ_NORMAL
): ?ExistingPageRecord;
/**
* Returns a PageIdentity for a given user provided page name text.
* Returns null if the title is not a valid name of a proper page,
* e.g if it is a special page, an interwiki link, a relative section line, or simply invalid.
*
* @since 1.37
*
* @param string $text
* @param int $defaultNamespace Namespace to assume by default (usually NS_MAIN)
* @param int $queryFlags
*
* @return ProperPageIdentity|null
*/
public function getPageByText(
string $text,
int $defaultNamespace = NS_MAIN,
int $queryFlags = IDBAccessObject::READ_NORMAL
): ?ProperPageIdentity;
/**
* Returns an ExistingPageRecord for a given user provided page name text.
*
* Returns null if the page does not exist or if title is not a valid name of a proper page,
* e.g if it is a special page, an interwiki link, a relative section line, or simply invalid.
*
* @since 1.37
*
* @param string $text
* @param int $defaultNamespace Namespace to assume by default (usually NS_MAIN)
* @param int $queryFlags
*
* @return ExistingPageRecord|null
*/
public function getExistingPageByText(
string $text,
int $defaultNamespace = NS_MAIN,
int $queryFlags = IDBAccessObject::READ_NORMAL
): ?ExistingPageRecord;
/**
* Returns the PageRecord of the given page.
* May return $page if that already is a PageRecord.
* If $page is a PageIdentity, implementations may call methods like exists() and getId() on it.
*
* The PageReference must refer to a proper page - that is, it must not refer to a special page.
*
* @param PageReference $page
* @param int $queryFlags
*
* @return ExistingPageRecord|null The page's PageRecord, or null if the page was not found.
* @throws InvalidArgumentException if $page does not refer to a proper page.
*/
public function getPageByReference(
PageReference $page,
int $queryFlags = IDBAccessObject::READ_NORMAL
): ?ExistingPageRecord;
}