Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
line 897 throws the error : The variable $localPath is wrong as that is what makes it look for the required file in wrong location.
protected function readStyleFile( $path, $flip, $context = null ) {
$localPath = $this->getLocalPath( $path );
$remotePath = $this->getRemotePath( $path );
if ( !file_exists( $localPath ) ) {
$msg = __METHOD__ . ": style file not found: \"$localPath\"";
wfDebugLog( 'resourceloader', $msg );
throw new MWException( $msg );
}
@ankita-kumari

This comment has been minimized.

Copy link
Owner Author

@ankita-kumari ankita-kumari commented Mar 10, 2015

    /**
     * @param string|ResourceLoaderFilePath $path
     * @return string
     */
    protected function getLocalPath( $path ) {
            if ( $path instanceof ResourceLoaderFilePath ) {
                    return $path->getLocalPath();
            }

            return "{$this->localBasePath}/$path";
    }
@ankita-kumari

This comment has been minimized.

Copy link
Owner Author

@ankita-kumari ankita-kumari commented Mar 10, 2015

protected $localBasePath = '';

@ankita-kumari

This comment has been minimized.

Copy link
Owner Author

@ankita-kumari ankita-kumari commented Mar 11, 2015

public function readStyleFiles( array $styles, $flip, $context = null ) {
if ( empty( $styles ) ) {
return array();
}
foreach ( $styles as $media => $files ) {
$uniqueFiles = array_unique( $files, SORT_REGULAR );
$styleFiles = array();
foreach ( $uniqueFiles as $file ) {
$styleFiles[] = $this->readStyleFile( $file, $flip, $context );
}
$styles[$media] = implode( "\n", $styleFiles );
}
return $styles;
}

@ankita-kumari

This comment has been minimized.

Copy link
Owner Author

@ankita-kumari ankita-kumari commented Mar 11, 2015

public function getStyles( ResourceLoaderContext $context ) {
$styles = $this->readStyleFiles(
$this->getStyleFiles( $context ),
$this->getFlip( $context ),
$context
);
// Collect referenced files
$this->localFileRefs = array_unique( $this->localFileRefs );
// If the list has been modified since last time we cached it, update the cache
try {
if ( $this->localFileRefs !== $this->getFileDependencies( $context->getSkin() ) ) {
$dbw = wfGetDB( DB_MASTER );
$dbw->replace( 'module_deps',
array( array( 'md_module', 'md_skin' ) ), array(
'md_module' => $this->getName(),
'md_skin' => $context->getSkin(),
'md_deps' => FormatJson::encode( $this->localFileRefs ),
)
);
}
} catch ( Exception $e ) {
wfDebugLog( 'resourceloader', METHOD . ": failed to update DB: $e" );
}
return $styles;
}

@ankita-kumari

This comment has been minimized.

Copy link
Owner Author

@ankita-kumari ankita-kumari commented Mar 11, 2015

public function getStyleFiles( ResourceLoaderContext $context ) {
return array_merge_recursive(
self::collateFilePathListByOption( $this->styles, 'media', 'all' ),
self::collateFilePathListByOption(
self::tryForKey( $this->skinStyles, $context->getSkin(), 'default' ),
'media',
'all'
)
);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.