Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
Complex classes like ResourceLoaderModule often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use ResourceLoaderModule, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 32 | abstract class ResourceLoaderModule implements LoggerAwareInterface { |
||
| 33 | # Type of resource |
||
| 34 | const TYPE_SCRIPTS = 'scripts'; |
||
| 35 | const TYPE_STYLES = 'styles'; |
||
| 36 | const TYPE_COMBINED = 'combined'; |
||
| 37 | |||
| 38 | # Desired load type |
||
| 39 | // Module only has styles (loaded via <style> or <link rel=stylesheet>) |
||
| 40 | const LOAD_STYLES = 'styles'; |
||
| 41 | // Module may have other resources (loaded via mw.loader from a script) |
||
| 42 | const LOAD_GENERAL = 'general'; |
||
| 43 | |||
| 44 | # sitewide core module like a skin file or jQuery component |
||
| 45 | const ORIGIN_CORE_SITEWIDE = 1; |
||
| 46 | |||
| 47 | # per-user module generated by the software |
||
| 48 | const ORIGIN_CORE_INDIVIDUAL = 2; |
||
| 49 | |||
| 50 | # sitewide module generated from user-editable files, like MediaWiki:Common.js, or |
||
| 51 | # modules accessible to multiple users, such as those generated by the Gadgets extension. |
||
| 52 | const ORIGIN_USER_SITEWIDE = 3; |
||
| 53 | |||
| 54 | # per-user module generated from user-editable files, like User:Me/vector.js |
||
| 55 | const ORIGIN_USER_INDIVIDUAL = 4; |
||
| 56 | |||
| 57 | # an access constant; make sure this is kept as the largest number in this group |
||
| 58 | const ORIGIN_ALL = 10; |
||
| 59 | |||
| 60 | # script and style modules form a hierarchy of trustworthiness, with core modules like |
||
| 61 | # skins and jQuery as most trustworthy, and user scripts as least trustworthy. We can |
||
| 62 | # limit the types of scripts and styles we allow to load on, say, sensitive special |
||
| 63 | # pages like Special:UserLogin and Special:Preferences |
||
| 64 | protected $origin = self::ORIGIN_CORE_SITEWIDE; |
||
| 65 | |||
| 66 | /* Protected Members */ |
||
| 67 | |||
| 68 | protected $name = null; |
||
| 69 | protected $targets = [ 'desktop' ]; |
||
| 70 | |||
| 71 | // In-object cache for file dependencies |
||
| 72 | protected $fileDeps = []; |
||
| 73 | // In-object cache for message blob (keyed by language) |
||
| 74 | protected $msgBlobs = []; |
||
| 75 | // In-object cache for version hash |
||
| 76 | protected $versionHash = []; |
||
| 77 | // In-object cache for module content |
||
| 78 | protected $contents = []; |
||
| 79 | |||
| 80 | /** |
||
| 81 | * @var Config |
||
| 82 | */ |
||
| 83 | protected $config; |
||
| 84 | |||
| 85 | /** |
||
| 86 | * @var LoggerInterface |
||
| 87 | */ |
||
| 88 | protected $logger; |
||
| 89 | |||
| 90 | /* Methods */ |
||
| 91 | |||
| 92 | /** |
||
| 93 | * Get this module's name. This is set when the module is registered |
||
| 94 | * with ResourceLoader::register() |
||
| 95 | * |
||
| 96 | * @return string|null Name (string) or null if no name was set |
||
| 97 | */ |
||
| 98 | public function getName() { |
||
| 101 | |||
| 102 | /** |
||
| 103 | * Set this module's name. This is called by ResourceLoader::register() |
||
| 104 | * when registering the module. Other code should not call this. |
||
| 105 | * |
||
| 106 | * @param string $name Name |
||
| 107 | */ |
||
| 108 | public function setName( $name ) { |
||
| 111 | |||
| 112 | /** |
||
| 113 | * Get this module's origin. This is set when the module is registered |
||
| 114 | * with ResourceLoader::register() |
||
| 115 | * |
||
| 116 | * @return int ResourceLoaderModule class constant, the subclass default |
||
| 117 | * if not set manually |
||
| 118 | */ |
||
| 119 | public function getOrigin() { |
||
| 122 | |||
| 123 | /** |
||
| 124 | * @param ResourceLoaderContext $context |
||
| 125 | * @return bool |
||
| 126 | */ |
||
| 127 | public function getFlip( $context ) { |
||
| 132 | |||
| 133 | /** |
||
| 134 | * Get all JS for this module for a given language and skin. |
||
| 135 | * Includes all relevant JS except loader scripts. |
||
| 136 | * |
||
| 137 | * @param ResourceLoaderContext $context |
||
| 138 | * @return string JavaScript code |
||
| 139 | */ |
||
| 140 | public function getScript( ResourceLoaderContext $context ) { |
||
| 144 | |||
| 145 | /** |
||
| 146 | * Takes named templates by the module and returns an array mapping. |
||
| 147 | * |
||
| 148 | * @return array of templates mapping template alias to content |
||
| 149 | */ |
||
| 150 | public function getTemplates() { |
||
| 154 | |||
| 155 | /** |
||
| 156 | * @return Config |
||
| 157 | * @since 1.24 |
||
| 158 | */ |
||
| 159 | View Code Duplication | public function getConfig() { |
|
| 167 | |||
| 168 | /** |
||
| 169 | * @param Config $config |
||
| 170 | * @since 1.24 |
||
| 171 | */ |
||
| 172 | public function setConfig( Config $config ) { |
||
| 175 | |||
| 176 | /** |
||
| 177 | * @since 1.27 |
||
| 178 | * @param LoggerInterface $logger |
||
| 179 | * @return null |
||
| 180 | */ |
||
| 181 | public function setLogger( LoggerInterface $logger ) { |
||
| 184 | |||
| 185 | /** |
||
| 186 | * @since 1.27 |
||
| 187 | * @return LoggerInterface |
||
| 188 | */ |
||
| 189 | protected function getLogger() { |
||
| 195 | |||
| 196 | /** |
||
| 197 | * Get the URL or URLs to load for this module's JS in debug mode. |
||
| 198 | * The default behavior is to return a load.php?only=scripts URL for |
||
| 199 | * the module, but file-based modules will want to override this to |
||
| 200 | * load the files directly. |
||
| 201 | * |
||
| 202 | * This function is called only when 1) we're in debug mode, 2) there |
||
| 203 | * is no only= parameter and 3) supportsURLLoading() returns true. |
||
| 204 | * #2 is important to prevent an infinite loop, therefore this function |
||
| 205 | * MUST return either an only= URL or a non-load.php URL. |
||
| 206 | * |
||
| 207 | * @param ResourceLoaderContext $context |
||
| 208 | * @return array Array of URLs |
||
| 209 | */ |
||
| 210 | View Code Duplication | public function getScriptURLsForDebug( ResourceLoaderContext $context ) { |
|
| 224 | |||
| 225 | /** |
||
| 226 | * Whether this module supports URL loading. If this function returns false, |
||
| 227 | * getScript() will be used even in cases (debug mode, no only param) where |
||
| 228 | * getScriptURLsForDebug() would normally be used instead. |
||
| 229 | * @return bool |
||
| 230 | */ |
||
| 231 | public function supportsURLLoading() { |
||
| 234 | |||
| 235 | /** |
||
| 236 | * Get all CSS for this module for a given skin. |
||
| 237 | * |
||
| 238 | * @param ResourceLoaderContext $context |
||
| 239 | * @return array List of CSS strings or array of CSS strings keyed by media type. |
||
| 240 | * like array( 'screen' => '.foo { width: 0 }' ); |
||
| 241 | * or array( 'screen' => array( '.foo { width: 0 }' ) ); |
||
| 242 | */ |
||
| 243 | public function getStyles( ResourceLoaderContext $context ) { |
||
| 247 | |||
| 248 | /** |
||
| 249 | * Get the URL or URLs to load for this module's CSS in debug mode. |
||
| 250 | * The default behavior is to return a load.php?only=styles URL for |
||
| 251 | * the module, but file-based modules will want to override this to |
||
| 252 | * load the files directly. See also getScriptURLsForDebug() |
||
| 253 | * |
||
| 254 | * @param ResourceLoaderContext $context |
||
| 255 | * @return array Array( mediaType => array( URL1, URL2, ... ), ... ) |
||
| 256 | */ |
||
| 257 | View Code Duplication | public function getStyleURLsForDebug( ResourceLoaderContext $context ) { |
|
| 271 | |||
| 272 | /** |
||
| 273 | * Get the messages needed for this module. |
||
| 274 | * |
||
| 275 | * To get a JSON blob with messages, use MessageBlobStore::get() |
||
| 276 | * |
||
| 277 | * @return array List of message keys. Keys may occur more than once |
||
| 278 | */ |
||
| 279 | public function getMessages() { |
||
| 283 | |||
| 284 | /** |
||
| 285 | * Get the group this module is in. |
||
| 286 | * |
||
| 287 | * @return string Group name |
||
| 288 | */ |
||
| 289 | public function getGroup() { |
||
| 293 | |||
| 294 | /** |
||
| 295 | * Get the origin of this module. Should only be overridden for foreign modules. |
||
| 296 | * |
||
| 297 | * @return string Origin name, 'local' for local modules |
||
| 298 | */ |
||
| 299 | public function getSource() { |
||
| 303 | |||
| 304 | /** |
||
| 305 | * Where on the HTML page should this module's JS be loaded? |
||
| 306 | * - 'top': in the "<head>" |
||
| 307 | * - 'bottom': at the bottom of the "<body>" |
||
| 308 | * |
||
| 309 | * @return string |
||
| 310 | */ |
||
| 311 | public function getPosition() { |
||
| 314 | |||
| 315 | /** |
||
| 316 | * Whether this module's JS expects to work without the client-side ResourceLoader module. |
||
| 317 | * Returning true from this function will prevent mw.loader.state() call from being |
||
| 318 | * appended to the bottom of the script. |
||
| 319 | * |
||
| 320 | * @return bool |
||
| 321 | */ |
||
| 322 | public function isRaw() { |
||
| 325 | |||
| 326 | /** |
||
| 327 | * Get a list of modules this module depends on. |
||
| 328 | * |
||
| 329 | * Dependency information is taken into account when loading a module |
||
| 330 | * on the client side. |
||
| 331 | * |
||
| 332 | * Note: It is expected that $context will be made non-optional in the near |
||
| 333 | * future. |
||
| 334 | * |
||
| 335 | * @param ResourceLoaderContext $context |
||
| 336 | * @return array List of module names as strings |
||
| 337 | */ |
||
| 338 | public function getDependencies( ResourceLoaderContext $context = null ) { |
||
| 342 | |||
| 343 | /** |
||
| 344 | * Get target(s) for the module, eg ['desktop'] or ['desktop', 'mobile'] |
||
| 345 | * |
||
| 346 | * @return array Array of strings |
||
| 347 | */ |
||
| 348 | public function getTargets() { |
||
| 351 | |||
| 352 | /** |
||
| 353 | * Get the module's load type. |
||
| 354 | * |
||
| 355 | * @since 1.28 |
||
| 356 | * @return string ResourceLoaderModule LOAD_* constant |
||
| 357 | */ |
||
| 358 | public function getType() { |
||
| 361 | |||
| 362 | /** |
||
| 363 | * Get the skip function. |
||
| 364 | * |
||
| 365 | * Modules that provide fallback functionality can provide a "skip function". This |
||
| 366 | * function, if provided, will be passed along to the module registry on the client. |
||
| 367 | * When this module is loaded (either directly or as a dependency of another module), |
||
| 368 | * then this function is executed first. If the function returns true, the module will |
||
| 369 | * instantly be considered "ready" without requesting the associated module resources. |
||
| 370 | * |
||
| 371 | * The value returned here must be valid javascript for execution in a private function. |
||
| 372 | * It must not contain the "function () {" and "}" wrapper though. |
||
| 373 | * |
||
| 374 | * @return string|null A JavaScript function body returning a boolean value, or null |
||
| 375 | */ |
||
| 376 | public function getSkipFunction() { |
||
| 379 | |||
| 380 | /** |
||
| 381 | * Get the files this module depends on indirectly for a given skin. |
||
| 382 | * |
||
| 383 | * These are only image files referenced by the module's stylesheet. |
||
| 384 | * |
||
| 385 | * @param ResourceLoaderContext $context |
||
| 386 | * @return array List of files |
||
| 387 | */ |
||
| 388 | protected function getFileDependencies( ResourceLoaderContext $context ) { |
||
| 413 | |||
| 414 | /** |
||
| 415 | * Set in-object cache for file dependencies. |
||
| 416 | * |
||
| 417 | * This is used to retrieve data in batches. See ResourceLoader::preloadModuleInfo(). |
||
| 418 | * To save the data, use saveFileDependencies(). |
||
| 419 | * |
||
| 420 | * @param ResourceLoaderContext $context |
||
| 421 | * @param string[] $files Array of file names |
||
| 422 | */ |
||
| 423 | public function setFileDependencies( ResourceLoaderContext $context, $files ) { |
||
| 427 | |||
| 428 | /** |
||
| 429 | * Set the files this module depends on indirectly for a given skin. |
||
| 430 | * |
||
| 431 | * @since 1.27 |
||
| 432 | * @param ResourceLoaderContext $context |
||
| 433 | * @param array $localFileRefs List of files |
||
| 434 | */ |
||
| 435 | protected function saveFileDependencies( ResourceLoaderContext $context, $localFileRefs ) { |
||
| 470 | |||
| 471 | /** |
||
| 472 | * Make file paths relative to MediaWiki directory. |
||
| 473 | * |
||
| 474 | * This is used to make file paths safe for storing in a database without the paths |
||
| 475 | * becoming stale or incorrect when MediaWiki is moved or upgraded (T111481). |
||
| 476 | * |
||
| 477 | * @since 1.27 |
||
| 478 | * @param array $filePaths |
||
| 479 | * @return array |
||
| 480 | */ |
||
| 481 | public static function getRelativePaths( array $filePaths ) { |
||
| 487 | |||
| 488 | /** |
||
| 489 | * Expand directories relative to $IP. |
||
| 490 | * |
||
| 491 | * @since 1.27 |
||
| 492 | * @param array $filePaths |
||
| 493 | * @return array |
||
| 494 | */ |
||
| 495 | public static function expandRelativePaths( array $filePaths ) { |
||
| 501 | |||
| 502 | /** |
||
| 503 | * Get the hash of the message blob. |
||
| 504 | * |
||
| 505 | * @since 1.27 |
||
| 506 | * @param ResourceLoaderContext $context |
||
| 507 | * @return string|null JSON blob or null if module has no messages |
||
| 508 | */ |
||
| 509 | protected function getMessageBlob( ResourceLoaderContext $context ) { |
||
| 525 | |||
| 526 | /** |
||
| 527 | * Set in-object cache for message blobs. |
||
| 528 | * |
||
| 529 | * Used to allow fetching of message blobs in batches. See ResourceLoader::preloadModuleInfo(). |
||
| 530 | * |
||
| 531 | * @since 1.27 |
||
| 532 | * @param string|null $blob JSON blob or null |
||
| 533 | * @param string $lang Language code |
||
| 534 | */ |
||
| 535 | public function setMessageBlob( $blob, $lang ) { |
||
| 538 | |||
| 539 | /** |
||
| 540 | * Get module-specific LESS variables, if any. |
||
| 541 | * |
||
| 542 | * @since 1.27 |
||
| 543 | * @param ResourceLoaderContext $context |
||
| 544 | * @return array Module-specific LESS variables. |
||
| 545 | */ |
||
| 546 | protected function getLessVars( ResourceLoaderContext $context ) { |
||
| 549 | |||
| 550 | /** |
||
| 551 | * Get an array of this module's resources. Ready for serving to the web. |
||
| 552 | * |
||
| 553 | * @since 1.26 |
||
| 554 | * @param ResourceLoaderContext $context |
||
| 555 | * @return array |
||
| 556 | */ |
||
| 557 | public function getModuleContent( ResourceLoaderContext $context ) { |
||
| 566 | |||
| 567 | /** |
||
| 568 | * Bundle all resources attached to this module into an array. |
||
| 569 | * |
||
| 570 | * @since 1.26 |
||
| 571 | * @param ResourceLoaderContext $context |
||
| 572 | * @return array |
||
| 573 | */ |
||
| 574 | final protected function buildContent( ResourceLoaderContext $context ) { |
||
| 669 | |||
| 670 | /** |
||
| 671 | * Get a string identifying the current version of this module in a given context. |
||
| 672 | * |
||
| 673 | * Whenever anything happens that changes the module's response (e.g. scripts, styles, and |
||
| 674 | * messages) this value must change. This value is used to store module responses in cache. |
||
| 675 | * (Both client-side and server-side.) |
||
| 676 | * |
||
| 677 | * It is not recommended to override this directly. Use getDefinitionSummary() instead. |
||
| 678 | * If overridden, one must call the parent getVersionHash(), append data and re-hash. |
||
| 679 | * |
||
| 680 | * This method should be quick because it is frequently run by ResourceLoaderStartUpModule to |
||
| 681 | * propagate changes to the client and effectively invalidate cache. |
||
| 682 | * |
||
| 683 | * For backward-compatibility, the following optional data providers are automatically included: |
||
| 684 | * |
||
| 685 | * - getModifiedTime() |
||
| 686 | * - getModifiedHash() |
||
| 687 | * |
||
| 688 | * @since 1.26 |
||
| 689 | * @param ResourceLoaderContext $context |
||
| 690 | * @return string Hash (should use ResourceLoader::makeHash) |
||
| 691 | */ |
||
| 692 | public function getVersionHash( ResourceLoaderContext $context ) { |
||
| 736 | |||
| 737 | /** |
||
| 738 | * Whether to generate version hash based on module content. |
||
| 739 | * |
||
| 740 | * If a module requires database or file system access to build the module |
||
| 741 | * content, consider disabling this in favour of manually tracking relevant |
||
| 742 | * aspects in getDefinitionSummary(). See getVersionHash() for how this is used. |
||
| 743 | * |
||
| 744 | * @return bool |
||
| 745 | */ |
||
| 746 | public function enableModuleContentVersion() { |
||
| 749 | |||
| 750 | /** |
||
| 751 | * Get the definition summary for this module. |
||
| 752 | * |
||
| 753 | * This is the method subclasses are recommended to use to track values in their |
||
| 754 | * version hash. Call this in getVersionHash() and pass it to e.g. json_encode. |
||
| 755 | * |
||
| 756 | * Subclasses must call the parent getDefinitionSummary() and build on that. |
||
| 757 | * It is recommended that each subclass appends its own new array. This prevents |
||
| 758 | * clashes or accidental overwrites of existing keys and gives each subclass |
||
| 759 | * its own scope for simple array keys. |
||
| 760 | * |
||
| 761 | * @code |
||
| 762 | * $summary = parent::getDefinitionSummary( $context ); |
||
| 763 | * $summary[] = array( |
||
| 764 | * 'foo' => 123, |
||
| 765 | * 'bar' => 'quux', |
||
| 766 | * ); |
||
| 767 | * return $summary; |
||
| 768 | * @endcode |
||
| 769 | * |
||
| 770 | * Return an array containing values from all significant properties of this |
||
| 771 | * module's definition. |
||
| 772 | * |
||
| 773 | * Be careful not to normalise too much. Especially preserve the order of things |
||
| 774 | * that carry significance in getScript and getStyles (T39812). |
||
| 775 | * |
||
| 776 | * Avoid including things that are insiginificant (e.g. order of message keys is |
||
| 777 | * insignificant and should be sorted to avoid unnecessary cache invalidation). |
||
| 778 | * |
||
| 779 | * This data structure must exclusively contain arrays and scalars as values (avoid |
||
| 780 | * object instances) to allow simple serialisation using json_encode. |
||
| 781 | * |
||
| 782 | * If modules have a hash or timestamp from another source, that may be incuded as-is. |
||
| 783 | * |
||
| 784 | * A number of utility methods are available to help you gather data. These are not |
||
| 785 | * called by default and must be included by the subclass' getDefinitionSummary(). |
||
| 786 | * |
||
| 787 | * - getMessageBlob() |
||
| 788 | * |
||
| 789 | * @since 1.23 |
||
| 790 | * @param ResourceLoaderContext $context |
||
| 791 | * @return array|null |
||
| 792 | */ |
||
| 793 | public function getDefinitionSummary( ResourceLoaderContext $context ) { |
||
| 799 | |||
| 800 | /** |
||
| 801 | * Get this module's last modification timestamp for a given context. |
||
| 802 | * |
||
| 803 | * @deprecated since 1.26 Use getDefinitionSummary() instead |
||
| 804 | * @param ResourceLoaderContext $context Context object |
||
| 805 | * @return int|null UNIX timestamp |
||
| 806 | */ |
||
| 807 | public function getModifiedTime( ResourceLoaderContext $context ) { |
||
| 810 | |||
| 811 | /** |
||
| 812 | * Helper method for providing a version hash to getVersionHash(). |
||
| 813 | * |
||
| 814 | * @deprecated since 1.26 Use getDefinitionSummary() instead |
||
| 815 | * @param ResourceLoaderContext $context |
||
| 816 | * @return string|null Hash |
||
| 817 | */ |
||
| 818 | public function getModifiedHash( ResourceLoaderContext $context ) { |
||
| 821 | |||
| 822 | /** |
||
| 823 | * Back-compat dummy for old subclass implementations of getModifiedTime(). |
||
| 824 | * |
||
| 825 | * This method used to use ObjectCache to track when a hash was first seen. That principle |
||
| 826 | * stems from a time that ResourceLoader could only identify module versions by timestamp. |
||
| 827 | * That is no longer the case. Use getDefinitionSummary() directly. |
||
| 828 | * |
||
| 829 | * @deprecated since 1.26 Superseded by getVersionHash() |
||
| 830 | * @param ResourceLoaderContext $context |
||
| 831 | * @return int UNIX timestamp |
||
| 832 | */ |
||
| 833 | public function getHashMtime( ResourceLoaderContext $context ) { |
||
| 840 | |||
| 841 | /** |
||
| 842 | * Back-compat dummy for old subclass implementations of getModifiedTime(). |
||
| 843 | * |
||
| 844 | * @since 1.23 |
||
| 845 | * @deprecated since 1.26 Superseded by getVersionHash() |
||
| 846 | * @param ResourceLoaderContext $context |
||
| 847 | * @return int UNIX timestamp |
||
| 848 | */ |
||
| 849 | public function getDefinitionMtime( ResourceLoaderContext $context ) { |
||
| 856 | |||
| 857 | /** |
||
| 858 | * Check whether this module is known to be empty. If a child class |
||
| 859 | * has an easy and cheap way to determine that this module is |
||
| 860 | * definitely going to be empty, it should override this method to |
||
| 861 | * return true in that case. Callers may optimize the request for this |
||
| 862 | * module away if this function returns true. |
||
| 863 | * @param ResourceLoaderContext $context |
||
| 864 | * @return bool |
||
| 865 | */ |
||
| 866 | public function isKnownEmpty( ResourceLoaderContext $context ) { |
||
| 869 | |||
| 870 | /** @var JSParser Lazy-initialized; use self::javaScriptParser() */ |
||
| 871 | private static $jsParser; |
||
| 872 | private static $parseCacheVersion = 1; |
||
| 873 | |||
| 874 | /** |
||
| 875 | * Validate a given script file; if valid returns the original source. |
||
| 876 | * If invalid, returns replacement JS source that throws an exception. |
||
| 877 | * |
||
| 878 | * @param string $fileName |
||
| 879 | * @param string $contents |
||
| 880 | * @return string JS with the original, or a replacement error |
||
| 881 | */ |
||
| 882 | protected function validateScriptFile( $fileName, $contents ) { |
||
| 914 | |||
| 915 | /** |
||
| 916 | * @return JSParser |
||
| 917 | */ |
||
| 918 | protected static function javaScriptParser() { |
||
| 924 | |||
| 925 | /** |
||
| 926 | * Safe version of filemtime(), which doesn't throw a PHP warning if the file doesn't exist. |
||
| 927 | * Defaults to 1. |
||
| 928 | * |
||
| 929 | * @param string $filePath File path |
||
| 930 | * @return int UNIX timestamp |
||
| 931 | */ |
||
| 932 | protected static function safeFilemtime( $filePath ) { |
||
| 938 | |||
| 939 | /** |
||
| 940 | * Compute a non-cryptographic string hash of a file's contents. |
||
| 941 | * If the file does not exist or cannot be read, returns an empty string. |
||
| 942 | * |
||
| 943 | * @since 1.26 Uses MD4 instead of SHA1. |
||
| 944 | * @param string $filePath File path |
||
| 945 | * @return string Hash |
||
| 946 | */ |
||
| 947 | protected static function safeFileHash( $filePath ) { |
||
| 950 | } |
||
| 951 |
This method has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.