Page MenuHomePhabricator

PHP Warning on showing Release Notes due to the fact that file does not exist
Closed, ResolvedPublic

Description

Author: moejoe0000

Description:
Use MediaWiki 1.18.1 and try to look at Release Notes in Installer:

http://127.0.0.1/w/mw-config/index.php?page=ReleaseNotes

Get the following warning:

Warning: file_get_contents([...]/www/w/includes/installer/../../RELEASE-NOTES): failed to open stream: No such file or directory in [...]/www/w/includes/installer/WebInstallerPage.php on line 1236.

The file "RELEASE-NOTES" does not exist (anymore) but it was renamed to "RELEASE-NOTES-1.18". WebInstallerPage.php does neither know this renaming nor check on existence of file.


Version: 1.18.x
Severity: minor

Details

Reference
bz33691

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 22 2014, 12:09 AM
bzimport set Reference to bz33691.
bzimport added a subscriber: Unknown Object (MLST).

I think we just need to get from $wgVersion the major and minor version, so we can drop the last number, and append that to the link to the release notes file

Ideally this needs fixing before 1.19 tarball

Attempting to symlink is just going to be asking for trouble

moejoe0000 wrote:

For me the following modification of /includes/installer/WebInstallerPage.php works well:

  • trunk/phase3/includes/installer/WebInstallerPage.php (revision 108689)

+++ trunk/phase3/includes/installer/WebInstallerPage.php (working copy)
@@ 1245,3 1245,11 @@
class WebInstaller_UpgradeDoc extends WebInstaller_Document {

  • protected function getFileName() { return 'RELEASE-NOTES'; }

+ protected function getFileName() {
+ global $wgVersion;
+
+ if(! preg_match( '/^(\d+)\.(\d+).*/i', $wgVersion, $result ) ) {
+ throw new MWException('Variable $wgVersion has an invalid value.');
+ }
+
+ return 'RELEASE-NOTES-' . $result[1] . '.' . $result[2];
+ }
}

Moreover, for me it seems rasonable to check if the user has deleted (or renamed...) one of the files:

  • trunk/phase3/includes/installer/WebInstallerPage.php (revision 108689)

+++ trunk/phase3/includes/installer/WebInstallerPage.php (working copy)
@@ 1235,3 1235,7 @@

	public function getFileContents() {
  • return file_get_contents( dirname( FILE ) . '/../../' . $this->getFileName() );

+ $file = dirname( FILE ) . '/../../' . $this->getFileName();
+ if( ! file_exists( $file ) ) {
+ return wfMsgNoTrans( 'config-nofile', $file );
+ }
+ return file_get_contents( $file );
}

  • trunk/phase3/includes/installer/Installer.i18n.php (revision 108689)

+++ trunk/phase3/includes/installer/Installer.i18n.php (working copy)

moejoe0000 wrote:

Sorry, I missed a bit:

  • trunk/phase3/includes/installer/Installer.i18n.php (revision 108689)

+++ trunk/phase3/includes/installer/Installer.i18n.php (working copy)
@@ 559,2 559,3 @@

+ 'config-nofile' => 'File "$1" could not be found.',
);

sumanah wrote:

moejoe0000, thanks for the patch! Could you please provide the patch as a unified diff against trunk?

https://en.wikipedia.org/wiki/en:Diff#Unified_format

Short version: $ svn di > /Users/you/Desktop/my_first_patch.diff

In case you need help with that: http://openhatch.org/missions/diffpatch

Thanks!

moejoe0000 wrote:

Patch as outlined in commets #2, #3

Attached: