r62179 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r62178‎ | r62179 | r62180 >
Date:10:54, 9 February 2010
Author:mglaser
Status:resolved (Comments)
Tags:
Comment:
adapted include of commandLine to phase3; commented out PEAR include and corrected a typo
Modified paths:
  • /trunk/extensions/PagedTiffHandler/tests/PagedTiffHandlerTest.php (modified) (history)

Diff [purge]

Index: trunk/extensions/PagedTiffHandler/tests/PagedTiffHandlerTest.php
@@ -1,12 +1,18 @@
22 <?php
33 /** To get this working you must
44 * - set a valid path to PEAR
5 -* - Upload the image Caspian.tif without PagedTiffHandler being active
 5+* - check upload size in php.ini: Multipage.tiff needs at least 3M
 6+* - Upload the image caspian.tif without PagedTiffHandler being active
67 * - Upload multipage.tiff when PagedTiffHandler is active
78 */
89
9 -require_once( dirname(__FILE__) . '/../../../maintenance/commandLine.inc' );
10 -ini_set( 'include_path', get_include_path() . PATH_SEPARATOR . /*$_SERVER['PHP_PEAR_INSTALL_DIR']*/ 'C:\php\pear' );
 10+try {
 11+ require_once( dirname(__FILE__) . '/../../../maintenance/commandLine.inc' );
 12+}
 13+catch(Exception $e) {
 14+ require_once( dirname(__FILE__) . '/../../../phase3/maintenance/commandLine.inc' );
 15+}
 16+// ini_set( 'include_path', get_include_path() . PATH_SEPARATOR . /*$_SERVER['PHP_PEAR_INSTALL_DIR']*/ 'C:\php\pear' );
1117 // requires PHPUnit 3.4
1218 require_once 'PHPUnit/Framework.php';
1319
@@ -15,6 +21,7 @@
1622
1723 private $handler;
1824 private $image;
 25+ private $preCheckError;
1926
2027 function setUp()
2128 {
@@ -32,7 +39,7 @@
3340 }
3441 if (!file_exists(dirname(__FILE__) . '/testImages/multipage.tiff'))
3542 {
36 - echo "testImages/Multitest_2.tif cannot be found.\n";
 43+ echo "testImages/Multipage.tif cannot be found.\n";
3744 $this->preCheckError = true;
3845 }
3946 if (!file_exists( dirname(__FILE__) . '/testImages'))

Follow-up revisions

RevisionCommit summaryAuthorDate
r62359Cleanup r62179: Use proper path detection like with other CL entry points, re...demon11:43, 12 February 2010

Comments

#Comment by 😂 (talk | contribs)   11:42, 9 February 2010
  • A failed require() isn't going to throw an exception, it'll throw a fatal error. Don't assume phase3, that's almost never correct. See how other extensions do it (specifically checking for MW_INSTALL_PATH if it exists). For example:
if ( getenv( 'MW_INSTALL_PATH' ) ) {
    $IP = getenv( 'MW_INSTALL_PATH' );
} else {
    $IP = dirname(__FILE__).'/../../..';
}
require "$IP/maintenance/commandLine.inc";
  • C:\php\pear will work for very few people, trying to guess where PEAR installs usually ends up not working (in general). Best bet is to make a note in your README that PEAR needs to be in the include path already.

Status & tagging log