Skip to content

Instantly share code, notes, and snippets.

@ankita-kumari
Created March 10, 2015 22:32
Show Gist options
  • Save ankita-kumari/4254e114390795d97d18 to your computer and use it in GitHub Desktop.
Save ankita-kumari/4254e114390795d97d18 to your computer and use it in GitHub Desktop.
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
Copy link
Author

protected $localBasePath = '';

@ankita-kumari
Copy link
Author

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
Copy link
Author

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
Copy link
Author

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