# If we don't know whether the page exists, let's find out.
wfProfileIn( __METHOD__ . '-checkPageExistence' );
- if ( !in_array( 'known', $options ) and !in_array( 'broken', $options ) ) {
+ if ( !in_array( 'known', $options ) && !in_array( 'broken', $options ) ) {
if ( $target->isKnown() ) {
$options[] = 'known';
} else {
// Matches: LIMIT {[offset,] row_count | row_count OFFSET offset}
$pattern = '/\bLIMIT\s+((([0-9]+)\s*,\s*)?([0-9]+)(\s+OFFSET\s+([0-9]+))?)/i';
if ( preg_match( $pattern, $sql, $matches ) ) {
- // row_count = $matches[4]
$row_count = $matches[4];
- // offset = $matches[3] OR $matches[6]
- $offset = $matches[3] or
- $offset = $matches[6] or
- $offset = false;
+ $offset = $matches[3] ?: $matches[6] ?: false;
// strip the matching LIMIT clause out
$sql = str_replace( $matches[0], '', $sql );
$this->setNamespacePriorities();
$this->url_limit = 50000;
$this->size_limit = pow( 2, 20 ) * 10;
- $this->fspath = self::init_path( $this->getOption( 'fspath', getcwd() ) );
+
+ # Create directory if needed
+ $fspath = $this->getOption( 'fspath', getcwd() );
+ if ( !wfMkdirParents( $fspath, null, __METHOD__ ) ) {
+ $this->error( "Can not create directory $fspath.", 1 );
+ }
+
+ $this->fspath = realpath( $fspath ) . DIRECTORY_SEPARATOR;
$this->urlpath = $this->getOption( 'urlpath', "" );
if ( $this->urlpath !== "" && substr( $this->urlpath, -1 ) !== '/' ) {
$this->urlpath .= '/';
}
}
- /**
- * Create directory if it does not exist and return pathname with a trailing slash
- * @param string $fspath
- * @return null|string
- */
- private static function init_path( $fspath ) {
- # Create directory if needed
- if ( $fspath && !is_dir( $fspath ) ) {
- wfMkdirParents( $fspath, null, __METHOD__ ) or die( "Can not create directory $fspath.\n" );
- }
-
- return realpath( $fspath ) . DIRECTORY_SEPARATOR;
- }
-
/**
* Generate a one-dimensional array of existing namespaces
*/